Beispiel #1
0
 def __init__(self, vpcid, prefix, portid, encap, macaddr, node_uuid=None):
     self.vpcid = vpcid
     self.prefix = ipaddress.IPv4Interface(prefix)
     self.portid = portid
     self.ethifidx = utils.PortToEthIfIdx(self.portid)
     if node_uuid:
         self.portuuid = utils.PdsUuid(self.ethifidx, node_uuid)
     else:
         self.portuuid = utils.PdsUuid(self.ethifidx)
     self.encap = encap
     self.macaddr = macaddr
     return
Beispiel #2
0
 def __init__(self,
              id,
              route_table_id,
              addrfamily,
              prefix,
              nhtype,
              nhid,
              nat_type=None,
              nat_addr_type="public",
              meteren=False,
              dnat_ip=None):
     assert (nhtype == "tunnel")
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.ROUTE)
     self.prefix = prefix
     self.nhtype = nhtype
     self.nhid = nhid
     self.nat_type = nat_type
     self.nat_addr_type = nat_addr_type
     if dnat_ip:
         self.nat_addr_type = "service"
     self.dnat_ip = dnat_ip
     self.meteren = meteren
     self.route_table_id = route_table_id
     self.addrfamily = addrfamily
Beispiel #3
0
 def __init__(self, id, local_addr, peer_addr):
     super().__init__()
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.BGP_PEER_AF)
     self.local_addr = local_addr
     self.peer_addr = peer_addr
     return
Beispiel #4
0
 def __init__(self, id, local_asn, router_id):
     super().__init__()
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.BGP)
     self.local_asn = local_asn
     self.router_id = router_id
     return
Beispiel #5
0
 def __init__(self,
              id,
              vpcid,
              localip,
              remoteip,
              macaddr,
              tunneltype,
              encaptype,
              vnid,
              nhid=None,
              ipsec_enc_id=None,
              ipsec_dec_id=None):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.TUNNEL)
     self.vpcid = vpcid
     self.localip = ipaddress.IPv4Address(localip)
     self.remoteip = ipaddress.IPv4Address(remoteip)
     if macaddr:
         self.macaddr = utils.getmac2num(macaddr, reorder=True)
     else:
         self.macaddr = None
     self.tunneltype = tunneltype
     self.encaptype = encaptype
     self.vnid = vnid
     self.nhid = nhid
     self.encrypt_id = ipsec_enc_id
     self.decrypt_id = ipsec_dec_id
     return
Beispiel #6
0
    def __init__(self,
                 id,
                 server_ip=None,
                 mtu=None,
                 gateway_ip=None,
                 dns_server=None,
                 ntp_server=None,
                 domain_name=None,
                 lease_timeout=None,
                 boot_filename=None):
        super().__init__()
        self.id = id
        self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.DHCP_POLICY)
        self.server_ip = server_ip
        self.mtu = mtu
        self.gateway_ip = gateway_ip
        self.dns_server = dns_server
        self.ntp_server = ntp_server
        self.domain_name = domain_name
        self.lease_timeout = lease_timeout
        self.boot_filename = boot_filename
        self.dns_server = dns_server if dns_server is not None else []
        self.ntp_server = ntp_server if ntp_server is not None else []

        return
Beispiel #7
0
 def __init__(self, id, tcp_idle_timeout, udp_idle_timeout, icmp_idle_timeout, conn_track_en=False):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.SECURITY_PROFILE)
     self.tcp_idle_timeout = tcp_idle_timeout
     self.udp_idle_timeout = udp_idle_timeout
     self.icmp_idle_timeout = icmp_idle_timeout
     self.conn_track_en = conn_track_en
     return
Beispiel #8
0
 def __init__(self, id, af, direction, rules, default_action=types_pb2.SECURITY_RULE_ACTION_ALLOW):
     self.id = id
     self.uuid     = utils.PdsUuid(self.id, objtype=api.ObjectTypes.POLICY)
     self.af       = af
     self.direction = direction
     self.rules = rules
     self.default_action = default_action
     return
Beispiel #9
0
 def __init__(self, id, vpcid, backend_ip, backend_port, vip, service_port):
     super().__init__()
     self.id    = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.SVC_MAPPING)
     self.vpcid = vpcid
     self.backend_ip = backend_ip
     self.backend_port = backend_port
     self.vip = vip
     self.service_port = service_port
     return
Beispiel #10
0
 def __init__(self,
              id,
              subnetid,
              macaddr,
              hostifindex,
              sourceguard=False,
              fabricencap='VXLAN',
              fabricencapid=1,
              rxmirrorid=[],
              txmirrorid=[],
              node_uuid=None,
              primary=False,
              encap='NONE',
              vlan1=None,
              vlan2=None,
              flow_learn_en=True,
              hostname=''):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.VNIC)
     self.primary = primary
     self.macaddr = macaddr
     self.subnetid = subnetid
     self.fabricencap = fabricencap
     self.fabricencapid = fabricencapid
     if hostifindex is not None:
         self.hostifindex = int(hostifindex, 16)
         if node_uuid:
             self.hostifuuid = utils.PdsUuid(self.hostifindex, node_uuid)
         else:
             self.hostifuuid = utils.PdsUuid(self.hostifindex)
     else:
         self.hostifuuid = None
     self.sourceguard = sourceguard
     self.rxmirrorid = rxmirrorid
     self.txmirrorid = txmirrorid
     self.encap = encap
     self.vlan1 = vlan1
     self.vlan2 = vlan2
     self.flow_learn_en = flow_learn_en
     self.hostname = hostname
     return
