def test_create_tunnel_mappings(self): """Ensure successfully create new tunnel mappings.""" # Simulate that first IDs are obtained self.query_mock.return_value = [] map_db_mock = mock.patch.object(csr_db, 'IdentifierMap').start() conn_info = { 'ikepolicy_id': '10', 'ipsecpolicy_id': '50', 'id': '100', 'tenant_id': '1000' } csr_db.create_tunnel_mapping(self.context, conn_info) map_db_mock.assert_called_once_with(csr_tunnel_id=0, csr_ike_policy_id=1, csr_ipsec_policy_id=1, ipsec_site_conn_id='100', tenant_id='1000') # Create another, with next ID of 2 for all IDs (not mocking each # ID separately, so will not have different IDs). self.query_mock.return_value = [(0, ), (1, )] map_db_mock.reset_mock() conn_info = { 'ikepolicy_id': '20', 'ipsecpolicy_id': '60', 'id': '101', 'tenant_id': '1000' } csr_db.create_tunnel_mapping(self.context, conn_info) map_db_mock.assert_called_once_with(csr_tunnel_id=2, csr_ike_policy_id=2, csr_ipsec_policy_id=2, ipsec_site_conn_id='101', tenant_id='1000')
def create_ipsec_site_connection(self, context, ipsec_site_connection): vpnservice = self.service_plugin._get_vpnservice( context, ipsec_site_connection['vpnservice_id']) csr_id_map.create_tunnel_mapping(context, ipsec_site_connection) self.agent_rpc.vpnservice_updated(context, vpnservice['router_id'], reason='ipsec-conn-create')
def test_create_tunnel_mappings(self): """Ensure successfully create new tunnel mappings.""" # Simulate that first IDs are obtained self.query_mock.return_value = [] map_db_mock = mock.patch.object(csr_db, 'IdentifierMap').start() conn_info = {'ikepolicy_id': '10', 'ipsecpolicy_id': '50', 'id': '100', 'tenant_id': '1000'} csr_db.create_tunnel_mapping(self.context, conn_info) map_db_mock.assert_called_once_with(csr_tunnel_id=0, csr_ike_policy_id=1, csr_ipsec_policy_id=1, ipsec_site_conn_id='100', tenant_id='1000') # Create another, with next ID of 2 for all IDs (not mocking each # ID separately, so will not have different IDs). self.query_mock.return_value = [(0, ), (1, )] map_db_mock.reset_mock() conn_info = {'ikepolicy_id': '20', 'ipsecpolicy_id': '60', 'id': '101', 'tenant_id': '1000'} csr_db.create_tunnel_mapping(self.context, conn_info) map_db_mock.assert_called_once_with(csr_tunnel_id=2, csr_ike_policy_id=2, csr_ipsec_policy_id=2, ipsec_site_conn_id='101', tenant_id='1000')
def create_ipsec_site_connection(self, context, ipsec_site_connection): vpnservice = self.service_plugin._get_vpnservice( context, ipsec_site_connection['vpnservice_id']) try: self.validate_ipsec_connection(context, ipsec_site_connection, vpnservice) except CsrValidationFailure: with excutils.save_and_reraise_exception(): self.service_plugin.update_ipsec_site_conn_status( context, ipsec_site_connection['id'], constants.ERROR) csr_id_map.create_tunnel_mapping(context, ipsec_site_connection) self.agent_rpc.vpnservice_updated(context, vpnservice['router_id'])