def test_generate_passwords_update(self): mock_open = mock.mock_open() with mock.patch('six.moves.builtins.open', mock_open): with self.assertRaises(exceptions.PasswordFileNotFound): utils.generate_overcloud_passwords()
def test_load_passwords(self, generate_password_mock, isfile_mock): PASSWORDS = [ 'OVERCLOUD_ADMIN_PASSWORD=PASSWORD\n', 'OVERCLOUD_ADMIN_TOKEN=PASSWORD\n', 'OVERCLOUD_AODH_PASSWORD=PASSWORD\n', 'OVERCLOUD_CEILOMETER_PASSWORD=PASSWORD\n', 'OVERCLOUD_CEILOMETER_SECRET=PASSWORD\n', 'OVERCLOUD_CINDER_PASSWORD=PASSWORD\n', 'OVERCLOUD_DEMO_PASSWORD=PASSWORD\n', 'OVERCLOUD_GLANCE_PASSWORD=PASSWORD\n', 'OVERCLOUD_HAPROXY_STATS_PASSWORD=PASSWORD\n', 'OVERCLOUD_HEAT_PASSWORD=PASSWORD\n', 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD=PASSWORD\n', 'OVERCLOUD_NEUTRON_PASSWORD=PASSWORD\n', 'OVERCLOUD_NOVA_PASSWORD=PASSWORD\n', 'OVERCLOUD_RABBITMQ_PASSWORD=PASSWORD\n', 'OVERCLOUD_REDIS_PASSWORD=PASSWORD\n', 'OVERCLOUD_SAHARA_PASSWORD=PASSWORD\n', 'OVERCLOUD_SWIFT_HASH=PASSWORD\n', 'OVERCLOUD_SWIFT_PASSWORD=PASSWORD\n', 'NEUTRON_METADATA_PROXY_SHARED_SECRET=PASSWORD\n', ] mock_open = mock.mock_open(read_data=''.join(PASSWORDS)) mock_open.return_value.__iter__ = lambda self: self mock_open.return_value.__next__ = lambda self: self.readline() with mock.patch('six.moves.builtins.open', mock_open): passwords = utils.generate_overcloud_passwords() generate_password_mock.assert_not_called() self.assertEqual(len(passwords), len(PASSWORDS)) for name in utils._PASSWORD_NAMES: self.assertEqual('PASSWORD', passwords[name])
def test_generate_passwords(self, generate_password_mock, isfile_mock): mock_open = mock.mock_open() with mock.patch('six.moves.builtins.open', mock_open): passwords = utils.generate_overcloud_passwords( create_password_file=True) mock_calls = [ mock.call('NEUTRON_METADATA_PROXY_SHARED_SECRET=PASSWORD\n'), mock.call('OVERCLOUD_ADMIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_ADMIN_TOKEN=PASSWORD\n'), mock.call('OVERCLOUD_AODH_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_SECRET=PASSWORD\n'), mock.call('OVERCLOUD_CINDER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_DEMO_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_GLANCE_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HAPROXY_STATS_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NEUTRON_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NOVA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_RABBITMQ_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_REDIS_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_SAHARA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_HASH=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_PASSWORD=PASSWORD\n'), ] self.assertEqual(sorted(mock_open().write.mock_calls), mock_calls) self.assertEqual(generate_password_mock.call_count, len(mock_calls)) self.assertEqual(len(passwords), len(mock_calls))
def test_load_passwords(self, generate_password_mock, isfile_mock): PASSWORDS = [ 'OVERCLOUD_ADMIN_PASSWORD=PASSWORD\n', 'OVERCLOUD_ADMIN_TOKEN=PASSWORD\n', 'OVERCLOUD_CEILOMETER_PASSWORD=PASSWORD\n', 'OVERCLOUD_CEILOMETER_SECRET=PASSWORD\n', 'OVERCLOUD_CINDER_PASSWORD=PASSWORD\n', 'OVERCLOUD_DEMO_PASSWORD=PASSWORD\n', 'OVERCLOUD_GLANCE_PASSWORD=PASSWORD\n', 'OVERCLOUD_HEAT_PASSWORD=PASSWORD\n', 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD=PASSWORD\n', 'OVERCLOUD_NEUTRON_PASSWORD=PASSWORD\n', 'OVERCLOUD_NOVA_PASSWORD=PASSWORD\n', 'OVERCLOUD_SWIFT_HASH=PASSWORD\n', 'OVERCLOUD_SWIFT_PASSWORD=PASSWORD\n', ] mock_open = mock.mock_open(read_data=''.join(PASSWORDS)) mock_open.return_value.__iter__ = lambda self: self mock_open.return_value.__next__ = lambda self: self.readline() with mock.patch('six.moves.builtins.open', mock_open): passwords = utils.generate_overcloud_passwords() mock_open().write.assert_not_called() generate_password_mock.assert_not_called() self.assertEqual(len(passwords), 13)
def test_generate_passwords(self, generate_password_mock, isfile_mock): mock_open = mock.mock_open() with mock.patch('six.moves.builtins.open', mock_open): passwords = utils.generate_overcloud_passwords() self.assertEqual(sorted(mock_open().write.mock_calls), [ mock.call('OVERCLOUD_ADMIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_ADMIN_TOKEN=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_SECRET=PASSWORD\n'), mock.call('OVERCLOUD_CINDER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_DEMO_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_GLANCE_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NEUTRON_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NOVA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_HASH=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_PASSWORD=PASSWORD\n'), ]) self.assertEqual(generate_password_mock.call_count, 13) self.assertEqual(len(passwords), 13)
def set_overcloud_passwords(self, parameters, parsed_args): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth", "undercloud_ceilometer_snmpd_password") self.passwords = passwords = utils.generate_overcloud_passwords() ceilometer_pass = passwords['OVERCLOUD_CEILOMETER_PASSWORD'] ceilometer_secret = passwords['OVERCLOUD_CEILOMETER_SECRET'] parameters['AdminPassword'] = passwords['OVERCLOUD_ADMIN_PASSWORD'] parameters['AdminToken'] = passwords['OVERCLOUD_ADMIN_TOKEN'] parameters['CeilometerPassword'] = ceilometer_pass parameters['CeilometerMeteringSecret'] = ceilometer_secret parameters['CinderPassword'] = passwords[ 'OVERCLOUD_CINDER_PASSWORD'] parameters['GlancePassword'] = passwords[ 'OVERCLOUD_GLANCE_PASSWORD'] parameters['HeatPassword'] = passwords['OVERCLOUD_HEAT_PASSWORD'] parameters['HeatStackDomainAdminPassword'] = passwords[ 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD'] parameters['NeutronPassword'] = passwords[ 'OVERCLOUD_NEUTRON_PASSWORD'] parameters['NovaPassword'] = passwords['OVERCLOUD_NOVA_PASSWORD'] parameters['SwiftHashSuffix'] = passwords['OVERCLOUD_SWIFT_HASH'] parameters['SwiftPassword'] = passwords['OVERCLOUD_SWIFT_PASSWORD'] parameters['SnmpdReadonlyUserPassword'] = ( undercloud_ceilometer_snmpd_password)
def set_overcloud_passwords(self, parameters, parsed_args): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth", "undercloud_ceilometer_snmpd_password") self.passwords = passwords = utils.generate_overcloud_passwords() ceilometer_pass = passwords['OVERCLOUD_CEILOMETER_PASSWORD'] ceilometer_secret = passwords['OVERCLOUD_CEILOMETER_SECRET'] parameters['AdminPassword'] = passwords['OVERCLOUD_ADMIN_PASSWORD'] parameters['AdminToken'] = passwords['OVERCLOUD_ADMIN_TOKEN'] parameters['CeilometerPassword'] = ceilometer_pass parameters['CeilometerMeteringSecret'] = ceilometer_secret parameters['CinderPassword'] = passwords['OVERCLOUD_CINDER_PASSWORD'] parameters['GlancePassword'] = passwords['OVERCLOUD_GLANCE_PASSWORD'] parameters['HAProxyStatsPassword'] = passwords[ 'OVERCLOUD_HAPROXY_STATS_PASSWORD'] parameters['HeatPassword'] = passwords['OVERCLOUD_HEAT_PASSWORD'] parameters['HeatStackDomainAdminPassword'] = passwords[ 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD'] parameters['NeutronPassword'] = passwords['OVERCLOUD_NEUTRON_PASSWORD'] parameters['NovaPassword'] = passwords['OVERCLOUD_NOVA_PASSWORD'] parameters['RabbitPassword'] = passwords['OVERCLOUD_RABBITMQ_PASSWORD'] parameters['RedisPassword'] = passwords['OVERCLOUD_REDIS_PASSWORD'] parameters['SaharaPassword'] = passwords['OVERCLOUD_SAHARA_PASSWORD'] parameters['SwiftHashSuffix'] = passwords['OVERCLOUD_SWIFT_HASH'] parameters['SwiftPassword'] = passwords['OVERCLOUD_SWIFT_PASSWORD'] parameters['SnmpdReadonlyUserPassword'] = ( undercloud_ceilometer_snmpd_password) parameters['NeutronMetadataProxySharedSecret'] = ( passwords['NEUTRON_METADATA_PROXY_SHARED_SECRET'])
def set_overcloud_passwords(self, stack_is_new, parameters): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth", "undercloud_ceilometer_snmpd_password") if not undercloud_ceilometer_snmpd_password: self.log.warning("Undercloud ceilometer SNMPd password missing!") passwords = utils.generate_overcloud_passwords( create_password_file=stack_is_new) ceilometer_pass = passwords['OVERCLOUD_CEILOMETER_PASSWORD'] ceilometer_secret = passwords['OVERCLOUD_CEILOMETER_SECRET'] parameters['AdminPassword'] = passwords['OVERCLOUD_ADMIN_PASSWORD'] parameters['AdminToken'] = passwords['OVERCLOUD_ADMIN_TOKEN'] parameters['AodhPassword'] = passwords['OVERCLOUD_AODH_PASSWORD'] parameters['BarbicanPassword'] = ( passwords['OVERCLOUD_BARBICAN_PASSWORD']) parameters['CeilometerPassword'] = ceilometer_pass parameters['CeilometerMeteringSecret'] = ceilometer_secret parameters['CinderPassword'] = passwords[ 'OVERCLOUD_CINDER_PASSWORD'] parameters['GlancePassword'] = passwords[ 'OVERCLOUD_GLANCE_PASSWORD'] parameters['GnocchiPassword'] = passwords['OVERCLOUD_GNOCCHI_PASSWORD'] parameters['HAProxyStatsPassword'] = passwords[ 'OVERCLOUD_HAPROXY_STATS_PASSWORD'] parameters['HeatPassword'] = passwords['OVERCLOUD_HEAT_PASSWORD'] parameters['HeatStackDomainAdminPassword'] = passwords[ 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD'] parameters['IronicPassword'] = passwords['OVERCLOUD_IRONIC_PASSWORD'] parameters['MistralPassword'] = passwords['OVERCLOUD_MISTRAL_PASSWORD'] parameters['MysqlClustercheckPassword'] = passwords[ 'OVERCLOUD_MYSQL_CLUSTERCHECK_PASSWORD'] parameters['NeutronPassword'] = passwords[ 'OVERCLOUD_NEUTRON_PASSWORD'] parameters['NovaPassword'] = passwords['OVERCLOUD_NOVA_PASSWORD'] parameters['RabbitPassword'] = passwords['OVERCLOUD_RABBITMQ_PASSWORD'] parameters['RedisPassword'] = passwords['OVERCLOUD_REDIS_PASSWORD'] parameters['SaharaPassword'] = ( passwords['OVERCLOUD_SAHARA_PASSWORD']) parameters['SwiftHashSuffix'] = passwords['OVERCLOUD_SWIFT_HASH'] parameters['SwiftPassword'] = passwords['OVERCLOUD_SWIFT_PASSWORD'] parameters['SnmpdReadonlyUserPassword'] = ( undercloud_ceilometer_snmpd_password) parameters['TrovePassword'] = ( passwords['OVERCLOUD_TROVE_PASSWORD']) parameters['ZaqarPassword'] = passwords['OVERCLOUD_ZAQAR_PASSWORD'] parameters['ManilaPassword'] = passwords['OVERCLOUD_MANILA_PASSWORD'] parameters['NeutronMetadataProxySharedSecret'] = ( passwords['NEUTRON_METADATA_PROXY_SHARED_SECRET']) parameters['CephMonKey'] = passwords['OVERCLOUD_CEPH_MON_KEY'] parameters['CephAdminKey'] = passwords['OVERCLOUD_CEPH_ADMIN_KEY'] parameters['CephClientKey'] = passwords['OVERCLOUD_CEPH_CLIENT_KEY'] parameters['CephRgwKey'] = passwords['OVERCLOUD_CEPH_RGW_KEY']
def set_overcloud_passwords(self, stack_is_new, parameters): """Add passwords to the parameters dictionary :param parameters: A dictionary for the passwords to be added to :type parameters: dict """ undercloud_ceilometer_snmpd_password = utils.get_config_value( "auth", "undercloud_ceilometer_snmpd_password") if not undercloud_ceilometer_snmpd_password: self.log.warning("Undercloud ceilometer SNMPd password missing!") passwords = utils.generate_overcloud_passwords( create_password_file=stack_is_new) ceilometer_pass = passwords['OVERCLOUD_CEILOMETER_PASSWORD'] ceilometer_secret = passwords['OVERCLOUD_CEILOMETER_SECRET'] parameters['AdminPassword'] = passwords['OVERCLOUD_ADMIN_PASSWORD'] parameters['AdminToken'] = passwords['OVERCLOUD_ADMIN_TOKEN'] parameters['AodhPassword'] = passwords['OVERCLOUD_AODH_PASSWORD'] parameters['CeilometerPassword'] = ceilometer_pass parameters['CeilometerMeteringSecret'] = ceilometer_secret parameters['CinderPassword'] = passwords[ 'OVERCLOUD_CINDER_PASSWORD'] parameters['GlancePassword'] = passwords[ 'OVERCLOUD_GLANCE_PASSWORD'] parameters['GnocchiPassword'] = passwords['OVERCLOUD_GNOCCHI_PASSWORD'] parameters['HAProxyStatsPassword'] = passwords[ 'OVERCLOUD_HAPROXY_STATS_PASSWORD'] parameters['HeatPassword'] = passwords['OVERCLOUD_HEAT_PASSWORD'] parameters['HeatStackDomainAdminPassword'] = passwords[ 'OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD'] parameters['IronicPassword'] = passwords['OVERCLOUD_IRONIC_PASSWORD'] parameters['MysqlClustercheckPassword'] = passwords[ 'OVERCLOUD_MYSQL_CLUSTERCHECK_PASSWORD'] parameters['NeutronPassword'] = passwords[ 'OVERCLOUD_NEUTRON_PASSWORD'] parameters['NovaPassword'] = passwords['OVERCLOUD_NOVA_PASSWORD'] parameters['RabbitPassword'] = passwords['OVERCLOUD_RABBITMQ_PASSWORD'] parameters['RedisPassword'] = passwords['OVERCLOUD_REDIS_PASSWORD'] parameters['SaharaPassword'] = ( passwords['OVERCLOUD_SAHARA_PASSWORD']) parameters['SwiftHashSuffix'] = passwords['OVERCLOUD_SWIFT_HASH'] parameters['SwiftPassword'] = passwords['OVERCLOUD_SWIFT_PASSWORD'] parameters['SnmpdReadonlyUserPassword'] = ( undercloud_ceilometer_snmpd_password) parameters['TrovePassword'] = ( passwords['OVERCLOUD_TROVE_PASSWORD']) parameters['NeutronMetadataProxySharedSecret'] = ( passwords['NEUTRON_METADATA_PROXY_SHARED_SECRET'])
def test_generate_passwords(self, create_cephx_key_mock, generate_password_mock, isfile_mock): mock_open = mock.mock_open() with mock.patch('six.moves.builtins.open', mock_open): passwords = utils.generate_overcloud_passwords( create_password_file=True) mock_calls = [ mock.call('NEUTRON_METADATA_PROXY_SHARED_SECRET=PASSWORD\n'), mock.call('OVERCLOUD_ADMIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_ADMIN_TOKEN=PASSWORD\n'), mock.call('OVERCLOUD_AODH_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_BARBICAN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_CEILOMETER_SECRET=PASSWORD\n'), mock.call('OVERCLOUD_CEPH_ADMIN_KEY=CEPHX_KEY\n'), mock.call('OVERCLOUD_CEPH_CLIENT_KEY=CEPHX_KEY\n'), mock.call('OVERCLOUD_CEPH_MON_KEY=CEPHX_KEY\n'), mock.call('OVERCLOUD_CEPH_RGW_KEY=CEPHX_KEY\n'), mock.call('OVERCLOUD_CINDER_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_DEMO_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_GLANCE_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_GNOCCHI_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HAPROXY_STATS_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_HEAT_STACK_DOMAIN_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_IRONIC_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_MANILA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_MISTRAL_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_MYSQL_CLUSTERCHECK_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NEUTRON_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_NOVA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_RABBITMQ_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_REDIS_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_SAHARA_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_HASH=PASSWORD\n'), mock.call('OVERCLOUD_SWIFT_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_TROVE_PASSWORD=PASSWORD\n'), mock.call('OVERCLOUD_ZAQAR_PASSWORD=PASSWORD\n'), ] self.assertEqual(sorted(mock_open().write.mock_calls), mock_calls) self.assertEqual( generate_password_mock.call_count + create_cephx_key_mock.call_count, len(mock_calls)) self.assertEqual(len(passwords), len(mock_calls))