コード例 #1
0
 def _mock_sec_group_mapping_db_calls(self, ret_value):
     mock.patch(vmware.nsx_method('get_nsx_security_group_id',
                                  module_name='dbexts.db'),
                return_value=ret_value).start()
     mock.patch(
         vmware.nsx_method('add_neutron_nsx_security_group_mapping',
                           module_name='dbexts.db')).start()
コード例 #2
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def _mock_sec_group_mapping_db_calls(self, ret_value):
     mock.patch(nsx_method('get_nsx_security_group_id',
                           module_name='dbexts.db'),
                return_value=ret_value).start()
     mock.patch(nsx_method('add_neutron_nsx_security_group_mapping',
                           module_name='dbexts.db')).start()
     self.addCleanup(mock.patch.stopall)
コード例 #3
0
ファイル: test_nsx_utils.py プロジェクト: penesoft/neutron
 def _mock_port_mapping_db_calls(self, ret_value):
     # Mock relevant db calls
     # This will allow for avoiding setting up the plugin
     # for creating db entries
     mock.patch(nsx_method("get_nsx_switch_and_port_id", module_name="dbexts.db"), return_value=ret_value).start()
     mock.patch(nsx_method("add_neutron_nsx_port_mapping", module_name="dbexts.db")).start()
     mock.patch(nsx_method("delete_neutron_nsx_port_mapping", module_name="dbexts.db")).start()
コード例 #4
0
 def _mock_router_mapping_db_calls(self, ret_value):
     # Mock relevant db calls
     # This will allow for avoiding setting up the plugin
     # for creating db entries
     mock.patch(nsx_method('get_nsx_router_id', module_name='dbexts.db'),
                return_value=ret_value).start()
     mock.patch(
         nsx_method('add_neutron_nsx_router_mapping',
                    module_name='dbexts.db')).start()
コード例 #5
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def _mock_router_mapping_db_calls(self, ret_value):
     # Mock relevant db calls
     # This will allow for avoiding setting up the plugin
     # for creating db entries
     mock.patch(nsx_method('get_nsx_router_id',
                           module_name='dbexts.db'),
                return_value=ret_value).start()
     mock.patch(nsx_method('add_neutron_nsx_router_mapping',
                           module_name='dbexts.db')).start()
コード例 #6
0
ファイル: test_nsx_utils.py プロジェクト: penesoft/neutron
 def test_get_nsx_switch_and_port_id_no_mappings_returns_none(self):
     # This test verifies that the function return (None, None) if the
     # mappings are not found both in the db and the backend
     ret_value = None, None
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(nsx_method("query_lswitch_lports", module_name="nsxlib.switch"), return_value=[]):
         self._verify_get_nsx_switch_and_port_id(None, None)
コード例 #7
0
 def test_get_nsx_router_id_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mapping
     # are not found both in the db and in the backend
     self._mock_router_mapping_db_calls(None)
     with mock.patch(vmware.nsx_method('query_lrouters',
                                       module_name='nsxlib.router'),
                     return_value=[]):
         self._verify_get_nsx_router_id(None)
コード例 #8
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def test_get_nsx_switch_ids_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mappings
     # are not found both in the db and in the backend
     self._mock_network_mapping_db_calls(None)
     with mock.patch(nsx_method('get_lswitches',
                                module_name='nsxlib.switch'),
                     return_value=[]):
         self._verify_get_nsx_switch_ids(None)
コード例 #9
0
 def test_get_nsx_switch_ids_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mappings
     # are not found both in the db and in the backend
     self._mock_network_mapping_db_calls(None)
     with mock.patch(nsx_method('get_lswitches',
                                module_name='nsxlib.switch'),
                     return_value=[]):
         self._verify_get_nsx_switch_ids(None)
