def _create(self, name, stack_id, username=None, ssh_keys=None,
                user_scripts=None, node_groups=None, connectors=None,
                wait=False):
        """
        CLI-only; cluster create command
        """
        if ssh_keys is None:
            ssh_keys = [DEFAULT_SSH_KEY]

        try:
            return self.create(name, stack_id, username, ssh_keys,
                               user_scripts, node_groups, connectors, wait)
        except error.RequestError as exc:
            if not (ssh_keys == [DEFAULT_SSH_KEY] and
                    'Cannot find requested ssh_keys' in str(exc)):
                raise

            six.print_('SSH key does not exist; creating...')

            # Create the SSH key for the user and then attempt to create the
            # cluster again
            with open(expand('$HOME/.ssh/id_rsa.pub')) as f:
                self._client.credentials.create_ssh_key(
                    DEFAULT_SSH_KEY,
                    f.read().strip())

            return self.create(name, stack_id, username, ssh_keys,
                               user_scripts, node_groups, connectors, wait)
    def _create_default_ssh_credential(self):
        if not confirm('You have not uploaded any SSH key credentials; do '
                       'you want to upload {0} now?'.format(
                           DEFAULT_SSH_PUBKEY)):
            sys.exit(1)

        try:
            with open(expand(DEFAULT_SSH_PUBKEY)) as f:
                six.print_('SSH key does not exist; creating...')
                self._client.credentials.create_ssh_key(
                    DEFAULT_SSH_KEY,
                    f.read().strip())
        except IOError:
            six.print_('No SSH keypair found; to generate a keypair, run '
                       '`ssh-keygen`')
            sys.exit(1)

        return DEFAULT_SSH_KEY
    def _create_default_ssh_credential(self):
        if not confirm(
                'You have not uploaded any SSH key credentials; do '
                'you want to upload {0} now?'.format(DEFAULT_SSH_PUBKEY)):
            sys.exit(1)

        try:
            with open(expand(DEFAULT_SSH_PUBKEY)) as f:
                six.print_('SSH key does not exist; creating...')
                self._client.credentials.create_ssh_key(
                    DEFAULT_SSH_KEY,
                    f.read().strip())
        except IOError:
            six.print_('No SSH keypair found; to generate a keypair, run '
                       '`ssh-keygen`')
            sys.exit(1)

        return DEFAULT_SSH_KEY