keypair-add botches key from stdin

Bug #1333476 reported by Mike Spreitzer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Wishlist
Natsuki Maruyama

Bug Description

`cat X | nova keypair-add K` produces a different result from `nova keypair-add --pub-key X K`.

The latter takes the contents of X as the public key; the former does not.

For example:

ubuntu@mjs-dstk-623b:~$ cat bar.pub | nova keypair-add bar_stdin
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA7aiDpcq1JOLBS6l471eFAvBe7DcJqKaK5uM4+73DG+99aihF
RxY8kwYQfqS3MPdlAfVhNNBI4ehLpgDsAVfqm5QOZSZChkZPnJpjifOqszBynL99
txmwfDqFJnOvzLT1eY1Q/9O1GXHquolAIruB4T9N/6VW8yWnzK6fJ733uaJCnvIp
rgqem8Hjc8g+Yn6o3HnXkeykd9ayElB+d+79yd82LysXtZlmb+QOKLn8RHTWIgyT
qIqCp+qlxRQtqc04DT/qyhEJjC50il8jAi4DEYOWrSJSlQGTKsj/z9giVXyTp/Dx
Ops/zGpz6dAH8TBFldnr4XrEPm3mTEcXBEOfZwIDAQABAoIBAQCfZ+ZVb++sfAPW
8idRskxfOkcQ/aGW445La6EvCYsy06I1cCl3kuyyWOD7cRQG3gl8FNBMkmAwVpVX
FUs3Y3bTP62gHteEJOkFS3D0eOHIKvjVNoPmKm78BGyG7BXAoqf8DdOEpMXV+VjO
IX1JTqfBI6r3jDkUAe/ZFE9gYsUkVuybXhwZzksPJRRvoDU+76/Zqq9dEK8nUuqs
+Oq4bHOGZPdOLtGsOLfe4tgJ5vDCu4CNkmXjxcDwHQmId53n/xX5magsGC3YCyTg
iTy05A3XlO7EEPPEuhlrIoHToRfgnRFJRsc5DiY8jzqdS1MEYH4N+eafCszVdQfr
u8xIVWmRAoGBAPlrg9UK4k8kC4XLgcZKNm5+gir7Jceqx3fmK9qV1m+6RmHatdKH
zu8CHXpFiLstVwk+I+BjvpQoUK5yO4GwINNN3JPPsfEiPlIb9QLfrE+Hjtis4FBF
Qy2vwBTl+CK03J2OUc79wDJQffEhlgYMQbQtYQ2KK0mFbQz/IbMSqrYtAoGBAPPt
kLGbp3j7hq751r3MYbhBvhVBM9XHDIljOffvbOr9wwetTeoK/GYTjNXymKggNijO
Uhb+VNf5FbYE4hGx601AKizctwXGzDJX+BzccU8dzf0uyoqxmFHn2JYtZtgk6VRT
glyOwLXPMeBd2bo9nmJcdr7FWPwFFeBMCor5Q1xjAoGBAKtWLC3BWE09WZ0De5aX
jGTDCvAzrnRG4NeAikeR/sipkYfPEnAZUxHkxhMkiRTrxIpY4ZRXcKeeOi5b0nz4
XNRK/GedmYMoHt+QzPK4bEoFuR8nQsBhlBBiVvUENTzCOXsSNSiYL9tgZ+OpSsHE
0a3QLod6jtnmik8PRDsba6HRAoGACDMVKRM9ZvC1j04wrMKhCkuTcy1065u8TSX7
vdzbgW60Tp7BvrtNzrSbiFmWThh/GZIN6l30RipGU48IdmXPrhIZGNb2hAgxtwOE
AJxcZrduxDL9dfoQT7iGbE3sZhmfikkgWbImwjXLzGn7Nqp5l37aMwF5Q0d8e8Sy
mgdU/1cCgYEA6e+DGrKIZlTXij1pdCTgC/A6sQgrAu4yY/7duUdCquAtX4L5cjza
dERodDaWj584RlHSot5GRP3RIPRfS5TGozH3nkPSyQ3+6vJC8Af9uAj+TcVnlK+n
4iEC5PnZnfXG79rPu0YpdFTXPM/IzQZOFaMbwQ43+qjPcLX2pFdoyzA=
-----END RSA PRIVATE KEY-----

