Esempio n. 1
0
    def test_ni(self):
        ni1 = ni.NetworkInstance("pe1")
        ni1.config.router_id = "10.0.0.1"
        ni1.config.route_distinguisher = "10:100"
        ni1.config.route_target = "100:100"

        ni1.interfaces.append(
            ni.NetworkInstanceInterface("wth1.10", "eth1", 10),
            ni.NetworkInstanceInterface("wth2.10"),
        )

        ni1.mpls._global.interface_attributes.append(
            mpls.MplsGlobalInterface("eth2.10", "eth2", 10), )

        ni1.mpls.signaling_protocols.ldp._global.discovery.interfaces.append(
            mpls.MplsLdpGlobalDiscoveryInterface("eth1.10", "eth1", 10), )

        _bgp = bgp.Bgp("test-bgp")
        _bgp._global.config.as_number = 65000
        _bgp._global.config.router_id = "10.0.1.1"
        _bgp.neighbors.append(bgp.BgpNeighbor("10.0.0.1"), )
        ni1.protocols.append(ni.NetworkInstanceProtocol(_bgp))

        nis = elements.ListElement("network-instances")
        nis.append(ni1)

        print ET.tostring(nis.xml_element(), pretty_print=True)
Esempio n. 2
0
 def __init__(self, address, peer_as=None, local_as=None):
     super(BgpNeighbor, self).__init__(constants.BGP_NEIGHBOR)
     self.neighbor_address = address
     self.config = BgpNeighborConfig(address, peer_as, local_as)
     self.timers = BgpNeighborTimers()
     self.transport = BgpNeighborTransport()
     self.afi_safis = elements.ListElement("afi-safis")
     self.apply_policy = BgpNeighborApplyPolicy()
Esempio n. 3
0
    def test_interfaces(self):
        iface1 = interface.Interface("eth1")
        iface1.config.mtu = 100

        subif2 = subinterface.Subinterface(0)
        subif2_10 = subinterface.Subinterface(10)
        subif2_10.ipv4.addresses.append(address.Address("10.0.0.1", 24))
        iface2 = interface.Interface("eth2")
        iface2.subinterfaces.append(subif2, subif2_10)

        ifaces = elements.ListElement("interfaces")
        ifaces.append(iface1, iface2)

        print ET.tostring(ifaces.xml_element(), pretty_print=True)
Esempio n. 4
0
 def __init__(self, _id):
     super(NetworkInstanceLoopback, self).__init__("loopback")
     self._id = _id
     self.config = NetworkInstanceLoopbackConfig(_id)
     self.addresses = elements.ListElement("addresses")
Esempio n. 5
0
 def __init__(self, name):
     super(Interface, self).__init__(constants.INTERFACE)
     self.name = name
     self.config = InterfaceConfig(name, "ethernetCsmacd")
     self.subinterfaces = elements.ListElement("subinterfaces")
     self.ethernet = InterfaceEthernet()
Esempio n. 6
0
 def __init__(self, ip, prefix_length):
     super(StaticRoute, self).__init__("static")
     self.ip = ip
     self.prefix_length = prefix_length
     self.config = StaticRouteConfig(ip, prefix_length)
     self.next_hops = elements.ListElement("next-hops")
Esempio n. 7
0
 def __init__(self):
     super(SubinterfaceIPv6, self).__init__(constants.INTERFACES_IP_V6,
                                            nsmap=self._NSMAP)
     self.addresses = elements.ListElement("addresses")
     self.config = SubinterfaceIPv4Config()