Beispiel #11
0
 def __init__(self, id, vpc_id=None, prefix=None, port_lo=None, port_hi=None, proto=None, addr_type="public"):
     super().__init__()
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.NAT)
     self.vpc_id = vpc_id
     self.prefix = prefix
     self.port_lo = port_lo
     self.port_hi = port_hi
     self.proto_name = proto
     self.proto_num = utils.GetIPProtoByName(proto)
     self.addr_type = addr_type
     return
Beispiel #12
0
 def __init__(self, id, vpcid, key, spi, salt):
     self.id = id
     self.uuid = utils.PdsUuid(self.id)
     self.vpcid = vpcid
     self.protocol = ipsec_pb2.IPSEC_PROTOCOL_ESP
     self.authalgo = ipsec_pb2.AUTHENTICATION_ALGORITHM_AES_GCM
     self.authkey = key
     self.encalgo = ipsec_pb2.ENCRYPTION_ALGORITHM_AES_GCM_256
     self.enckey = key
     self.spi = spi
     self.salt = salt
     return
Beispiel #13
0
    def __init__(self,
                 id,
                 vpcid,
                 v4prefix,
                 hostifindex,
                 v4virtualrouterip,
                 virtualroutermac,
                 v4routetableid,
                 fabricencap='VXLAN',
                 fabricencapid=1,
                 node_uuid=None,
                 dhcp_policy_id=None,
                 ingress_policy_id=None,
                 egress_policy_id=None):
        super().__init__()
        self.id = id
        self.vpcid = vpcid
        self.dhcp_policy_id = dhcp_policy_id
        self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.SUBNET)
        self.v4prefix = v4prefix

        self.hostifuuid = []
        self.hostifindex = []
        for cur_hostifidx in hostifindex:
            cur_hostifidx = int(cur_hostifidx, 16)
            self.hostifindex.append(cur_hostifidx)
            if node_uuid:
                self.hostifuuid.append(utils.PdsUuid(cur_hostifidx, node_uuid))
            else:
                self.hostifuuid.append(utils.PdsUuid(cur_hostifidx))

        self.v4virtualrouterip = v4virtualrouterip
        self.virtualroutermac = virtualroutermac
        self.fabricencap = fabricencap
        self.fabricencapid = fabricencapid
        self.v4routetableid = v4routetableid
        self.ingress_policy_id = ingress_policy_id
        self.egress_policy_id = egress_policy_id
        return
Beispiel #14
0
 def __init__(self,
              id,
              type=vpc_pb2.VPC_TYPE_TENANT,
              encaptype=types_pb2.ENCAP_TYPE_VXLAN,
              encapvalue=None,
              rmac=None,
              v4routetableid=None):
     #print(encapvalue)
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.VPC)
     self.type = type
     self.encaptype = encaptype
     self.encapvalue = encapvalue
     self.v4routetableid = v4routetableid
     return
Beispiel #15
0
 def __init__(self, id, local_addr, peer_addr, admin_state, send_comm, send_ext_comm, connect_retry, rrclient, remote_asn, holdtime, keepalive):
     super().__init__()
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.BGP_PEER)
     self.local_addr = local_addr
     self.peer_addr = peer_addr
     self.admin_state = admin_state
     self.send_comm = send_comm
     self.send_ext_comm = send_ext_comm
     self.connect_retry = connect_retry
     if rrclient == "client":
         self.rrclient = bgp_pb2.BGP_PEER_RR_CLIENT
     elif rrclient == "mesh":
         self.rrclient = bgp_pb2.BGP_PEER_RR_MESHED_CLIENT
     else:
         self.rrclient = bgp_pb2.BGP_PEER_RR_NONE
     self.remote_asn = remote_asn
     self.holdtime = holdtime
     self.keepalive = keepalive
     return
Beispiel #16
0
 def __init__(self,
              id,
              iftype,
              ifadminstatus,
              vpcid=None,
              prefix=None,
              portid=None,
              encap=None,
              macaddr=None,
              node_uuid=None,
              gateway=None):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.INTERFACE)
     self.iftype = iftype
     self.ifadminstatus = ifadminstatus
     if iftype == interface_pb2.IF_TYPE_L3:
         self.ifobj = L3IfObject(vpcid, prefix, portid, encap, macaddr,
                                 node_uuid)
     elif iftype == interface_pb2.IF_TYPE_CONTROL:
         self.ifobj = MgmtIfObject(prefix, macaddr, gateway=gateway)
     elif iftype == interface_pb2.IF_TYPE_LOOPBACK:
         self.ifobj = LoopbackIfObject(prefix)
     return
Beispiel #17
0
 def __init__(self,
              id,
              key_type,
              macaddr,
              ip,
              vpcid,
              subnetid=None,
              tunnelid=None,
              encaptype=None,
              encapslotid=None,
              nexthopgroupid=None,
              vnicid=None,
              public_ip=None,
              tags=[]):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.MAPPING)
     self.keytype = key_type
     self.macaddr = utils.getmac2num(macaddr)
     if type(ip) is ipaddress.IPv4Address:
         self.af = types_pb2.IP_AF_INET
         self.ip = int(ip)
     elif type(ip) is ipaddress.IPv6Address:
         self.af = types_pb2.IP_AF_INET6
         self.ip = ip.packed
     self.nexthopgroupid = nexthopgroupid
     self.vpcid = vpcid
     self.subnetid = subnetid
     self.tunnelid = tunnelid
     self.encaptype = encaptype
     self.encapslotid = encapslotid
     self.vnicid = vnicid
     self.public_ip = None
     if public_ip:
         self.public_ip = int(public_ip)
     self.tags = tags
     return
Beispiel #18
0
 def __init__(self, id, addrfamily, routes=None):
     self.id = id
     self.uuid = utils.PdsUuid(self.id, objtype=api.ObjectTypes.ROUTETABLE)
     self.addrfamily = addrfamily
     self.routes = routes
     return