Browse Source

Fixed launch output.

Fixed backticks so that they actually wrap the whole command.

Added code to gamely make a guess about the username of the launched
instance and the location of the ssh key. Falls back on placeholders
if it can't.

Closes-bug 1850586

Change-Id: I980ee8617dfc4bf7c60846052d66ff18cf8aa8e9
changes/64/696764/1
Pete Vander Giessen 3 years ago
parent
commit
d169bef119
  1. 29
      tools/launch/launch/main.py

29
tools/launch/launch/main.py

@ -146,23 +146,28 @@ 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():
username = 'fedora'
if 'ubuntu' in args.flavor.lower():
username = 'ubuntu'
if 'cirros' in args.flavor.lower():
username = 'cirros'
if 'fedora' in args.image.lower():
username = 'fedora'
if 'ubuntu' in args.image.lower():
username = 'ubuntu'
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,
username=username, ip=ip))
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')
port = check_output('snapctl', 'get', 'config.network.ports.dashboard')

Loading…
Cancel
Save