summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <andy.doan@linaro.org>2016-05-09 15:55:39 -0500
committerAndy Doan <andy.doan@linaro.org>2016-05-09 15:55:39 -0500
commitf976d605b9cd4800afabb63b9da1130098e58554 (patch)
treebbb508c39fcd43e7cdad6168dfba58b5fe2c509c
parentd403074136f046bb9066fb17a559557babe0c9f0 (diff)
colo: update devcloud-admin script
Add a quirk for installing rp-centos7 as well as a status command. Change-Id: I0a764caf9944985cf6b7633f1905bec307ba0f67
-rwxr-xr-xroles/devcloud-admin/files/devcloud.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/roles/devcloud-admin/files/devcloud.py b/roles/devcloud-admin/files/devcloud.py
index 3b86a04c..37434369 100755
--- a/roles/devcloud-admin/files/devcloud.py
+++ b/roles/devcloud-admin/files/devcloud.py
@@ -58,8 +58,13 @@ def _start_instance(server, flavor, image, sshkey):
with tempfile.NamedTemporaryFile('w', delete=False) as f:
f.write('#!/bin/sh -ex\n')
f.write('echo "%s" >> /home/admin/.ssh/authorized_keys\n' % sshkey)
- f.write('systemctl enable systemd-timesyncd\n')
- f.write('systemctl start systemd-timesyncd\n')
+ if image == 'rp-debian-jessie':
+ f.write('systemctl enable systemd-timesyncd\n')
+ f.write('systemctl start systemd-timesyncd\n')
+ elif image == 'rp-centos7':
+ # resolv.conf is set up wrong, it gets fixed after reboot
+ # but this keeps it up and going for now
+ f.write('echo nameserver 8.8.8.8 > /etc/resolv.conf\n')
try:
subprocess.check_call(
@@ -89,6 +94,9 @@ def create(args):
args.sshkey = open(args.sshkey).read()
_start_instance(args.name, args.flavor, args.image, args.sshkey)
+ if args.private_ip:
+ log.debug('--private-ip specificied, skipping public ip allocation')
+ return
try:
ip = _wait_for_ip(args.name)
log.debug('internal ip: %s', ip)
@@ -106,11 +114,15 @@ def delete(args):
if ip:
_unmap_ip(ip)
else:
- log.warn('No public IP address found?')
+ log.debug('No public IP address found')
log.info('Deleting openstack instance')
subprocess.check_call(['openstack', 'server', 'delete', args.name])
+def show(args):
+ subprocess.check_call(['openstack', 'server', 'show', args.name])
+
+
if __name__ == '__main__':
images = ('rp-debian-jessie', 'rp-centos7')
flavors = ('m1.small', 'm1.medium', 'm1.large', 'm1.xlarge')
@@ -128,11 +140,17 @@ if __name__ == '__main__':
p.add_argument('--flavor', '-f', required=True, choices=flavors)
p.add_argument('--sshkey', '-k', required=True,
help='Users ssh key(s) can be file or string')
+ p.add_argument('--private-ip', action='store_true',
+ help='Do not allocate a public IP for this instance')
p = cmds.add_parser('delete-instance')
p.set_defaults(func=delete)
p.add_argument('--name', '-n', required=True)
+ p = cmds.add_parser('show-instance')
+ p.set_defaults(func=show)
+ p.add_argument('--name', '-n', required=True)
+
args = parser.parse_args()
log.setLevel(getattr(logging, args.log))