def test_compute_changed_nova_public_key(self): self.test_relation.set({ 'migration_auth_type': 'sasl', 'nova_ssh_public_key': 'fookey', 'private-address': '10.0.0.1', 'region': 'RegionOne'}) self.ssh_known_hosts_lines.return_value = [ 'k_h_0', 'k_h_1', 'k_h_2'] self.ssh_authorized_keys_lines.return_value = [ 'auth_0', 'auth_1', 'auth_2'] hooks.compute_changed() self.ssh_compute_add.assert_called_with('fookey', user='******', rid=None, unit=None) expected_relations = [ call(relation_settings={'nova_authorized_keys_0': 'auth_0'}, relation_id=None), call(relation_settings={'nova_authorized_keys_1': 'auth_1'}, relation_id=None), call(relation_settings={'nova_authorized_keys_2': 'auth_2'}, relation_id=None), call(relation_settings={'nova_known_hosts_0': 'k_h_0'}, relation_id=None), call(relation_settings={'nova_known_hosts_1': 'k_h_1'}, relation_id=None), call(relation_settings={'nova_known_hosts_2': 'k_h_2'}, relation_id=None), call(relation_settings={'nova_known_hosts_max_index': 3}, relation_id=None), call(relation_settings={'nova_authorized_keys_max_index': 3}, relation_id=None)] self.assertEquals(sorted(self.relation_set.call_args_list), sorted(expected_relations))
def test_compute_changed_ssh_migration(self, mock_is_db_initialised): self.test_relation.set({ 'migration_auth_type': 'ssh', 'ssh_public_key': 'fookey', 'private-address': '10.0.0.1', 'region': 'RegionOne' }) self.ssh_known_hosts_lines.return_value = ['k_h_0', 'k_h_1', 'k_h_2'] self.ssh_authorized_keys_lines.return_value = [ 'auth_0', 'auth_1', 'auth_2' ] mock_is_db_initialised.return_value = False hooks.compute_changed() self.ssh_compute_add.assert_called_with('fookey', rid=None, unit=None) expected_relations = [ call(relation_settings={'authorized_keys_0': 'auth_0'}, relation_id=None), call(relation_settings={'authorized_keys_1': 'auth_1'}, relation_id=None), call(relation_settings={'authorized_keys_2': 'auth_2'}, relation_id=None), call(relation_settings={'known_hosts_0': 'k_h_0'}, relation_id=None), call(relation_settings={'known_hosts_1': 'k_h_1'}, relation_id=None), call(relation_settings={'known_hosts_2': 'k_h_2'}, relation_id=None), call(authorized_keys_max_index=3, relation_id=None), call(known_hosts_max_index=3, relation_id=None) ] self.assertEquals(sorted(self.relation_set.call_args_list), sorted(expected_relations))
def test_compute_changed_nova_public_key(self): self.test_relation.set({ 'migration_auth_type': 'sasl', 'nova_ssh_public_key': 'fookey', 'private-address': '10.0.0.1' }) self.ssh_known_hosts_lines.return_value = ['k_h_0', 'k_h_1', 'k_h_2'] self.ssh_authorized_keys_lines.return_value = [ 'auth_0', 'auth_1', 'auth_2' ] hooks.compute_changed() self.ssh_compute_add.assert_called_with('fookey', user='******', rid=None, unit=None) expected_relations = [ call(relation_settings={'nova_authorized_keys_0': 'auth_0'}, relation_id=None), call(relation_settings={'nova_authorized_keys_1': 'auth_1'}, relation_id=None), call(relation_settings={'nova_authorized_keys_2': 'auth_2'}, relation_id=None), call(relation_settings={'nova_known_hosts_0': 'k_h_0'}, relation_id=None), call(relation_settings={'nova_known_hosts_1': 'k_h_1'}, relation_id=None), call(relation_settings={'nova_known_hosts_2': 'k_h_2'}, relation_id=None), call(relation_settings={'nova_known_hosts_max_index': 3}, relation_id=None), call(relation_settings={'nova_authorized_keys_max_index': 3}, relation_id=None) ] self.assertEquals(sorted(self.relation_set.call_args_list), sorted(expected_relations))
def test_compute_changed_nova_api_trigger(self, api_joined, mock_is_db_initialised, mock_is_cellv2_init_ready): self.relation_ids.return_value = ['nova-api/0'] mock_is_db_initialised.return_value = False mock_is_cellv2_init_ready.return_value = False hooks.compute_changed() api_joined.assert_called_with(rid='nova-api/0')
def test_compute_changed_ssh_migration(self): self.test_relation.set({ 'migration_auth_type': 'ssh', 'ssh_public_key': 'fookey', 'private-address': '10.0.0.1'}) self.ssh_known_hosts_b64.return_value = 'hosts' self.ssh_authorized_keys_b64.return_value = 'keys' hooks.compute_changed() self.ssh_compute_add.assert_called_with('fookey') self.relation_set.assert_called_with(known_hosts='hosts', authorized_keys='keys')
def test_compute_changed_nova_api_trigger(self, api_joined): self.relation_ids.return_value = ['nova-api/0'] hooks.compute_changed() api_joined.assert_called_with(rid='nova-api/0')