def __get_route_attribs(spec, af=utils.IP_VERSION_4): nhid = 0 nhgid = 0 vpcid = 0 tunnelid = 0 nat_type = None service_nat_prefix = getattr(spec, 'servicenatprefix', None) classpriority = getattr(spec, 'classpriority', 0) meteren = getattr(spec, 'meteren', False) dnat_ip = getattr(spec, 'dnatip', None) natspec = getattr(spec, 'nat', None) if natspec: nat_type = getattr(natspec, 'type', None) nat_level = getattr(natspec, 'level', None) nh_type = __derive_nh_type_info(spec) if nh_type == "vpcpeer": vpcid = vpcpeerid elif nh_type == "tep": tunobj = __get_tunnel(spec) if utils.IsPipelineArtemis() and tunobj.IsSvc(): # service tunnel case nh_type = "nh" nexthop = __get_nexthop(af) nh_id = nexthop.NexthopId else: tunnelid = tunobj.Id elif nh_type == "nh": nexthop = __get_nexthop(af) if nexthop: nhid = nexthop.NexthopId elif nh_type == "nhg": nhgid = 1 # fill later return nh_type, nhid, nhgid, vpcid, tunnelid, nat_type, \ service_nat_prefix, dnat_ip, classpriority, meteren
def GenerateObjects(self, node, topospec): vpc_count = 0 for p in topospec.vpc: count = max(1, getattr(p, 'count', 0)) vpc_count += count for c in range(count): obj = None if hasattr(p, "nat46"): if p.nat46 is True and not utils.IsPipelineArtemis(): continue if utils.IsReconfigInProgress(node): if getattr(p, 'id', None): obj = self.GetVpcObject(node, p.id) obj.ObjUpdate(p, clone=False) if not obj: obj = VpcObject(node, p, c, p.count) self.Objs[node].update({obj.VPCId: obj}) obj.GenerateChildren(p) if obj.IsUnderlayVPC(): EzAccessStoreClient[node].SetUnderlayVPC(obj) # Write the flow and nexthop config to agent hook file if utils.IsFlowInstallationNeeded(): self.__write_cfg(vpc_count) if utils.IsPipelineApulu(): # Associate Nexthop objects if utils.IsReconfigInProgress(node): return ipsec.encrypt_client.AssociateObjects(node) ipsec.decrypt_client.AssociateObjects(node) NhGroupClient.CreateAllocator(node) NhClient.AssociateObjects(node) NhGroupClient.AssociateObjects(node) tunnel.client.FillUnderlayNhGroups(node) route.client.FillNhGroups(node) tunnel.client.FillIpsecObjects(node) return
def CollectSvcTunnels(self): if utils.IsPipelineArtemis(): objs = EzAccessStoreClient[self.Node].GetSvcTunnels() if len(objs) != 0: self.SvcTunAllocator = utils.rrobiniter(objs) objs = EzAccessStoreClient[self.Node].GetSvcTunnels(True) if len(objs) != 0: self.RemoteSvcTunAllocator = utils.rrobiniter(objs)
def DeriveOperInfo(self, spec): # operational info useful for testspec routetype = self.RouteType self.HasDefaultRoute = True if 'default' in routetype else False self.VPCPeeringEnabled = True if 'vpc_peer' in routetype else False self.HasBlackHoleRoute = True if 'blackhole' in routetype else False self.HasNexthop = True if self.NEXTHOP else False self.TepType = getattr(spec, 'teptype', None) self.HasServiceTunnel = False if utils.IsPipelineArtemis(): if self.TUNNEL and self.TUNNEL.IsSvc(): self.HasServiceTunnel = True if self.HasBlackHoleRoute: self.NextHopType = "blackhole" elif self.VPCPeeringEnabled: self.NextHopType = "vpcpeer" else: if utils.IsPipelineArtemis() and \ self.HasServiceTunnel == False and self.HasNexthop: self.NextHopType = "nh" elif utils.IsPipelineApulu() and \ self.TepType == "overlay-ecmp": self.NextHopType = "nhg" else: self.NextHopType = "tep" self.NatLevel = None self.NatType = None self.ServiceNatPrefix = None svc_nat_prefix = getattr(spec, 'servicenatprefix', None) if svc_nat_prefix: self.ServiceNatPrefix = ipaddress.ip_network( svc_nat_prefix.replace('\\', '/')) self.DstNatIp = getattr(spec, 'dnatip', None) self.TwiceNatEnabled = self.DstNatIp != None natspec = getattr(spec, 'nat', None) if natspec: self.NatLevel = getattr(natspec, 'level', None) self.NatType = getattr(natspec, 'type', None) super().DeriveOperInfo() return
def PopulateSpec(self, grpcmsg): spec = grpcmsg.Request.add() spec.Id = self.GetKey() spec.IPKey.VPCId = self.VNIC.SUBNET.VPC.GetKey() utils.GetRpcIPAddr(self.IPAddr, spec.IPKey.IPAddr) for i in self.Tags: spec.Tags.append(i) spec.SubnetId = self.VNIC.SUBNET.GetKey() spec.VnicId = self.VNIC.GetKey() spec.MACAddr = self.VNIC.MACAddr.getnum() spec.PublicIP.Af = types_pb2.IP_AF_NONE if self.PublicIPAddr is not None: utils.GetRpcIPAddr(self.PublicIPAddr, spec.PublicIP) if utils.IsPipelineArtemis(): utils.GetRpcIPAddr(self.ProviderIPAddr, spec.ProviderIp) return
def __derive_nh_type_info(spec): routetype = spec.routetype if 'vpc_peer' in routetype: return 'vpcpeer' elif 'blackhole' in routetype: return 'blackhole' elif utils.IsPipelineArtemis(): # handle service tunnel case, return tep return "nh" elif utils.IsPipelineApulu(): if 'overlay-ecmp' in spec.teptype: return "nhg" else: return "tep" else: return "tep"
def PopulateSpec(self, grpcmsg): spec = grpcmsg.Request.add() spec.Id = self.GetKey() if self.TypeL2: spec.MACKey.MACAddr = self.MACAddr.getnum() spec.MACKey.SubnetId = self.SUBNET.GetKey() else: spec.IPKey.VPCId = self.SUBNET.VPC.GetKey() utils.GetRpcIPAddr(self.IPAddr, spec.IPKey.IPAddr) spec.SubnetId = self.SUBNET.GetKey() spec.TunnelId = self.TUNNEL.GetKey() spec.MACAddr = self.MACAddr.getnum() for i in self.Tags: spec.Tags.append(i) if utils.IsPipelineArtemis(): utils.GetRpcIPAddr(self.ProviderIPAddr, spec.ProviderIp) return
class Resmgr(base.ConfigObjectBase): #TODO: read from PDS header files / naples mem & init MAX_OPER = 1 MAX_UPGRADE = 1 MAX_DEVICE = 1 MAX_INTERFACE = 4 MAX_TUNNEL = 2048 if utils.IsPipelineApulu() else 1023 MAX_NEXTHOP = 4095 MAX_NEXTHOPGROUP = 2048 MAX_LMAPPING = 131072 MAX_RMAPPING = 2097152 MAX_VPC = 64 MAX_VNIC = 128 if utils.IsPipelineArtemis() or utils.IsPipelineApulu( ) else 64 MAX_HOST_INTERFACES = 8 if utils.IsPipelineApulu() else 2 # Apulu supports 8 lif for now and therefore cfg cannot have more than 8 subnets MAX_SUBNET = MAX_HOST_INTERFACES if utils.IsPipelineApulu() else 64 MAX_RULES_PER_V4_POLICY = 1023 MAX_RULES_PER_V6_POLICY = 15 if utils.IsPipelineArtemis(): MAX_POLICY = 1023 MAX_ROUTE_TABLE = 128 MAX_ROUTES_PER_ROUTE_TBL = 63 elif utils.IsPipelineApulu(): # TODO: init based on mem # 32 vnics, 32 subnets, 5 policies per vnic per direction, 1 policy per subnet per direction # ((32 * 5) * 2) + ((32 * 1) * 2) = 384 MAX_POLICY = 384 # 384 (8G) and 32 (4G) MAX_RULES_PER_V4_POLICY = 256 MAX_ROUTE_TABLE = 1024 # 1024 (8G) and 8 (4G) MAX_ROUTES_PER_ROUTE_TBL = 16383 # 1023 (8G) and 16383 (4G) else: MAX_POLICY = 1023 MAX_ROUTE_TABLE = 1024 MAX_ROUTES_PER_ROUTE_TBL = 1023 MAX_POLICY_PER_VNIC = 2 MAX_POLICER_PER_DIRECTION = 1024 MAX_SECURITY_PROFILE = 1 MAX_MIRROR = 8 MAX_TAG = 1 MAX_METER = 64 MAX_UNDERLAY_NHS = 2 MAX_OVERLAY_NHS = 8 MAX_DHCP_RELAY = 16 MAX_DHCP_PROXY = 16 MAX_NAT_PB = 1024 MAX_BGP_SESSIONS = 5 MAX_BGP_PEER_AF_SESSIONS = 5 MAX_BGP_PEERS = 10 MAX_BGP_EVPN_EVI = 50 MAX_BGP_EVPN_EVI_RT = 50 MAX_BGP_EVPN_IP_VRF = 50 MAX_BGP_EVPN_IP_VRF_RT = 50 MAX_IPSEC_SA = 1024 NICMGR_HOST_LIF_BASE = 72 NICMGR_HOST_LIF_COUNT = 1 # Starts VPC prefixes from 10/8 to 42/8 VPC_V4_PREFIX_BASE = 10 # Create overlapping prefixes for every 32 VPCs VPC_V4_PREFIX_OVERLAP_DIST = 32 # Starts VPC prefixes from aaaa:0001:0010/48 to aaaa:0001:00042/48 VPC_V6_BASE = 'aaaa:0001' VPC_V6_PREFIX_BASE = 10 # Create overlapping prefixes for every 32 VPCs VPC_V6_PREFIX_OVERLAP_DIST = 128 InvalidMplsSlotIdAllocator = iter(irange(50001, 90000)) InvalidVxlanIdAllocator = iter(irange(10001, 12000)) # This will be used to avoid overlap between topology and resource manager id allocation # used only for Tunnel, Nexthop and Interface objects BaseDuplicateIdAllocator = 100000 # TCP/UDP ports for flow and service mapping. Right now keeping it in resmgr. TransportSrcPort = 100 # For VNET packets TransportDstPort = 200 # For VNET packets TransportSvcPort = 400 # For VIP, Underlay tcp/udp port TransportSrcLBPort = 101 # Local backend service port, 101 mapped to 400 # Subnet address pools for multi node topology where same subnet exists on many nodes SubnetIPv4AddrPool = dict() SubnetIPv6AddrPool = dict() SubnetVRIPv4 = dict() SubnetVRIPv6 = dict() LocalMappingIdAllocator = iter(irange(1, 128 * 1024)) RemoteMappingIdAllocator = iter(irange(1, 16 * 1024 * 1024)) LocalMappingV4TagIdAllocator = iter(irange(1, 2 * 1024 * 1024)) LocalMappingV6TagIdAllocator = iter(irange(1, 2 * 1024 * 1024)) RemoteMappingV4TagIdAllocator = iter(irange(1, 2 * 1024 * 1024)) RemoteMappingV6TagIdAllocator = iter(irange(1, 2 * 1024 * 1024)) VnicMacAllocator = objects.TemplateFieldObject( "macstep/00DD.0000.0001/0000.0000.0001") def __init__(self, node): super().__init__() self.Node = node self.EpochAllocator = iter(irange(1, 4096)) # tunnel id=1 is mytep self.TunnelIdAllocator = iter(irange(2, 4096)) self.VpcIdAllocator = iter(irange(1, 1024)) self.SubnetIdAllocator = iter(irange(1, 1024)) self.FlowIdAllocator = iter(irange(1, 1 * 1024 * 1024)) self.VnicVlanIdAllocator = iter(irange(1, 1024)) self.VnicMplsSlotIdAllocator = iter(irange(10000, 11024)) self.VnicIdAllocator = iter(irange(1, 1024)) self.InterfaceIdAllocator = iter(irange(1, 66)) self.V4RouteTableIdAllocator = iter(irange(1, 1024)) self.V6RouteTableIdAllocator = iter(irange(10001, 11024)) self.RouteIdAllocator = iter(irange(1, 1024 * 1023)) self.V4SecurityPolicyIdAllocator = iter(irange(1, 2048)) self.V6SecurityPolicyIdAllocator = iter(irange(10001, 12048)) self.RuleIdAllocator = iter(irange(1, 1023 * 1023)) self.SecurityPolicyIdAllocator = iter(irange(1, 4 * 1024 * 1024)) self.VirtualRouterMacAllocator = objects.TemplateFieldObject( "macstep/00CC.0000.0001/0000.0000.0001") self.RemoteMappingMacAllocator = objects.TemplateFieldObject( "macstep/00EE.0000.0001/0000.0000.0001") self.TepIpAddressAllocator = ipaddress.IPv4Network( '172.16.0.0/16').hosts() self.TepIpv6AddressAllocator = ipaddress.IPv6Network( 'ffff::100:0/104').hosts() self.IGWMplsSlotIdAllocator = iter(irange(30001, 31024)) self.RemoteInternetNonNatTunAllocator = None self.RemoteInternetNatTunAllocator = None self.RemoteMplsVnicTunAllocator = None self.PublicIpAddressAllocator = ipaddress.IPv4Network( '200.0.0.0/16').hosts() self.PublicIpv6AddressAllocator = ipaddress.IPv6Network( 'eeee:0:0:0::/64').hosts() self.IGWVxlanIdAllocator = iter(irange(50001, 51024)) self.VxlanIdAllocator = iter(irange(80001, 81024)) self.MirrorSessionIdAllocator = iter(irange(1, 8)) self.PortIdAllocator = iter(irange(1, 4)) self.DhcpIdAllocator = iter(irange(1, 32)) self.NatPoolIdAllocator = iter(irange(1, 1000)) self.PolicerIdAllocator = iter(irange(1, 2048)) self.EvpnEviIdAllocator = iter(irange(1, 50)) self.EvpnEviRtIdAllocator = iter(irange(1, 50)) self.EvpnIpVrfIdAllocator = iter(irange(1, 50)) self.EvpnIpVrfRtIdAllocator = iter(irange(1, 50)) self.IpsecTunAllocator = None self.IpsecTunnelModeTunAllocator = None self.IpsecTransportModeTunAllocator = None self.IpsecEncryptSAIdAllocator = iter(irange(1, 1000)) self.IpsecDecryptSAIdAllocator = iter(irange(1, 1000)) self.IpsecTunnelAddressAllocator = ipaddress.IPv4Network( '205.10.0.0/16').hosts() # --------------------------------------------------------------------------------- # Artemis specific configs # Nexthop IP allocator. Curently unique IP (globally) # TODO : Can have same IP across VPCs. self.NexthopIdAllocator = iter(irange(1, 1 * 1024 * 1024)) self.NexthopIpV4AddressAllocator = ipaddress.IPv4Network( '210.0.0.0/16').hosts() self.NexthopIpV6AddressAllocator = ipaddress.IPv6Network( 'eeee:eeee:0:0::/64').hosts() self.NexthopMacAllocator = objects.TemplateFieldObject( "macstep/0055.0000.0001/0000.0000.0001") self.NexthopGroupIdAllocator = iter(irange(1, 1 * 1024)) self.V4TagIdAllocator = iter(irange(1, 1)) self.V6TagIdAllocator = iter(irange(2, 2)) self.NexthopVxlanIdAllocator = iter(irange(90001, 91024)) self.V4MeterIdAllocator = iter(irange(1, 64)) self.V6MeterIdAllocator = iter(irange(65, 129)) # Currently one to one mapping with CA-IP. TODO. Many to one self.SvcMappingPublicIpV4AddressAllocator = ipaddress.IPv4Network( '150.0.0.0/16').hosts() self.SvcMappingPublicIpV6AddressAllocator = ipaddress.IPv6Network( 'eeee:dddd:dddd:0::/64').hosts() self.NexthopVlanIdAllocator = iter(irange(4001, 5124)) # Provider IP for local and remote. One to One mapping now. Many to one can be done later self.ProviderIpV4Network = '220.0.0.0/8' self.ProviderIpV6Network = 'eeee:eeee:eee0:0::/64' self.ProviderIpV4Network = ipaddress.IPv4Network( self.ProviderIpV4Network) self.ProviderIpV6Network = ipaddress.IPv6Network( self.ProviderIpV6Network) self.ProviderIpV4AddressAllocator = ipaddress.IPv4Network( self.ProviderIpV4Network).hosts() self.ProviderIpV6AddressAllocator = ipaddress.IPv6Network( self.ProviderIpV6Network).hosts() self.VpcVxlanIdAllocator = iter(irange(50000, 51024)) self.Nat46Address = ipaddress.IPv6Network('aaaa:aaaa:0:0::/64') self.TepMacAllocator = objects.TemplateFieldObject( "macstep/0065.0000.0001/0000.0000.0001") # Public IP adddress in the underlay VC self.SvcMappingPublicIpV4AddressAllocator = ipaddress.IPv4Network( '150.0.0.0/16').hosts() self.SvcMappingPublicIpV6AddressAllocator = ipaddress.IPv6Network( 'eeee:dddd:dddd:0::/64').hosts() # ------------------------------------------------------------------- self.SvcTunAllocator = None self.RemoteSvcTunAllocator = None self.UnderlayTunAllocator = None self.UnderlayECMPTunAllocator = None self.OverlayNhGroupAllocator = None self.RemoteSvcTunIPv4Addr = ipaddress.IPv4Network( '30.0.0.0/24').hosts() #Apulu specific configs self.UnderlayNHAllocator = None self.OverlayNHAllocator = None self.DualEcmpNhAllocator = None self.UnderlayNhGroupAllocator = None self.DualEcmpNhGroupAllocator = None self.DhcpRelayAllocator = None self.IpsecEncryptSAAllocator = None self.IpsecDecryptSAAllocator = None self.DeviceMacAllocator = objects.TemplateFieldObject( "macstep/0002.0100.0000/0000.0000.0001") self.NumVnicPolicyAllocator = utils.rrobiniter( range(Resmgr.MAX_POLICY_PER_VNIC + 1)) self.UnderlayNumNexthopsAllocator = utils.rrobiniter( range(1, Resmgr.MAX_UNDERLAY_NHS + 1)) self.OverlayNumNexthopsAllocator = utils.rrobiniter( range(1, Resmgr.MAX_OVERLAY_NHS + 1)) self.L3InterfaceIPv4PfxPool = iter( ipaddress.IPv4Network('40.40.0.0/16').subnets(new_prefix=24)) # Host interface configs self.HostMemoryAllocator = None self.HostIfs = dict() # Host interface index allocator for IOTA. # Ifindices 72 and 73 (0x48, 0x49) are reserved, so we have a non-contiuous list #TODO: Fix it properly later HostIfIdxList = [ 0x80000047, 0x8000004A, 0x8000004B, 0x8000004C, 0x8000004D, 0x8000004E, 0x8000004F, 0x80000050 ] self.HostIfIdxAllocator = iter(HostIfIdxList) self.LoopbackIfIdAllocator = iter(irange(1, 16)) # Metaswitch self.BgpIdAllocator = iter(irange(1, 10)) self.BgpPeerIdAllocator = iter(irange(1, 10)) self.BgpPeerAfIdAllocator = iter(irange(1, 10)) return def Show(self): return def ReadHostInterfaceInfo(self): if utils.IsDryRun(): return # reads nicmgr.log and get interface info nicmgrlog = utils.GetNicmgrLogPath() f = open(nicmgrlog, "r") for ifobj in self.HostIfs.values(): # get lifbase and count pattern = ' %s: lif_base (\w+) lif_count (\w+)' % (ifobj.IfName) for line in f: match = re.search(pattern, line) if match is None: continue lifbase = int(match.groups()[0]) lifcount = int(match.groups()[1]) ifobj.SetLifBase(lifbase) ifobj.SetLifCount(lifcount) break # get devcmd addr pattern = ' %s: regs_mem_addr (\w+) devcmd_mem_addr (\w+)' % ( ifobj.IfName) for line in f: match = re.search(pattern, line) if match is None: continue devcmdaddr = int(match.groups()[1], base=16) ifobj.SetDevCmdAddr(devcmdaddr) break # get qstate addr for all lifs under this device for i in range(lifcount): lif_id = lifbase + i pattern = ' lif-%d: qtype: (\d{1}), qstate_base: (\w+)' % ( lif_id) for line in f: match = re.search(pattern, line) if match is None: continue q_type = int(match.groups()[0]) qstate_base = int(match.groups()[1], base=16) qstateaddr_list = ifobj.Lif2QstateMap.get(lif_id, []) qstateaddr_list.insert(q_type, qstate_base) ifobj.Lif2QstateMap.update({lif_id: qstateaddr_list}) if (q_type == 7): break f.close() return def InitializeHostMemMgr(self): if utils.IsDryRun(): return self.HostMemoryAllocator = objects.GetHostMemMgrObject() assert self.HostMemoryAllocator is not None def InitializeHostInterfaces(self): if not utils.IsDol(): return with open(utils.GetDeviceJsonPath(), 'r') as fp: obj = json.load(fp) lifbase = Resmgr.NICMGR_HOST_LIF_BASE lifcount = Resmgr.NICMGR_HOST_LIF_COUNT # read host interface info from device.json for ethdev in obj["eth_dev"]: if ethdev["type"] != 'host': continue ifname = ethdev["name"] intf = NicmgrInterface(ifname) intf.SetLifBase(lifbase) self.HostIfs.update({ifname: intf}) lifbase += lifcount if utils.IsInterfaceSupported(): self.InitializeHostMemMgr() self.ReadHostInterfaceInfo() def Initialize(self): self.InitializeHostInterfaces() def CreateInternetTunnels(self): objs = EzAccessStoreClient[self.Node].GetIgwNonNatTunnels() if len(objs) != 0: self.RemoteInternetNonNatTunAllocator = utils.rrobiniter(objs) objs = EzAccessStoreClient[self.Node].GetIgwNatTunnels() if len(objs) != 0: self.RemoteInternetNatTunAllocator = utils.rrobiniter(objs) def CollectSvcTunnels(self): if utils.IsPipelineArtemis(): objs = EzAccessStoreClient[self.Node].GetSvcTunnels() if len(objs) != 0: self.SvcTunAllocator = utils.rrobiniter(objs) objs = EzAccessStoreClient[self.Node].GetSvcTunnels(True) if len(objs) != 0: self.RemoteSvcTunAllocator = utils.rrobiniter(objs) def CreateVnicTunnels(self): objs = EzAccessStoreClient[self.Node].GetWorkloadTunnels() if len(objs) != 0: self.RemoteMplsVnicTunAllocator = utils.rrobiniter(objs) def CreateUnderlayTunnels(self): objs = EzAccessStoreClient[self.Node].GetUnderlayTunnels() if len(objs) != 0: self.UnderlayTunAllocator = utils.rrobiniter(objs) objs = EzAccessStoreClient[self.Node].GetUnderlayTunnels(ecmp=True) if len(objs) != 0: self.UnderlayECMPTunAllocator = utils.rrobiniter(objs) def CreateUnderlayNHAllocator(self): objs = EzAccessStoreClient[self.Node].GetUnderlayNexthops() if len(objs) != 0: self.UnderlayNHAllocator = utils.rrobiniter(objs) def CreateOverlayNHAllocator(self): objs = EzAccessStoreClient[self.Node].GetOverlayNexthops() if len(objs) != 0: self.OverlayNHAllocator = utils.rrobiniter(objs) def CreateDualEcmpNhAllocator(self): objs = EzAccessStoreClient[self.Node].GetDualEcmpNexthops() if len(objs) != 0: self.DualEcmpNhAllocator = utils.rrobiniter(objs) def CreateUnderlayNhGroupAllocator(self): objs = EzAccessStoreClient[self.Node].GetUnderlayNhGroups() if len(objs) != 0: self.UnderlayNhGroupAllocator = utils.rrobiniter(objs) def CreateOverlayNhGroupAllocator(self): objs = EzAccessStoreClient[self.Node].GetOverlayNhGroups() if len(objs) != 0: self.OverlayNhGroupAllocator = utils.rrobiniter(objs) def CreateDualEcmpNhGroupAllocator(self): objs = EzAccessStoreClient[self.Node].GetDualEcmpNhGroups() if len(objs) != 0: self.DualEcmpNhGroupAllocator = utils.rrobiniter(objs) def CreateDHCPRelayAllocator(self): objs = EzAccessStoreClient[self.Node].GetDhcpRelayObjects() if len(objs) != 0: self.DhcpRelayAllocator = utils.rrobiniter(objs) def CreateDHCPProxyAllocator(self): objs = EzAccessStoreClient[self.Node].GetDhcpProxyObjects() if len(objs) != 0: self.DhcpProxyAllocator = utils.rrobiniter(objs) def CreateIpsecTunnels(self): objs = EzAccessStoreClient[self.Node].GetIpsecTunnels() if len(objs) != 0: self.IpsecTunAllocator = utils.rrobiniter(objs) def CreateIpsecTunnelModeTunnels(self): objs = EzAccessStoreClient[self.Node].GetIpsecTunnelModeTunnels() if len(objs) != 0: self.IpsecTunnelModeTunAllocator = utils.rrobiniter(objs) def CreateIpsecTransportModeTunnels(self): objs = EzAccessStoreClient[self.Node].GetIpsecTransportModeTunnels() if len(objs) != 0: self.IpsecTransportModeTunAllocator = utils.rrobiniter(objs) def CreateIpsecEncryptSAAllocator(self): objs = EzAccessStoreClient[self.Node].GetIpsecEncryptSAs() if len(objs) != 0: self.IpsecEncryptSAAllocator = utils.rrobiniter(objs) def CreateIpsecDecryptSAAllocator(self): objs = EzAccessStoreClient[self.Node].GetIpsecDecryptSAs() if len(objs) != 0: self.IpsecDecryptSAAllocator = utils.rrobiniter(objs) # Create subnets from base prefix # - base is a prefix in the form of '10.0.0.0/16' # - sublen is the subnet length, gt base prefix length. # - poolid , subnet pool index with in a vpc @staticmethod def CreateIPv4SubnetPool(base, sublen, poolid): assert (isinstance(base, ipaddress.IPv4Network)) assert (sublen >= 10) assert (poolid < 16) addr = base.network_address + (poolid << (32 - 8)) pfxstr = "%s/8" % (str(ipaddress.IPv4Address(addr))) base = ipaddress.IPv4Network(pfxstr) return iter(base.subnets(new_prefix=sublen)) @staticmethod def CreateIPv6SubnetPool(base, sublen, poolid): assert (isinstance(base, ipaddress.IPv6Network)) assert (sublen >= 64) assert (poolid < 16) addr = base.network_address + (poolid << (128 - 56)) pfxstr = "%s/56" % (str(ipaddress.IPv6Address(addr))) base = ipaddress.IPv6Network(pfxstr) return iter(base.subnets(new_prefix=sublen)) @staticmethod def CreateIpv4AddrPool(subnet): assert (isinstance(subnet, ipaddress.IPv4Network)) return iter(subnet.hosts()) @staticmethod def CreateIpv6AddrPool(subnet): assert (isinstance(subnet, ipaddress.IPv6Network)) return iter(subnet.hosts()) @staticmethod def CreateIPv4AddrPoolForSubnet(subnet_id, prefix): if subnet_id in Resmgr.SubnetIPv4AddrPool: return assert (isinstance(prefix, ipaddress.IPv4Network)) Resmgr.SubnetIPv4AddrPool[subnet_id] = iter(prefix.hosts()) # store first IP as VRIP Resmgr.SubnetVRIPv4[subnet_id] = next( Resmgr.SubnetIPv4AddrPool[subnet_id]) return @staticmethod def CreateIPv6AddrPoolForSubnet(subnet_id, prefix): if subnet_id in Resmgr.SubnetIPv6AddrPool: return assert (isinstance(prefix, ipaddress.IPv6Network)) Resmgr.SubnetIPv6AddrPool[subnet_id] = iter(prefix.hosts()) # store first IP as VRIP Resmgr.SubnetVRIPv6[subnet_id] = next( Resmgr.SubnetIPv6AddrPool[subnet_id]) return @staticmethod def GetIPv4AddrFromSubnetPool(subnet_id): if subnet_id in Resmgr.SubnetIPv4AddrPool: return next(Resmgr.SubnetIPv4AddrPool[subnet_id]) else: return None @staticmethod def GetIPv6AddrFromSubnetPool(subnet_id): if subnet_id in Resmgr.SubnetIPv6AddrPool: return next(Resmgr.SubnetIPv6AddrPool[subnet_id]) else: return None @staticmethod def GetSubnetVRIPv4(subnet_id): if subnet_id in Resmgr.SubnetVRIPv4: return Resmgr.SubnetVRIPv4[subnet_id] else: return None @staticmethod def GetSubnetVRIPv6(subnet_id): if subnet_id in Resmgr.SubnetVRIPv6: return Resmgr.SubnetVRIPv6[subnet_id] else: return None # The below function will be called for every Remote TEP @staticmethod def CreateRemoteVnicMplsSlotAllocator(): mplsbase = 20000 return iter(irange(mplsbase, mplsbase + 1027)) # 1M Remote Mappings/1022 Teps # The below function will be called for every Remote TEP @staticmethod def CreateRemoteVnicVxlanIdAllocator(): vxlanbase = 30000 return iter(irange(vxlanbase, vxlanbase + 1027)) # 1M Remote Mappings/1022 Teps @staticmethod def GetVpcIPv4Prefix(vpcid): pfxstr = '%d.0.0.0/8' % ((vpcid % Resmgr.VPC_V4_PREFIX_OVERLAP_DIST) + Resmgr.VPC_V4_PREFIX_BASE) return ipaddress.IPv4Network(pfxstr) @staticmethod def GetVpcIPv6Prefix(vpcid): pfxstr = '%s:%04x::/48' % (Resmgr.VPC_V6_BASE, ( (vpcid % Resmgr.VPC_V6_PREFIX_OVERLAP_DIST) + Resmgr.VPC_V6_PREFIX_BASE)) return ipaddress.IPv6Network(pfxstr) @staticmethod def GetVpcInternetNatPoolPfx(vpcid): pfxstr = '50.5.%d.0/24' % (vpcid) return ipaddress.IPv4Network(pfxstr) @staticmethod def GetVpcInfraNatPoolPfx(vpcid): pfxstr = '10.%d.199.0/24' % (vpcid) return ipaddress.IPv4Network(pfxstr) @staticmethod def GetNatPoolPortRange(proto): if proto == 'icmp': return 0, 0 return 10000, 20000
def __isObjSupported(): if utils.IsPipelineArtemis() or utils.IsPipelineApulu(): return True return False