def test_router_version(self): network = objects.NetworkTestObj(self.neutron, self.nb_api) self.addCleanup(network.close) network_id = network.create() self.assertTrue(network.exists()) subnet = objects.SubnetTestObj(self.neutron, self.nb_api, network_id) self.addCleanup(subnet.close) subnet_id = subnet.create() self.assertTrue(subnet.exists()) router = objects.RouterTestObj(self.neutron, self.nb_api) self.addCleanup(router.close) router_id = router.create() self.assertTrue(router.exists()) prev_version = self.nb_api.get(l3.LogicalRouter(id=router_id)).version subnet_msg = {'subnet_id': subnet_id} self.neutron.add_interface_router(router_id, body=subnet_msg) version = self.nb_api.get(l3.LogicalRouter(id=router_id)).version self.assertGreater(version, prev_version) prev_version = version self.neutron.remove_interface_router(router_id, body=subnet_msg) version = self.nb_api.get(l3.LogicalRouter(id=router_id)).version self.assertGreater(version, prev_version) router.close() self.assertFalse(router.exists()) subnet.close() self.assertFalse(subnet.exists()) network.close() self.assertFalse(network.exists())
def test_create_delete_router(self): router = self.store(objects.RouterTestObj(self.neutron, self.nb_api)) router_id = router.create() self.assertTrue(router.exists()) version1 = self.nb_api.get(l3.LogicalRouter(id=router_id)).version router.update() self.assertTrue(router.exists()) version2 = self.nb_api.get(l3.LogicalRouter(id=router_id)).version self.assertTrue(version1 != version2) router.close() self.assertFalse(router.exists())
def on_switch_leave(self, ev): print "Switch left" dpid = "{}".format(ev.switch.dp.id) # Removing Switch from DB and Cache (optional) router = self.nb_api.get(l3.LogicalRouter(id=dpid)) self.nb_api.delete(router) print ("l3 Switch LEAVE Done")
def logical_router_from_neutron_router(router): return l3.LogicalRouter( id=router['id'], topic=router['tenant_id'], name=router.get('name', df_const.DF_ROUTER_DEFAULT_NAME), version=router['revision_number'], routes=router.get('routes', []))
def _add_concrete_router_interface(self, lport, router=None): """ The router interace is concrete, direct the packets to the real port of router interface. The flow here will overwrite the flow that packet-in the packets to local controller. If the router is not given (or is None), try to get it from the port's owner. :param lport: The router interface's concrete port :type lport: LogicalPort model object :param router: The owning router :type lport: LogicalRouter or None """ router = router or self.db_store.get_one( l3.LogicalRouter(id=lport.device_id)) if not router: return router_unique_key = router.unique_key port_unique_key = lport.unique_key match = self._get_router_interface_match(router_unique_key, lport.ip) actions = [self.parser.OFPActionSetField(reg7=port_unique_key)] action_inst = self.parser.OFPInstructionActions( self.ofproto.OFPIT_APPLY_ACTIONS, actions) goto_inst = self.parser.OFPInstructionGotoTable(const.EGRESS_TABLE) inst = [action_inst, goto_inst] self.mod_flow(inst=inst, table_id=const.L3_LOOKUP_TABLE, priority=const.PRIORITY_HIGH, match=match)
def _install_flow_by_packet_and_continue(self, pkt_ip, network_id, msg): """ Install the routing flows by the information in the packet, and have the packet continue along the pipelone. :param pkt_ip: IP header on the packet (IPv4 or IPv6) :type pkt_ip: ryu.packet.ipv4 or ryu.packet.ipv6 :param network_id: The source network from which the packet arrived :type network_id: Integer :param msg: Packet in message :type msg: ryu.ofproto.ofproto_v<version>_parser.OFPPacketIn """ ip_addr = netaddr.IPAddress(pkt_ip.dst) router_unique_key = msg.match.get('reg5') router = self.db_store.get_all( l3.LogicalRouter(unique_key=router_unique_key), l3.LogicalRouter.get_index('unique_key')) for router_port in router.ports: if ip_addr in router_port.network: index = l2.LogicalPort.get_index('lswitch_id') dst_ports = self.db_store.get_all(l2.LogicalPort( lswitch=l2.LogicalSwitch(id=router_port.lswitch.id)), index=index) for out_port in dst_ports: if out_port.ip == ip_addr: self._install_flow_by_ports_and_continue( router_port, out_port, msg, network_id) return
def _handle_ttl_expired(self, msg): if self.ttl_invalid_handler_rate_limit(): LOG.warning("Get more than %(rate)s TTL invalid packets per " "second at table %(table)s", {'rate': self.conf.router_ttl_invalid_max_rate, 'table': const.L3_LOOKUP_TABLE}) return LOG.debug("Get an invalid TTL packet at table %s", const.L3_LOOKUP_TABLE) pkt = packet.Packet(msg.data) e_pkt = pkt.get_protocol(ethernet.ethernet) router_key = msg.match.get('reg5') lrouter = self.db_store.get_one( l3.LogicalRouter(unique_key=router_key), index=l3.LogicalRouter.get_index('unique_key'), ) router_port_ip = None for port in lrouter.ports: if port.lswitch.unique_key == msg.match.get('metadata'): router_port_ip = port.network.ip break if router_port_ip: icmp_ttl_pkt = icmp_error_generator.generate( icmp.ICMP_TIME_EXCEEDED, icmp.ICMP_TTL_EXPIRED_CODE, msg.data, str(router_port_ip), pkt) unique_key = msg.match.get('reg6') self.dispatch_packet(icmp_ttl_pkt, unique_key) else: LOG.warning("The invalid TTL packet's destination mac %s " "can't be recognized.", e_pkt.dst)
def add_router_interface(self, context, router_id, interface_info): router_port_info = super(DFL3RouterPlugin, self).add_router_interface( context, router_id, interface_info) router = self.get_router(context, router_id) port = self.core_plugin.get_port(context, router_port_info['port_id']) subnet = self.core_plugin.get_subnet(context, router_port_info['subnet_id']) cidr = netaddr.IPNetwork(subnet['cidr']) network = "%s/%s" % (port['fixed_ips'][0]['ip_address'], str(cidr.prefixlen)) logical_port = self.nb_api.get( l2.LogicalPort(id=port['id'], topic=port['tenant_id'])) logical_router_port = neutron_l3.build_logical_router_port( router_port_info, mac=port['mac_address'], network=network, unique_key=logical_port.unique_key) lrouter = self.nb_api.get( l3.LogicalRouter(id=router_id, topic=router['tenant_id'])) lrouter.version = router['revision_number'] lrouter.add_router_port(logical_router_port) self.nb_api.update(lrouter) return router_port_info
def create_logical_router(self, switch): """ Only works with testbed0/mininet_multi_switches_ipv4.py :param switch: :return: """ if self.nb_api is None: self.nb_api = api_nb.NbApi.get_instance(False) # TODO: lswitch from nb api router_ports = [] dpid = str(switch.dp.id) for port in switch.ports: # network = "192.168.33.1/24", network = None ip = None if dpid == '1': if port.port_no == 1: network = SUBNET1 ip = DP1_PORT1_GATEWAY_IP else: network = SUBNET2 ip = DP1_PORT2_GATEWAY_IP elif dpid == '2': if port.port_no == 1: network = SUBNET2 ip = DP2_PORT1_GATEWAY_IP else: network = SUBNET3 ip = DP2_PORT2_GATEWAY_IP elif dpid == '3': if port.port_no == 1: network = SUBNET3 ip = DP3_PORT1_GATEWAY_IP else: network = SUBNET4 ip = DP3_PORT2_GATEWAY_IP else: print "Datapath {} not supported. Router not created!".format(dpid) return if network and ip: router_port = l3.LogicalRouterPort(lswitch="{}".format(switch.dp.id), topic="fake_tenant1", network=network, gateway_ip=ip, mac="{}".format(port.hw_addr), port_no=str(port.port_no), unique_key=4, id="{}:{}".format(switch.dp.id, port.port_no)) router_ports.append(router_port) router = l3.LogicalRouter(name="router_of_{}".format(switch.dp.id), topic="fake_tenant1", version=10, id="{}".format(switch.dp.id), unique_key=5, ports=router_ports) self.nb_api.create(router)
def delete_router(self, context, router_id): ret_val = super(DFL3RouterPlugin, self).delete_router(context, router_id) try: self.nb_api.delete(l3.LogicalRouter(id=router_id)) except df_exceptions.DBKeyNotFound: LOG.debug("router %s is not found in DF DB", router_id) return ret_val
def db_change_callback(self, table, key, action, value, topic=None): """ Called from nb_api on db update. Routing: When logicalport is updated with a host ip (this happens while arp request/responses): for all routers install route to this ip :param table: :param key: :param action: :param value: :param topic: """ if self.USE_CACHE: # Update cache if action == 'create' or action == 'set': if table == 'lport': self.cache_logical_port_by_port_id[key] = self.nb_api.get(l2.LogicalPort(id=key)) if table == 'lrouter': self.cache_logical_router_by_dpid[key] = self.nb_api.get(l3.LogicalRouter(id=key)) if action == 'del': if table == 'lport': # default if key does not exists is None self.cache_logical_port_by_port_id.pop(key, None) if table == 'lrouter': self.cache_logical_router_by_dpid.pop(key, None) print("L3 App: Received Update for table {} and key {} action {}".format(table, key, action)) if action == 'set': if table == 'lport': if self.USE_CACHE: updated_port = self.cache_logical_port_by_port_id[key] else: updated_port = self.nb_api.get(l2.LogicalPort(id=key)) if len(updated_port.ips) is not 0: for ip in updated_port.ips: # new ip discovered # install route on every datapath # only update the other datapaths for dpid, datapath in self.cache_datapath_by_dpid.iteritems(): out_port, new_src_mac, new_dst_mac = self.get_next_hop(dpid, ip) if out_port is None: continue out_port_id = "{}:{}".format(dpid, out_port) lout_port = self.nb_api.get(l2.LogicalPort(id=out_port_id)) if ip in lout_port.ips: continue # else add new ip and install flow lout_port.ips.append(ip) self.nb_api.update(lout_port) # install flow print "L3 IP via pubsub: installing flow on {}: out_port: {} src_mac:" \ " {} dst_mac: {}, ip: {}".format(datapath.id, out_port, new_src_mac, new_dst_mac, ip) self.add_flow_gateway_for_ip(datapath, int(out_port), ip, new_src_mac, new_dst_mac)
def _get_vm_gateway_info(self, floatingip): lport = self.db_store2.get_one( l2.LogicalPort(id=floatingip.get_lport_id())) lrouter = self.db_store2.get_one(l3.LogicalRouter( id=floatingip.get_lrouter_id())) for router_port in lrouter.ports: if router_port.lswitch.id == lport.lswitch.id: return router_port.mac return None
def get_port_by_ip(self, datapath, dstIp): if self.nb_api is None: self.nb_api = api_nb.NbApi.get_instance(False) if self.USE_CACHE and datapath.id in self.cache_logical_router_by_dpid.keys(): lrouter = self.cache_logical_router_by_dpid[datapath.id] else: lrouter = self.nb_api.get(l3.LogicalRouter(id=str(datapath.id))) for port in lrouter.ports: if self.ip_matches_network(str(port.network), str(dstIp)): return port
def test_reply_ttl_invalid_message_with_rate_limit(self): pkt = packet.Packet() pkt.add_protocol(ethernet.ethernet(dst='aa:bb:cc:dd:ee:ff')) pkt.add_protocol(ipv4.ipv4(proto=in_proto.IPPROTO_UDP)) pkt.add_protocol(udp.udp()) pkt.serialize() lswitch = l2.LogicalSwitch( id='lswitch1', topic='topic1', unique_key=9, version=1, ) self.app.db_store.update(lswitch) lrouter = l3.LogicalRouter( id='lrouter1', topic='topic1', version=1, unique_key=22, ports=[ l3.LogicalRouterPort( id='lrouter1-port1', unique_key=55, topic='topic1', mac='aa:bb:cc:dd:ee:ff', network='10.0.0.1/24', lswitch='lswitch1', ), ], ) self.app.db_store.update(lrouter) event = ofp_event.EventOFPMsgBase( msg=ofproto_parser.OFPPacketIn( datapath=mock.Mock(), reason=self.app.ofproto.OFPR_INVALID_TTL, match=ofproto_parser.OFPMatch( metadata=lswitch.unique_key, reg5=lrouter.unique_key, ), data=pkt.data, ) ) with mock.patch("dragonflow.controller.common." "icmp_error_generator.generate") as icmp_error: for _ in range(self.app.conf.router_ttl_invalid_max_rate * 2): self.app.packet_in_handler(event) self.assertEqual(self.app.conf.router_ttl_invalid_max_rate, icmp_error.call_count) icmp_error.assert_called_with(icmp.ICMP_TIME_EXCEEDED, icmp.ICMP_TTL_EXPIRED_CODE, mock.ANY, "10.0.0.1", mock.ANY)
def test_create_lrouter(self): fake_lrouter = l3.LogicalRouter(id='test_router0', topic='test_tenant1') self.nb_api.create(fake_lrouter) lean_fake_lrouter = l3.LogicalRouter(id=fake_lrouter.id, topic=fake_lrouter.topic) self.addCleanup(self.nb_api.delete, lean_fake_lrouter) lrouter = self.nb_api.get(lean_fake_lrouter) self.assertIsNotNone(lrouter.unique_key) fake_lrouter1 = l3.LogicalRouter(id='test_router1', topic='test_tenant1') self.nb_api.create(fake_lrouter1) lean_fake_lrouter1 = l3.LogicalRouter(id=fake_lrouter1.id, topic=fake_lrouter1.topic) self.addCleanup(self.nb_api.delete, lean_fake_lrouter1) lrouter1 = self.nb_api.get(lean_fake_lrouter1) self.assertIsNotNone(lrouter1.unique_key) self.assertNotEqual(lrouter.unique_key, lrouter1.unique_key)
def get_hwaddr_of_router_port(self, datapath, in_port): if self.nb_api is None: self.nb_api = api_nb.NbApi.get_instance(False) if self.USE_CACHE and datapath.id in self.cache_logical_router_by_dpid.keys(): lrouter = self.cache_logical_router_by_dpid[datapath.id] else: lrouter = self.nb_api.get(l3.LogicalRouter(id=str(datapath.id))) for port in lrouter.ports: if port.port_no == in_port: return port.mac return None
def test_create_router(self): self.subnets = [ l2.Subnet(dhcp_ip="10.1.0.2", name="private-subnet", enable_dhcp=True, topic="fake_tenant1", gateway_ip="10.1.0.1", cidr="10.1.0.0/24", id="test_subnet10_1") ] self.lswitch = l2.LogicalSwitch(subnets=self.subnets, unique_key=3, name='test_lswitch_1', is_external=False, segmentation_id=41, topic='fake_tenant1', id='test_lswitch_1', version=5) self.router_ports = [ l3.LogicalRouterPort(network="10.1.0.1/24", lswitch=self.lswitch, topic="fake_tenant1", mac="fa:16:3e:50:96:f5", unique_key=4, id="fake_router_1_port1") ] self.router = l3.LogicalRouter(name="fake_router_1", topic="fake_tenant1", version=10, id="fake_router_1", unique_key=5, ports=self.router_ports) self.controller.update(self.lswitch) self.app.mod_flow.reset_mock() self.controller.update(self.router) self.app._add_router_port.assert_called_once_with(self.router_ports[0]) parser = self.app.parser ofproto = self.app.ofproto match = parser.OFPMatch(metadata=5, eth_dst="fa:16:3e:50:96:f5") actions = [parser.OFPActionSetField(reg7=4)] inst = [ parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS, actions), parser.OFPInstructionGotoTable(const.EGRESS_TABLE), ] self.app.mod_flow.assert_called_once_with( inst=inst, table_id=const.L3_LOOKUP_TABLE, priority=const.PRIORITY_VERY_LOW, match=match)
def test_udp_virtual_router_interface_with_rate_limit(self): if 'zmq_pubsub_driver' == cfg.CONF.df.pub_sub_driver: # NOTE(nick-ma-z): This test case directly calls nb_api which # relies on a publisher running on local process. In ZMQ driver, # a socket needs to be binded which causes conflicts with other # df-services. But in Redis driver, the publisher is virtual and # does not actually run which makes this test case work. self.skipTest("ZMQ_PUBSUB does not support this test case") # Delete the concrete router interface. router_port_id = self.router.router_interfaces[ self.subnet1.subnet_id]['port_id'] topic = self.router.router_interfaces[ self.subnet1.subnet_id]['tenant_id'] self.nb_api.delete(l2.LogicalPort(id=router_port_id, topic=topic)) lrouter = self.nb_api.get( l3.LogicalRouter(id=self.router.router.router_id, topic=topic)) lrouter.version += 1 original_lrouter = copy.deepcopy(lrouter) lrouter.remove_router_port(router_port_id) self.nb_api.update(lrouter) # Update router with virtual router interface. original_lrouter.version += 1 self.nb_api.update(original_lrouter) time.sleep(const.DEFAULT_CMD_TIMEOUT) self.port1.port.update({"security_groups": []}) ignore_action = app_testing_objects.IgnoreAction() port_policy = self._create_rate_limit_port_policies( cfg.CONF.df_l3_app.router_port_unreach_max_rate, app_testing_objects.RyuICMPUnreachFilter) initial_packet = self._create_packet( "192.168.12.1", ryu.lib.packet.ipv4.inet.IPPROTO_UDP) send_action = app_testing_objects.SendAction(self.subnet1.subnet_id, self.port1.port_id, initial_packet) policy = self.store( app_testing_objects.Policy(initial_actions=[ send_action, send_action, send_action, send_action ], port_policies=port_policy, unknown_port_action=ignore_action)) policy.start(self.topology) # Since the rate limit, we expect timeout to wait for 4th packet hit # the policy. self.assertRaises(app_testing_objects.TimeoutException, policy.wait, const.DEFAULT_RESOURCE_READY_TIMEOUT) if len(policy.exceptions) > 0: raise policy.exceptions[0]
def remove_router_interface(self, context, router_id, interface_info): router_port_info = ( super(DFL3AgentlessRouterPlugin, self).remove_router_interface( context, router_id, interface_info)) router = self.get_router(context, router_id) try: lrouter = self.nb_api.get(l3.LogicalRouter( id=router_id, topic=router['tenant_id'])) lrouter.remove_router_port(router_port_info['port_id']) lrouter.version = router['revision_number'] self.nb_api.update(lrouter) except df_exceptions.DBKeyNotFound: LOG.exception("logical router %s is not found in DF DB, " "suppressing delete_lrouter_port " "exception", router_id) return router_port_info
def _get_route(self, pkt_ip, network_id, msg): ip_addr = netaddr.IPAddress(pkt_ip.dst) router_unique_key = msg.match.get('reg5') router = self.db_store2.get_all( l3.LogicalRouter(unique_key=router_unique_key), l3.LogicalRouter.get_index('unique_key')) for router_port in router.ports: if ip_addr in router_port.network: index = l2.LogicalPort.get_index('lswitch_id') dst_ports = self.db_store2.get_all(l2.LogicalPort( lswitch=l2.LogicalSwitch(id=router_port.lswitch.id)), index=index) for out_port in dst_ports: if out_port.ip == ip_addr: self._install_l3_flow(router_port, out_port, msg, network_id) return
def test_reply_icmp_unreachable_with_rate_limit(self): pkt = packet.Packet() pkt.add_protocol(ethernet.ethernet(dst='aa:bb:cc:dd:ee:ff')) pkt.add_protocol(ipv4.ipv4(dst='10.0.0.1', proto=in_proto.IPPROTO_UDP)) pkt.add_protocol(udp.udp()) pkt.serialize() lrouter = l3.LogicalRouter( id='lrouter1', topic='topic1', version=1, unique_key=22, ports=[ l3.LogicalRouterPort( id='lrouter1-port1', unique_key=55, topic='topic1', mac='aa:bb:cc:dd:ee:ff', network='10.0.0.1/24', ), ], ) self.app.db_store.update(lrouter) event = ofp_event.EventOFPMsgBase( msg=ofproto_parser.OFPPacketIn( datapath=mock.Mock(), reason=self.app.ofproto.OFPR_PACKET_IN, match=ofproto_parser.OFPMatch( reg7=lrouter.ports[0].unique_key, ), data=pkt.data, ) ) with mock.patch("dragonflow.controller.common." "icmp_error_generator.generate") as icmp_error: for _ in range(self.app.conf.router_port_unreach_max_rate * 2): self.app.packet_in_handler(event) self.assertEqual( self.app.conf.router_port_unreach_max_rate, icmp_error.call_count) icmp_error.assert_called_with(icmp.ICMP_DEST_UNREACH, icmp.ICMP_PORT_UNREACH_CODE, pkt.data, pkt=mock.ANY)
def get_router_port_by_gateway_ip(self, dpid, gateway_ip): """ Returns Port of Datapath with matching gateway ip :param dpid: :param gateway_ip: :return: """ if self.nb_api is None: self.nb_api = api_nb.NbApi.get_instance(False) dpid = str(dpid) if self.USE_CACHE and dpid in self.cache_logical_router_by_dpid.keys(): lrouter = self.cache_logical_router_by_dpid[dpid] else: lrouter = self.nb_api.get(l3.LogicalRouter(id=dpid)) for router_port in lrouter.ports: if str(router_port.gateway_ip) == gateway_ip: # check all ports of this datapath return router_port return None
def _add_concrete_router_interface(self, lport, router=None): # The router interace is concrete, direct the packets to the real # port of router interface. The flow here will overwrite # the flow that packet-in the packets to local controller. router = router or self.db_store.get_one( l3.LogicalRouter(id=lport.device_id)) if not router: return router_unique_key = router.unique_key port_unique_key = lport.unique_key match = self._get_router_interface_match(router_unique_key, lport.ip) actions = [self.parser.OFPActionSetField(reg7=port_unique_key)] action_inst = self.parser.OFPInstructionActions( self.ofproto.OFPIT_APPLY_ACTIONS, actions) goto_inst = self.parser.OFPInstructionGotoTable(const.EGRESS_TABLE) inst = [action_inst, goto_inst] self.mod_flow(inst=inst, table_id=const.L3_LOOKUP_TABLE, priority=const.PRIORITY_HIGH, match=match)
def logical_router_from_neutron_router(router): return l3.LogicalRouter(id=router['id'], topic=utils.get_obj_topic(router), name=router.get('name'), version=router['revision_number'], routes=router.get('routes', []))
def get_next_hop(self, dpid, dstIP): """ This is a STUB! This is static implemented according to the test topology. In Future work this information is retrieved via routing protocols :param dpid: :param dstIP: :return: port number, new src mac, new dst mac """ if self.nb_api is None: self.nb_api = api_nb.NbApi.get_instance(False) dstIP = str(dstIP) # TODO: THIS IS JUST A STUB: Use Database for this dpid = str(dpid) if self.USE_CACHE and dpid in self.cache_logical_router_by_dpid.keys(): lrouter = self.cache_logical_router_by_dpid[dpid] else: lrouter = self.nb_api.get(l3.LogicalRouter(id=dpid)) if dpid == '1': if not self.ip_matches_network(SUBNET1, dstIP) and not self.ip_matches_network(SUBNET2, dstIP): rport = lrouter.ports[1] if self.USE_CACHE: nexthop_router = self.cache_logical_router_by_dpid["2"] else: nexthop_router = self.nb_api.get(l3.LogicalRouter(id="2")) nh_port = nexthop_router.ports[0] return rport.port_no, rport.mac, nh_port.mac else: # network is directly connected to switch # host mac is learned during arp request. return None, None, None elif dpid == '2': if self.ip_matches_network(SUBNET3, dstIP) or self.ip_matches_network(SUBNET4, dstIP): rport = lrouter.ports[1] # second port if self.USE_CACHE: nexthop_router = self.cache_logical_router_by_dpid["3"] else: nexthop_router = self.nb_api.get(l3.LogicalRouter(id="3")) nh_port = nexthop_router.ports[0] return rport.port_no, rport.mac, nh_port.mac elif self.ip_matches_network(SUBNET1, dstIP) or self.ip_matches_network(SUBNET2, dstIP): rport = lrouter.ports[0] # first port if self.USE_CACHE: nexthop_router = self.cache_logical_router_by_dpid["1"] else: nexthop_router = self.nb_api.get(l3.LogicalRouter(id="1")) nh_port = nexthop_router.ports[1] # second port return rport.port_no, rport.mac, nh_port.mac elif dpid == '3': if not self.ip_matches_network(SUBNET3, dstIP) and not self.ip_matches_network(SUBNET4, dstIP): rport = lrouter.ports[0] if self.USE_CACHE: nexthop_router = self.cache_logical_router_by_dpid["2"] else: nexthop_router = self.nb_api.get(l3.LogicalRouter(id="2")) nh_port = nexthop_router.ports[1] return rport.port_no, rport.mac, nh_port.mac else: # host mac adress # Learned by ARP return None, None, None else: print "Datapath {} not supported. Cannot return nexthop information!" return None, None, None
def exists(self): router = self.nb_api.get(l3.LogicalRouter(id=self.router_id)) if router: return True return False
super(DFAppTestBase, self).tearDown() fake_logical_router_ports = [ l3.LogicalRouterPort(network="10.0.0.1/24", lswitch="fake_switch1", topic="fake_tenant1", mac="fa:16:3e:50:96:f4", unique_key=14, id="fake_router_port1") ] fake_logic_router1 = l3.LogicalRouter(name="router1", topic="fake_tenant1", version=10, routes=[], id="fake_router_id", unique_key=1, ports=fake_logical_router_ports) fake_logic_switch1 = l2.LogicalSwitch(unique_key=1, name='private', is_external=False, segmentation_id=41, mtu=1450, topic='fake_tenant1', id='fake_switch1', version=5) fake_lswitch_default_subnets = [ l2.Subnet(name="private-subnet",