コード例 #10
0
ファイル: test_nsx_utils.py プロジェクト: aaaaatoz/neutron
 def test_get_nsx_router_id_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mapping
     # are not found both in the db and in the backend
     self._mock_router_mapping_db_calls(None)
     with mock.patch(vmware.nsx_method('query_lrouters',
                                       module_name='nsxlib.router'),
                     return_value=[]):
         self._verify_get_nsx_router_id(None)
コード例 #11
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def test_get_nsx_sec_profile_id_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mapping
     # are not found both in the db and in the backend
     self._mock_sec_group_mapping_db_calls(None)
     with mock.patch(nsx_method('query_security_profiles',
                                module_name='nsxlib.secgroup'),
                     return_value=[]):
         self._verify_get_nsx_sec_profile_id(None)
コード例 #12
0
 def test_get_nsx_sec_profile_id_no_mapping_returns_None(self):
     # This test verifies that the function returns None if the mapping
     # are not found both in the db and in the backend
     self._mock_sec_group_mapping_db_calls(None)
     with mock.patch(nsx_method('query_security_profiles',
                                module_name='nsxlib.secgroup'),
                     return_value=[]):
         self._verify_get_nsx_sec_profile_id(None)
コード例 #13
0
 def test_get_nsx_router_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given port identifier
     exp_lr_uuid = uuidutils.generate_uuid()
     self._mock_router_mapping_db_calls(None)
     with mock.patch(vmware.nsx_method('query_lrouters',
                                       module_name='nsxlib.router'),
                     return_value=[{'uuid': exp_lr_uuid}]):
         self._verify_get_nsx_router_id(exp_lr_uuid)
コード例 #14
0
 def test_get_nsx_switch_and_port_id_no_mappings_returns_none(self):
     # This test verifies that the function return (None, None) if the
     # mappings are not found both in the db and the backend
     ret_value = None, None
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(nsx_method('query_lswitch_lports',
                                module_name='nsxlib.switch'),
                     return_value=[]):
         self._verify_get_nsx_switch_and_port_id(None, None)
コード例 #15
0
 def test_get_nsx_sec_profile_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given security profile identifier
     exp_sec_prof_uuid = uuidutils.generate_uuid()
     self._mock_sec_group_mapping_db_calls(None)
     with mock.patch(vmware.nsx_method('query_security_profiles',
                                       module_name='nsxlib.secgroup'),
                     return_value=[{'uuid': exp_sec_prof_uuid}]):
         self._verify_get_nsx_sec_profile_id(exp_sec_prof_uuid)
コード例 #16
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def test_get_nsx_sec_profile_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given security profile identifier
     exp_sec_prof_uuid = uuidutils.generate_uuid()
     self._mock_sec_group_mapping_db_calls(None)
     with mock.patch(nsx_method('query_security_profiles',
                                module_name='nsxlib.secgroup'),
                     return_value=[{'uuid': exp_sec_prof_uuid}]):
         self._verify_get_nsx_sec_profile_id(exp_sec_prof_uuid)
コード例 #17
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def test_get_nsx_router_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given port identifier
     exp_lr_uuid = uuidutils.generate_uuid()
     self._mock_router_mapping_db_calls(None)
     with mock.patch(nsx_method('query_lrouters',
                                module_name='nsxlib.router'),
                     return_value=[{'uuid': exp_lr_uuid}]):
         self._verify_get_nsx_router_id(exp_lr_uuid)
コード例 #18
0
ファイル: test_nsx_utils.py プロジェクト: Doude/neutron
 def test_get_nsx_switch_ids_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given network identifier
     exp_ls_uuids = [uuidutils.generate_uuid()]
     self._mock_network_mapping_db_calls(None)
     with mock.patch(nsx_method('get_lswitches',
                                module_name='nsxlib.switch'),
                     return_value=[{'uuid': uuid}
                                   for uuid in exp_ls_uuids]):
         self._verify_get_nsx_switch_ids(exp_ls_uuids)
