Adds information about private key generation for instance access
- Also updated the help text in the command itself. Change-Id: Ib3d4f94ef415a3f12024d0d7c000d2de20de001b Partial-Bug: 1549410
This commit is contained in:
parent
be9306f1d4
commit
5055074db0
@ -3,14 +3,16 @@ keypair
|
|||||||
=======
|
=======
|
||||||
|
|
||||||
The badly named keypair is really the public key of an OpenSSH key pair to be
|
The badly named keypair is really the public key of an OpenSSH key pair to be
|
||||||
used for access to created servers.
|
used for access to created servers. You can also create a private key for
|
||||||
|
access to a created server by not passing any argument to the keypair create
|
||||||
|
command.
|
||||||
|
|
||||||
Compute v2
|
Compute v2
|
||||||
|
|
||||||
keypair create
|
keypair create
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Create new public key
|
Create new public or private key for server ssh access
|
||||||
|
|
||||||
.. program:: keypair create
|
.. program:: keypair create
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
@ -21,16 +23,16 @@ Create new public key
|
|||||||
|
|
||||||
.. option:: --public-key <file>
|
.. option:: --public-key <file>
|
||||||
|
|
||||||
Filename for public key to add
|
Filename for public key to add. If not used, creates a private key.
|
||||||
|
|
||||||
.. describe:: <name>
|
.. describe:: <name>
|
||||||
|
|
||||||
New public key name
|
New public or private key name
|
||||||
|
|
||||||
keypair delete
|
keypair delete
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Delete public key(s)
|
Delete public or private key(s)
|
||||||
|
|
||||||
.. program:: keypair delete
|
.. program:: keypair delete
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
@ -40,12 +42,12 @@ Delete public key(s)
|
|||||||
|
|
||||||
.. describe:: <key>
|
.. describe:: <key>
|
||||||
|
|
||||||
Public key(s) to delete (name only)
|
Name of key(s) to delete (name only)
|
||||||
|
|
||||||
keypair list
|
keypair list
|
||||||
------------
|
------------
|
||||||
|
|
||||||
List public key fingerprints
|
List key fingerprints
|
||||||
|
|
||||||
.. program:: keypair list
|
.. program:: keypair list
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
@ -55,7 +57,7 @@ List public key fingerprints
|
|||||||
keypair show
|
keypair show
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Display public key details
|
Display key details
|
||||||
|
|
||||||
.. program:: keypair show
|
.. program:: keypair show
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
@ -66,8 +68,8 @@ Display public key details
|
|||||||
|
|
||||||
.. option:: --public-key
|
.. option:: --public-key
|
||||||
|
|
||||||
Show only bare public key (name only)
|
Show only bare public key paired with the generated key
|
||||||
|
|
||||||
.. describe:: <key>
|
.. describe:: <key>
|
||||||
|
|
||||||
Public key to display (name only)
|
Public or private key to display (name only)
|
||||||
|
@ -32,19 +32,20 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class CreateKeypair(command.ShowOne):
|
class CreateKeypair(command.ShowOne):
|
||||||
"""Create new public key"""
|
"""Create new public or private key for server ssh access"""
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(CreateKeypair, self).get_parser(prog_name)
|
parser = super(CreateKeypair, self).get_parser(prog_name)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'name',
|
'name',
|
||||||
metavar='<name>',
|
metavar='<name>',
|
||||||
help=_("New public key name")
|
help=_("New public or private key name")
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--public-key',
|
'--public-key',
|
||||||
metavar='<file>',
|
metavar='<file>',
|
||||||
help=_("Filename for public key to add")
|
help=_("Filename for public key to add. If not used, "
|
||||||
|
"creates a private key.")
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ class CreateKeypair(command.ShowOne):
|
|||||||
|
|
||||||
|
|
||||||
class DeleteKeypair(command.Command):
|
class DeleteKeypair(command.Command):
|
||||||
"""Delete public key(s)"""
|
"""Delete public or private key(s)"""
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(DeleteKeypair, self).get_parser(prog_name)
|
parser = super(DeleteKeypair, self).get_parser(prog_name)
|
||||||
@ -90,7 +91,7 @@ class DeleteKeypair(command.Command):
|
|||||||
'name',
|
'name',
|
||||||
metavar='<key>',
|
metavar='<key>',
|
||||||
nargs='+',
|
nargs='+',
|
||||||
help=_("Public key(s) to delete (name only)")
|
help=_("Name of key(s) to delete (name only)")
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -104,19 +105,19 @@ class DeleteKeypair(command.Command):
|
|||||||
compute_client.keypairs.delete(data.name)
|
compute_client.keypairs.delete(data.name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result += 1
|
result += 1
|
||||||
LOG.error(_("Failed to delete public key with name "
|
LOG.error(_("Failed to delete key with name "
|
||||||
"'%(name)s': %(e)s")
|
"'%(name)s': %(e)s")
|
||||||
% {'name': n, 'e': e})
|
% {'name': n, 'e': e})
|
||||||
|
|
||||||
if result > 0:
|
if result > 0:
|
||||||
total = len(parsed_args.name)
|
total = len(parsed_args.name)
|
||||||
msg = (_("%(result)s of %(total)s public keys failed "
|
msg = (_("%(result)s of %(total)s keys failed "
|
||||||
"to delete.") % {'result': result, 'total': total})
|
"to delete.") % {'result': result, 'total': total})
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
class ListKeypair(command.Lister):
|
class ListKeypair(command.Lister):
|
||||||
"""List public key fingerprints"""
|
"""List key fingerprints"""
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
@ -133,20 +134,20 @@ class ListKeypair(command.Lister):
|
|||||||
|
|
||||||
|
|
||||||
class ShowKeypair(command.ShowOne):
|
class ShowKeypair(command.ShowOne):
|
||||||
"""Display public key details"""
|
"""Display key details"""
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(ShowKeypair, self).get_parser(prog_name)
|
parser = super(ShowKeypair, self).get_parser(prog_name)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'name',
|
'name',
|
||||||
metavar='<key>',
|
metavar='<key>',
|
||||||
help=_("Public key to display (name only)")
|
help=_("Public or private key to display (name only)")
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--public-key',
|
'--public-key',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
help=_("Show only bare public key (name only)")
|
help=_("Show only bare public key paired with the generated key")
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -179,8 +179,7 @@ class TestKeypairDelete(TestKeypair):
|
|||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
self.fail('CommandError should be raised.')
|
self.fail('CommandError should be raised.')
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
self.assertEqual('1 of 2 public keys failed to delete.',
|
self.assertEqual('1 of 2 keys failed to delete.', str(e))
|
||||||
str(e))
|
|
||||||
|
|
||||||
find_mock.assert_any_call(
|
find_mock.assert_any_call(
|
||||||
self.keypairs_mock, self.keypairs[0].name)
|
self.keypairs_mock, self.keypairs[0].name)
|
||||||
|
Loading…
Reference in New Issue
Block a user