Skip to content

Commit 5055074

Browse files
agentleciscostevemar
authored andcommitted
Adds information about private key generation for instance access
- Also updated the help text in the command itself. Change-Id: Ib3d4f94ef415a3f12024d0d7c000d2de20de001b Partial-Bug: 1549410
1 parent be9306f commit 5055074

3 files changed

Lines changed: 25 additions & 23 deletions

File tree

doc/source/command-objects/keypair.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ keypair
33
=======
44

55
The badly named keypair is really the public key of an OpenSSH key pair to be
6-
used for access to created servers.
6+
used for access to created servers. You can also create a private key for
7+
access to a created server by not passing any argument to the keypair create
8+
command.
79

810
Compute v2
911

1012
keypair create
1113
--------------
1214

13-
Create new public key
15+
Create new public or private key for server ssh access
1416

1517
.. program:: keypair create
1618
.. code:: bash
@@ -21,16 +23,16 @@ Create new public key
2123
2224
.. option:: --public-key <file>
2325

24-
Filename for public key to add
26+
Filename for public key to add. If not used, creates a private key.
2527

2628
.. describe:: <name>
2729

28-
New public key name
30+
New public or private key name
2931

3032
keypair delete
3133
--------------
3234

33-
Delete public key(s)
35+
Delete public or private key(s)
3436

3537
.. program:: keypair delete
3638
.. code:: bash
@@ -40,12 +42,12 @@ Delete public key(s)
4042
4143
.. describe:: <key>
4244

43-
Public key(s) to delete (name only)
45+
Name of key(s) to delete (name only)
4446

4547
keypair list
4648
------------
4749

48-
List public key fingerprints
50+
List key fingerprints
4951

5052
.. program:: keypair list
5153
.. code:: bash
@@ -55,7 +57,7 @@ List public key fingerprints
5557
keypair show
5658
------------
5759

58-
Display public key details
60+
Display key details
5961

6062
.. program:: keypair show
6163
.. code:: bash
@@ -66,8 +68,8 @@ Display public key details
6668
6769
.. option:: --public-key
6870

69-
Show only bare public key (name only)
71+
Show only bare public key paired with the generated key
7072

7173
.. describe:: <key>
7274

73-
Public key to display (name only)
75+
Public or private key to display (name only)

openstackclient/compute/v2/keypair.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,20 @@
3232

3333

3434
class CreateKeypair(command.ShowOne):
35-
"""Create new public key"""
35+
"""Create new public or private key for server ssh access"""
3636

3737
def get_parser(self, prog_name):
3838
parser = super(CreateKeypair, self).get_parser(prog_name)
3939
parser.add_argument(
4040
'name',
4141
metavar='<name>',
42-
help=_("New public key name")
42+
help=_("New public or private key name")
4343
)
4444
parser.add_argument(
4545
'--public-key',
4646
metavar='<file>',
47-
help=_("Filename for public key to add")
47+
help=_("Filename for public key to add. If not used, "
48+
"creates a private key.")
4849
)
4950
return parser
5051

@@ -82,15 +83,15 @@ def take_action(self, parsed_args):
8283

8384

8485
class DeleteKeypair(command.Command):
85-
"""Delete public key(s)"""
86+
"""Delete public or private key(s)"""
8687

8788
def get_parser(self, prog_name):
8889
parser = super(DeleteKeypair, self).get_parser(prog_name)
8990
parser.add_argument(
9091
'name',
9192
metavar='<key>',
9293
nargs='+',
93-
help=_("Public key(s) to delete (name only)")
94+
help=_("Name of key(s) to delete (name only)")
9495
)
9596
return parser
9697

@@ -104,19 +105,19 @@ def take_action(self, parsed_args):
104105
compute_client.keypairs.delete(data.name)
105106
except Exception as e:
106107
result += 1
107-
LOG.error(_("Failed to delete public key with name "
108+
LOG.error(_("Failed to delete key with name "
108109
"'%(name)s': %(e)s")
109110
% {'name': n, 'e': e})
110111

111112
if result > 0:
112113
total = len(parsed_args.name)
113-
msg = (_("%(result)s of %(total)s public keys failed "
114+
msg = (_("%(result)s of %(total)s keys failed "
114115
"to delete.") % {'result': result, 'total': total})
115116
raise exceptions.CommandError(msg)
116117

117118

118119
class ListKeypair(command.Lister):
119-
"""List public key fingerprints"""
120+
"""List key fingerprints"""
120121

121122
def take_action(self, parsed_args):
122123
compute_client = self.app.client_manager.compute
@@ -133,20 +134,20 @@ def take_action(self, parsed_args):
133134

134135

135136
class ShowKeypair(command.ShowOne):
136-
"""Display public key details"""
137+
"""Display key details"""
137138

138139
def get_parser(self, prog_name):
139140
parser = super(ShowKeypair, self).get_parser(prog_name)
140141
parser.add_argument(
141142
'name',
142143
metavar='<key>',
143-
help=_("Public key to display (name only)")
144+
help=_("Public or private key to display (name only)")
144145
)
145146
parser.add_argument(
146147
'--public-key',
147148
action='store_true',
148149
default=False,
149-
help=_("Show only bare public key (name only)")
150+
help=_("Show only bare public key paired with the generated key")
150151
)
151152
return parser
152153

openstackclient/tests/unit/compute/v2/test_keypair.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ def test_delete_multiple_keypairs_with_exception(self):
179179
self.cmd.take_action(parsed_args)
180180
self.fail('CommandError should be raised.')
181181
except exceptions.CommandError as e:
182-
self.assertEqual('1 of 2 public keys failed to delete.',
183-
str(e))
182+
self.assertEqual('1 of 2 keys failed to delete.', str(e))
184183

185184
find_mock.assert_any_call(
186185
self.keypairs_mock, self.keypairs[0].name)

0 commit comments

Comments
 (0)