Пример #1
0
    def test_update_lrouter_with_no_routes(self):
        router_id = 'fake_router_id'
        new_routes = [{"nexthop": "10.0.0.2",
                       "destination": "169.254.169.0/30"}, ]

        nsx_routes = [self._get_single_route(router_id)]
        with mock.patch.object(routerlib, 'get_explicit_routes_lrouter',
                               return_value=nsx_routes):
            with mock.patch.object(routerlib, 'create_explicit_route_lrouter',
                                   return_value='fake_uuid'):
                old_routes = routerlib.update_explicit_routes_lrouter(
                    self.fake_cluster, router_id, new_routes)
        self.assertEqual(old_routes, nsx_routes)
Пример #2
0
    def test_update_lrouter_with_routes(self):
        router_id = 'fake_router_id'
        new_routes = [{"next_hop_ip": "10.0.0.2",
                       "prefix": "169.254.169.0/30"}, ]

        nsx_routes = [self._get_single_route(router_id),
                      self._get_single_route(router_id, 'fake_route_id_1',
                                             '0.0.0.1/24', '10.0.0.3'),
                      self._get_single_route(router_id, 'fake_route_id_2',
                                             '0.0.0.2/24', '10.0.0.4'), ]

        with mock.patch.object(routerlib, 'get_explicit_routes_lrouter',
                               return_value=nsx_routes):
            with mock.patch.object(routerlib, 'delete_explicit_route_lrouter',
                                   return_value=None):
                with mock.patch.object(routerlib,
                                       'create_explicit_route_lrouter',
                                       return_value='fake_uuid'):
                    old_routes = routerlib.update_explicit_routes_lrouter(
                        self.fake_cluster, router_id, new_routes)
        self.assertEqual(old_routes, nsx_routes)