コード例 #19
0
 def test_get_nsx_switch_ids_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given network identifier
     exp_ls_uuids = [uuidutils.generate_uuid()]
     self._mock_network_mapping_db_calls(None)
     with mock.patch(vmware.nsx_method('get_lswitches',
                                       module_name='nsxlib.switch'),
                     return_value=[{'uuid': uuid}
                                   for uuid in exp_ls_uuids]):
         self._verify_get_nsx_switch_ids(exp_ls_uuids)
コード例 #20
0
ファイル: test_nsx_utils.py プロジェクト: penesoft/neutron
 def test_get_nsx_switch_and_port_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given port identifier
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, None
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(
         nsx_method("query_lswitch_lports", module_name="nsxlib.switch"),
         return_value=[{"uuid": exp_lp_uuid, "_relations": {"LogicalSwitchConfig": {"uuid": exp_ls_uuid}}}],
     ):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
コード例 #21
0
ファイル: test_nsx_utils.py プロジェクト: penesoft/neutron
 def test_get_nsx_switch_and_port_id_only_port_db_mapping(self):
     # This test is representative of the case in which a port with a nvp
     # db mapping in the havana db was upgraded to icehouse
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, exp_lp_uuid
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(
         nsx_method("query_lswitch_lports", module_name="nsxlib.switch"),
         return_value=[{"uuid": exp_lp_uuid, "_relations": {"LogicalSwitchConfig": {"uuid": exp_ls_uuid}}}],
     ):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
コード例 #22
0
ファイル: test_nsx_utils.py プロジェクト: aaaaatoz/neutron
 def test_get_nsx_switch_and_port_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given port identifier
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, None
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(vmware.nsx_method('query_lswitch_lports',
                                       module_name='nsxlib.switch'),
                     return_value=[{'uuid': exp_lp_uuid,
                                    '_relations': {
                                        'LogicalSwitchConfig': {
                                            'uuid': exp_ls_uuid}
                                    }}]):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
コード例 #23
0
ファイル: test_nsx_utils.py プロジェクト: aaaaatoz/neutron
 def test_get_nsx_switch_and_port_id_only_port_db_mapping(self):
     # This test is representative of the case in which a port with a nsx
     # db mapping in the havana db was upgraded to icehouse
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, exp_lp_uuid
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(vmware.nsx_method('query_lswitch_lports',
                                       module_name='nsxlib.switch'),
                     return_value=[{'uuid': exp_lp_uuid,
                                    '_relations': {
                                        'LogicalSwitchConfig': {
                                            'uuid': exp_ls_uuid}
                                    }}]):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
コード例 #24
0
 def test_get_nsx_switch_and_port_id_no_db_mapping(self):
     # This test is representative of the case where db mappings where not
     # found for a given port identifier
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, None
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(vmware.nsx_method('query_lswitch_lports',
                                       module_name='nsxlib.switch'),
                     return_value=[{'uuid': exp_lp_uuid,
                                    '_relations': {
                                        'LogicalSwitchConfig': {
                                            'uuid': exp_ls_uuid}
                                    }}]):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)
コード例 #25
0
 def test_get_nsx_switch_and_port_id_only_port_db_mapping(self):
     # This test is representative of the case in which a port with a nsx
     # db mapping in the havana db was upgraded to icehouse
     exp_ls_uuid = uuidutils.generate_uuid()
     exp_lp_uuid = uuidutils.generate_uuid()
     ret_value = None, exp_lp_uuid
     self._mock_port_mapping_db_calls(ret_value)
     with mock.patch(vmware.nsx_method('query_lswitch_lports',
                                       module_name='nsxlib.switch'),
                     return_value=[{'uuid': exp_lp_uuid,
                                    '_relations': {
                                        'LogicalSwitchConfig': {
                                            'uuid': exp_ls_uuid}
                                    }}]):
         self._verify_get_nsx_switch_and_port_id(exp_ls_uuid, exp_lp_uuid)