Exemple #1
0
    def test_route_table_prefixes(self):
        """
        UT to verify CEM-22625.

        API server to allow applying two network routes (same prefix,
        different next-hops) to the same Virtual Network.
        """
        rt = RouteTable("rt1")
        routes = RouteTableType()
        route1 = RouteType(prefix="1.1.1.1/0",
                           next_hop="10.10.10.10",
                           next_hop_type="ip-address")
        route2 = RouteType(prefix="1.1.1.1/0",
                           next_hop="20.20.20.20",
                           next_hop_type="ip-address")
        routes.add_route(route1)
        routes.add_route(route2)
        rt.set_routes(routes)
        self._vnc_lib.route_table_create(rt)

        routes.delete_route(route2)
        route2 = RouteType(prefix="1.1.1.2/0",
                           next_hop="20.20.20.20",
                           next_hop_type="ip-address")
        routes.add_route(route2)
        rt.set_routes(routes)
        self._vnc_lib.route_table_update(rt)

        routes.delete_route(route1)
        routes.delete_route(route2)
Exemple #2
0
    def test_route_table_prefixes(self):
        rt = RouteTable("rt1")
        routes = RouteTableType()
        route1 = RouteType(prefix="1.1.1.1/0",
                           next_hop="10.10.10.10",
                           next_hop_type="ip-address")
        route2 = RouteType(prefix="1.1.1.1/0",
                           next_hop="20.20.20.20",
                           next_hop_type="ip-address")
        routes.add_route(route1)
        routes.add_route(route2)
        rt.set_routes(routes)
        try:
            self._vnc_lib.route_table_create(rt)
            self.fail("Create succeeded unexpectedly: duplicate prefixes "
                      "routes")
        except BadRequest:
            pass

        routes.delete_route(route2)
        route2 = RouteType(prefix="1.1.1.2/0",
                           next_hop="20.20.20.20",
                           next_hop_type="ip-address")
        routes.add_route(route2)
        rt.set_routes(routes)
        self._vnc_lib.route_table_create(rt)

        routes.delete_route(route2)
        route2 = RouteType(prefix="1.1.1.1/0",
                           next_hop="20.20.20.20",
                           next_hop_type="ip-address")
        routes.add_route(route2)
        rt.set_routes(routes)
        try:
            self._vnc_lib.route_table_update(rt)
            self.failt("Update succeeded unexpectedly - duplicate prefixe"
                       "routes")
        except BadRequest:
            pass
 def add_route(self, intf_route_table_obj, prefix):
     rt_routes = intf_route_table_obj.get_interface_route_table_routes()
     routes = rt_routes.get_route()
     found = False
     for route in routes:
         if route.prefix == prefix:
             print "Prefix already present in Interface Route Table, not adding"
             found = True
             sys.exit(0)
     if not found:
         rt1 = RouteType(prefix=prefix)
         routes.append(rt1)
     return intf_route_table_obj
  def add_route(self, intf_route_table_obj, prefix):
      rt_routes = intf_route_table_obj.get_interface_route_table_routes()
      routes = rt_routes.get_route()
      found = False
      #for route in routes:
      #    if route.prefix == prefix:
      #        print "Prefix already present in Interface Route Table, not adding"
      #        found = True
      #        sys.exit(0) 
      #if not found:
      for route in prefix:
 	    rt1 = RouteType(prefix = route)
          routes.append(rt1)
      intf_route_table_obj.set_interface_route_table_routes(rt_routes)
      return intf_route_table_obj
Exemple #5
0
 def add_route(self, global_config, prefix, nh):
     rt_routes = global_config.get_global_static_routes()
     routes = rt_routes.get_route()
     found = False
     for route in routes:
         if route.prefix == prefix:
             print "Prefix already present in default Route Table, not adding"
             found = True
             sys.exit(0)
     if not found:
         rt1 = RouteType(prefix=prefix,
                         next_hop=nh,
                         next_hop_type='ip-address')
     routes.append(rt1)
     global_config.set_global_static_routes(rt_routes)
     return global_config