Add utility method for generating passwords for the undercloud
Change-Id: I0303d02ec927ea06dae2f2b6e295b7a0258a2494
This commit is contained in:
parent
2d9a945e8a
commit
db239f87e5
29
rdomanager_oscplugin/tests/test_util.py
Normal file
29
rdomanager_oscplugin/tests/test_util.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from rdomanager_oscplugin.v1 import util
|
||||
|
||||
|
||||
class TestPasswordsUtil(TestCase):
|
||||
|
||||
def test_generate_passwords(self):
|
||||
|
||||
passwords = util.generate_overcloud_passwords()
|
||||
passwords2 = util.generate_overcloud_passwords()
|
||||
|
||||
self.assertEqual(len(passwords), 13)
|
||||
self.assertNotEqual(passwords, passwords2)
|
44
rdomanager_oscplugin/v1/util.py
Normal file
44
rdomanager_oscplugin/v1/util.py
Normal file
@ -0,0 +1,44 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import hashlib
|
||||
import six
|
||||
import uuid
|
||||
|
||||
|
||||
def _generate_password():
|
||||
uuid_str = six.text_type(uuid.uuid1()).encode("UTF-8")
|
||||
return hashlib.sha1(uuid_str).hexdigest()
|
||||
|
||||
|
||||
def generate_overcloud_passwords():
|
||||
|
||||
passwords = (
|
||||
"OVERCLOUD_ADMIN_PASSWORD",
|
||||
"OVERCLOUD_ADMIN_TOKEN",
|
||||
"OVERCLOUD_CEILOMETER_PASSWORD",
|
||||
"OVERCLOUD_CEILOMETER_SECRET",
|
||||
"OVERCLOUD_CINDER_PASSWORD",
|
||||
"OVERCLOUD_DEMO_PASSWORD",
|
||||
"OVERCLOUD_GLANCE_PASSWORD",
|
||||
"OVERCLOUD_HEAT_PASSWORD",
|
||||
"OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD",
|
||||
"OVERCLOUD_NEUTRON_PASSWORD",
|
||||
"OVERCLOUD_NOVA_PASSWORD",
|
||||
"OVERCLOUD_SWIFT_HASH",
|
||||
"OVERCLOUD_SWIFT_PASSWORD",
|
||||
)
|
||||
|
||||
return dict((password, _generate_password()) for password in passwords)
|
@ -10,6 +10,7 @@ os-cloud-config
|
||||
python-heatclient>=0.3.0
|
||||
python-ironicclient>=0.4.1
|
||||
python-openstackclient>=1.0.0
|
||||
six>=1.9.0
|
||||
|
||||
# The ironic-discoverd OSC integration isn't yet on PyPI
|
||||
-e git://github.com/stackforge/ironic-discoverd.git#egg=ironic_discoverd
|
||||
|
Loading…
Reference in New Issue
Block a user