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,22 +146,27 @@ def launch(name, args):
'-c', 'floating_ip_address', 'external')
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>'
if args.flavor:
# Try to guess at a username.
# TODO: make this more sophisticated.
if 'fedora' in args.flavor.lower():
if 'fedora' in args.image.lower():
username = 'fedora'
if 'ubuntu' in args.flavor.lower():
if 'ubuntu' in args.image.lower():
username = 'ubuntu'
if 'cirros' in args.flavor.lower():
if 'cirros' in args.image.lower():
username = 'cirros'
ssh_key = '/path/to/ssh/key'
if args.key == 'microstack':
ssh_key = '$HOME/.ssh/id_microstack'
print("""\
Server {name} launched! (status is {status})
Access it with `ssh -i \
$HOME/.ssh/id_microstack` {username}@{ip}""".format(name=name, status=status,
Access it with `ssh -i {ssh_key} {username}@{ip}`\
""".format(name=name, status=status, ssh_key=ssh_key,
username=username, ip=ip))
gate = check_output('snapctl', 'get', 'config.network.ext-gateway')