in ebcli/operations/sshops.py [0:0]
def prepare_for_ssh(env_name, instance, keep_open, force, setup, number,
keyname=None, no_keypair_error_message=None,
custom_ssh=None, command=None, timeout=None):
if setup:
setup_ssh(env_name, keyname, timeout=timeout)
return
if instance and number:
raise InvalidOptionsError(strings['ssh.instanceandnumber'])
if not instance:
instances = commonops.get_instance_ids(env_name)
if number is not None:
if number > len(instances) or number < 1:
raise InvalidOptionsError(
'Invalid index number (' + str(number) +
') for environment with ' + str(len(instances)) +
' instances')
else:
instance = instances[number - 1]
elif len(instances) == 1:
instance = instances[0]
elif len(instances) == 0:
raise InvalidOptionsError(strings['ssh.noinstance'])
else:
io.echo()
io.echo('Select an instance to ssh into')
instance = utils.prompt_for_item_in_list(instances)
try:
ssh_into_instance(
instance,
keep_open=keep_open,
force_open=force,
custom_ssh=custom_ssh,
command=command
)
except NoKeypairError:
if not no_keypair_error_message:
no_keypair_error_message = prompts['ssh.nokey']
io.log_error(no_keypair_error_message)