diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-04-04 09:50:01 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-04-04 09:50:02 +0000 |
| commit | ac228c370bca9179e1116ad31e5863cc3675f2f1 (patch) | |
| tree | d6211391cbbf249dafa1b20c6616bf88b150bbec /kolla/cmd | |
| parent | c7e261c8c2eb6c4bd4474375ca77e07f24a7822b (diff) | |
| parent | 42420830f65c0a76ba8e7e1b6a8d2974dabb9cfa (diff) | |
| download | kolla-ac228c370bca9179e1116ad31e5863cc3675f2f1.tar.gz kolla-ac228c370bca9179e1116ad31e5863cc3675f2f1.zip | |
Merge "Implement nova-ssh container"
Diffstat (limited to 'kolla/cmd')
| -rwxr-xr-x | kolla/cmd/genpwd.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kolla/cmd/genpwd.py b/kolla/cmd/genpwd.py index 728dd458b..70dbc0357 100755 --- a/kolla/cmd/genpwd.py +++ b/kolla/cmd/genpwd.py @@ -12,16 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import random import string import uuid import yaml +from Crypto.PublicKey import RSA + + +def generate_RSA(bits=2048): + new_key = RSA.generate(bits, os.urandom) + private_key = new_key.exportKey("PEM") + public_key = new_key.publickey().exportKey("OpenSSH") + return private_key, public_key + def main(): # These keys should be random uuids uuid_keys = ['ceph_cluster_fsid', 'rbd_secret_uuid'] + # SSH key pair + ssh_keys = ['nova_ssh_key'] + # If these keys are None, leave them as None blank_keys = ['docker_registry_password'] @@ -32,6 +45,16 @@ def main(): passwords = yaml.load(f.read()) for k, v in passwords.items(): + if (k in ssh_keys and + (v is None + or v.get('public_key') is None + and v.get('private_key') is None)): + private_key, public_key = generate_RSA() + passwords[k] = { + 'private_key': private_key, + 'public_key': public_key + } + continue if v is None: if k in blank_keys and v is None: continue |
