Merge "Fixed launch output."

This commit is contained in:
Zuul 2019-12-17 17:17:36 +00:00 committed by Gerrit Code Review
commit 500b328495
1 changed files with 17 additions and 12 deletions

View File

@ -146,23 +146,28 @@ def launch(name, args):
'-c', 'floating_ip_address', 'external') '-c', 'floating_ip_address', 'external')
check('openstack', 'server', 'add', 'floating', 'ip', server_id, ip) check('openstack', 'server', 'add', 'floating', 'ip', server_id, ip)
# We've launched! Make some guesses about usernames and the
# location of the ssh key in the operator's system, so we can tell
# the them how to access their new server. TODO: is it possible
# to make this logic more sophisticated?
username = '<username>' username = '<username>'
if args.flavor: if 'fedora' in args.image.lower():
# Try to guess at a username. username = 'fedora'
# TODO: make this more sophisticated. if 'ubuntu' in args.image.lower():
if 'fedora' in args.flavor.lower(): username = 'ubuntu'
username = 'fedora' if 'cirros' in args.image.lower():
if 'ubuntu' in args.flavor.lower(): username = 'cirros'
username = 'ubuntu'
if 'cirros' in args.flavor.lower(): ssh_key = '/path/to/ssh/key'
username = 'cirros' if args.key == 'microstack':
ssh_key = '$HOME/.ssh/id_microstack'
print("""\ print("""\
Server {name} launched! (status is {status}) Server {name} launched! (status is {status})
Access it with `ssh -i \ Access it with `ssh -i {ssh_key} {username}@{ip}`\
$HOME/.ssh/id_microstack` {username}@{ip}""".format(name=name, status=status, """.format(name=name, status=status, ssh_key=ssh_key,
username=username, ip=ip)) username=username, ip=ip))
gate = check_output('snapctl', 'get', 'config.network.ext-gateway') gate = check_output('snapctl', 'get', 'config.network.ext-gateway')
port = check_output('snapctl', 'get', 'config.network.ports.dashboard') port = check_output('snapctl', 'get', 'config.network.ports.dashboard')