示例#1
0
 def _test_create_router_dnat_rule(self, version, dest_port=None):
     lrouter = routerlib.create_lrouter(self.fake_cluster,
                                        uuidutils.generate_uuid(),
                                        'pippo',
                                        'fake-lrouter',
                                        '10.0.0.1')
     with mock.patch.object(self.fake_cluster.api_client,
                            'get_version',
                            return_value=ver_module.Version(version)):
         routerlib.create_lrouter_dnat_rule(
             self.fake_cluster, lrouter['uuid'], '192.168.0.2', order=200,
             dest_port=dest_port,
             match_criteria={'destination_ip_addresses': '10.0.0.3'})
         rules = routerlib.query_nat_rules(
             self.fake_cluster, lrouter['uuid'])
         self.assertEqual(len(rules), 1)
示例#2
0
 def _prepare_nat_rules_for_delete_tests(self):
     lrouter = routerlib.create_lrouter(self.fake_cluster,
                                        uuidutils.generate_uuid(),
                                        'pippo',
                                        'fake-lrouter',
                                        '10.0.0.1')
     # v2 or v3 makes no difference for this test
     with mock.patch.object(self.fake_cluster.api_client,
                            'get_version',
                            new=lambda: ver_module.Version('2.0')):
         routerlib.create_lrouter_snat_rule(
             self.fake_cluster, lrouter['uuid'],
             '10.0.0.2', '10.0.0.2', order=220,
             match_criteria={'source_ip_addresses': '192.168.0.0/24'})
         routerlib.create_lrouter_snat_rule(
             self.fake_cluster, lrouter['uuid'],
             '10.0.0.3', '10.0.0.3', order=200,
             match_criteria={'source_ip_addresses': '192.168.0.2/32'})
         routerlib.create_lrouter_dnat_rule(
             self.fake_cluster, lrouter['uuid'], '192.168.0.2', order=200,
             match_criteria={'destination_ip_addresses': '10.0.0.3'})
     return lrouter
示例#3
0
 def _test_create_lrouter_dnat_rule(self, version):
     with mock.patch.object(self.fake_cluster.api_client,
                            'get_version',
                            new=lambda: ver_module.Version(version)):
         tenant_id = 'pippo'
         lrouter = routerlib.create_lrouter(self.fake_cluster,
                                            uuidutils.generate_uuid(),
                                            tenant_id,
                                            'fake_router',
                                            '192.168.0.1')
         nat_rule = routerlib.create_lrouter_dnat_rule(
             self.fake_cluster, lrouter['uuid'], '10.0.0.99',
             match_criteria={'destination_ip_addresses':
                             '192.168.0.5'})
         uri = nsxlib._build_uri_path(routerlib.LROUTERNAT_RESOURCE,
                                      nat_rule['uuid'],
                                      lrouter['uuid'])
         resp_obj = nsxlib.do_request("GET", uri, cluster=self.fake_cluster)
         self.assertEqual('DestinationNatRule', resp_obj['type'])
         self.assertEqual('192.168.0.5',
                          resp_obj['match']['destination_ip_addresses'])