ubuntu@mjs-dstk-623b:~$ nova keypair-add --pub-key bar.pub bar_file

ubuntu@mjs-dstk-623b:~$ nova keypair-list
+-----------+-------------------------------------------------+
| Name | Fingerprint |
+-----------+-------------------------------------------------+
...
| bar_stdin | 51:b4:0b:bc:6d:5d:3f:7e:bc:4c:e9:5c:03:fd:c2:4d |
| bar_file | 93:85:70:f2:a5:40:ae:30:da:4a:1e:01:fd:80:79:24 |
+-----------+-------------------------------------------------+
ubuntu@mjs-dstk-623b:~$

This is with a DevStack install about an hour ago. The following shows exact identifiers.

ubuntu@mjs-dstk-623b:~$ cd /opt/stack/nova

ubuntu@mjs-dstk-623b:/opt/stack/nova$ git branch -v
* master 80b827d Merge "Drop support for conductor 1.x rpc interface"

ubuntu@mjs-dstk-623b:/opt/stack/nova$ cd ../keystone/

ubuntu@mjs-dstk-623b:/opt/stack/keystone$ git branch -v
* master db0519d Merge "Make gen_pki.sh & debug_helper.sh bash8 compliant"

Revision history for this message
Joe Gordon (jogo) wrote :

python-novaclient doesn't support reading the keypair from stdin. I see now reason why novaclient shouldn't support this model

Changed in nova:
status: New → Invalid
Changed in python-novaclient:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Mike Spreitzer (mike-spreitzer) wrote :

Those two commands used to produce the same result. They have diverged only recently.

Sorry about the wrong project identification; will remove the wrong one.

no longer affects: nova
Revision history for this message
Joe Gordon (jogo) wrote :

MIke, a cursory look at the novaclient code base didn't find any signs that this was supported, so if you find the offending patch, etc, or can point to a version of the client where this worked that would be great.

Until then I am leaving this as a wishlist bug, one that would be nice to fix none the less.

Changed in python-novaclient:
assignee: nobody → Natsuki Maruyama (gashiforce)
Revision history for this message
Natsuki Maruyama (gashiforce) wrote :

I assume the following 3 patterns:

    A. Without `--pub-key` option, generate the keypair by the nova, and return the private key.
    B. With `--pub-key` option and filename, register the public key from a file.
    C. With `--pub-key` option and `-`, register the public key from stdin. (new-feature)

For example:

    $ nova keypair-add bar_new # A.
    $ nova keypair-add --pub-key bar.pub bar_file # B.
    $ cat bar.pub | nova keypair-add --pub-key - bar_stdin # C. new-feature

This implementation is standard in the python.

    - https://docs.python.org/2/library/argparse.html#filetype-objects

Are you satisfied with this plan?

Revision history for this message
Natsuki Maruyama (gashiforce) wrote :

Add stdin support by this plan.

Review: https://review.openstack.org/137946/

Changed in python-novaclient:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/137946
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=45000677ec6c6c3e9d22aa2f1650a3458a67883a
Submitter: Jenkins
Branch: master

commit 45000677ec6c6c3e9d22aa2f1650a3458a67883a
Author: Natsuki Maruyama <email address hidden>
Date: Sun Nov 30 20:21:03 2014 +0900

    Add support for keypair-add command reading public key from stdin

    If given filename is `-` for `--pub-key` option, reads public key
    from stdin.

      $ cat id_rsa.pub | nova keypair-add --pub-key - keyname

    Change-Id: Ib6dfe5a7b08d588868a923defb9ddd15fc28e01f
    Closes-Bug: #1333476

Changed in python-novaclient:
status: In Progress → Fix Committed
Revision history for this message
Shuichiro MAKIGAKI (shuichiro-makigaki) wrote :

Thank you for your contribution. Congratulations!

Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.21.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.