def GetMatchingConfigObjects(self, selectors): objs = [] fwdmode = None mapsel = selectors key = 'FwdMode' # Consider it only if TEST is for MAPPING if mapsel.flow.GetValueByKey('FlType') != 'MAPPING': return objs # Get the forwarding mode, fwdmode is not applicable for local & remote fwdmode = mapsel.flow.GetValueByKey(key) mapsel.flow.filters.remove((key, fwdmode)) rmapsel = copy.deepcopy(mapsel) assert (fwdmode == 'VNET' or fwdmode == 'IGW' or fwdmode == 'SVCTUN' or\ fwdmode == 'SVCTUN_REMOTE') == True dutNode = EzAccessStore.GetDUTNode() if fwdmode == 'VNET': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): for robj in rmapping.GetMatchingObjects(rmapsel, dutNode): # Ignore VPC-ID 1 , Reserved for substrate if lobj.VNIC.SUBNET.VPC.VPCId == 1 or robj.SUBNET.VPC.VPCId == 1: continue if lobj.VNIC.SUBNET.VPC.VPCId != robj.SUBNET.VPC.VPCId: continue obj = FlowMapObject(lobj, robj, fwdmode, None) objs.append(obj) return utils.GetFilteredObjects(objs, selectors.maxlimits) elif fwdmode == 'IGW': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj) objs.append(obj) return utils.GetFilteredObjects(objs, selectors.maxlimits) elif fwdmode == 'SVCTUN' or fwdmode == 'SVCTUN_REMOTE': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): vpc = lobj.VNIC.SUBNET.VPC if vpc.Nat46_pfx is not None: for routetblobj in routetable.GetAllMatchingObjects( mapsel): if fwdmode == 'SVCTUN_REMOTE': if routetblobj.TUNNEL.Remote is False: continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj) objs.append(obj) return utils.GetFilteredObjects(objs, selectors.maxlimits) else: assert 0
def GetMatchingObjects(selectors): nodes = list(client.Objs.values()) objs = [] for obj in nodes: if IsFilterMatch(obj, selectors): objs.append(obj) return utils.GetFilteredObjects(objs, selectors.maxlimits)
def GetMatchingConfigObjects(self, selectors): objs = [] policyobjs = filter(lambda x: x.IsFilterMatch(selectors), policy.client.Objects()) for policyObj in policyobjs: for lobj in lmapping.client.Objects(): if self.__is_lmapping_match(policyObj, lobj): policyObj.l_obj = lobj objs.append(policyObj) break return utils.GetFilteredObjects(objs, selectors.maxlimits, False)
def GetMatchingConfigObjects(self, selectors, all_objs): objs = [] rtype = selectors.route.GetValueByKey('RouteType') for route_obj in route.client.Objects(): if not route_obj.IsFilterMatch(selectors): continue if rtype != 'empty' and 0 == len(route_obj.routes): # skip route tables with no routes continue for lobj in lmapping.GetMatchingObjects(selectors): if self.__is_lmapping_match(route_obj, lobj): route_obj.l_obj = lobj objs.append(route_obj) break if all_objs is True: maxlimits = 0 else: maxlimits = selectors.maxlimits return utils.GetFilteredObjects(objs, maxlimits, False)
def GetMatchingObjects(selectors): dutNode = EzAccessStore.GetDUTNode() upgradeobjs = [EzAccessStoreClient[dutNode].GetUpgrade()] return utils.GetFilteredObjects(upgradeobjs, selectors.maxlimits, False)
def GetMatchingConfigObjects(self, selectors): objs = [] fwdmode = None ipsecmode = None mapsel = copy.deepcopy(selectors) key = 'FwdMode' # Consider it only if TEST is for MAPPING if mapsel.flow.GetValueByKey('FlType') != 'MAPPING': return objs # Get the forwarding mode, fwdmode is not applicable for local & remote fwdmode = mapsel.flow.GetValueByKey(key) mapsel.flow.filters.remove((key, fwdmode)) ipsecmode = mapsel.flow.GetValueByKey('IpsecMode') if ipsecmode: mapsel.flow.filters.remove(('IpsecMode', ipsecmode)) # Get the local2local info. key = 'L2LType' l2l = mapsel.flow.GetValueByKey(key) if l2l != None: mapsel.flow.filters.remove((key, l2l)) # Src and Dst check is not applicable for remote rmapsel = copy.deepcopy(mapsel) key = 'SourceGuard' value = rmapsel.flow.GetValueByKey(key) if value != None: rmapsel.flow.filters.remove((key, value)) assert (fwdmode == 'L2' or fwdmode == 'L3' or fwdmode == 'IGW' or \ fwdmode == 'IGW_NAT' or fwdmode == 'VPC_PEER' or \ fwdmode == 'POLICY' or fwdmode == 'L2L' or \ fwdmode == 'IGW_NAPT' or fwdmode == 'IGW_NAPT_SERVICE') == True selected_objs = [] if topo.ChosenFlowObjs.use_selected_objs == True and len( topo.ChosenFlowObjs.objs) != 0: matching_flows = topo.ChosenFlowObjs.GetMatchingFlowObjects( selectors) selected_objs = utils.GetFilteredObjects( matching_flows, topo.ChosenFlowObjs.GetMaxLimits()) maxlimits = selectors.maxlimits - len(selected_objs) if maxlimits <= 0: return utils.GetFilteredObjects(selected_objs, selectors.maxlimits) else: maxlimits = selectors.maxlimits dutNode = EzAccessStore.GetDUTNode() if fwdmode == 'VPC_PEER': rmappings = rmapping.GetMatchingObjects(mapsel, dutNode) lmappings = lmapping.GetMatchingObjects(mapsel, dutNode) for routetblobj in routetable.GetAllMatchingObjects(mapsel): if routetblobj.IsNatEnabled(): # Skip IGWs with nat flag set to True continue lmappingobjs = filter( lambda x: self.__is_lmapping_match(routetblobj, x), lmappings) rmappingobjs = filter( lambda x: self.__is_rmapping_match(routetblobj, x), rmappings) for robj in rmappingobjs: for lobj in lmappingobjs: obj = FlowMapObject(lobj, robj, fwdmode, routetblobj, robj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == 'IGW': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue if routetblobj.IsNatEnabled(): # Skip IGWs with nat flag set to True continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj, routetblobj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == 'IGW_NAT': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): if hasattr(lobj, "PublicIP") == False: continue for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue if not routetblobj.IsNatEnabled(): # Skip IGWs without nat flag set to True continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj, routetblobj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == 'IGW_NAPT': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): if hasattr(lobj, "PublicIP") == True: # skip VNICs which have floating IP continue for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue if not routetblobj.IsNatEnabled(): # Skip IGWs without nat flag set to True continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj, routetblobj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == 'IGW_NAPT_SERVICE': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): if hasattr(lobj, "PublicIP") == True: # skip VNICs which have floating IP continue for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj, routetblobj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == 'POLICY': for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): for routetblobj in routetable.GetAllMatchingObjects(mapsel): if not self.__is_lmapping_match(routetblobj, lobj): continue obj = FlowMapObject(lobj, None, fwdmode, routetblobj, routetblobj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) elif fwdmode == "L2L": lobjs = lmapping.GetMatchingObjects(mapsel, dutNode) if l2l == 'VPC_PEER': for routetblobj in routetable.GetAllMatchingObjects(mapsel): smappingobjs = filter( lambda x: self.__is_lmapping_match(routetblobj, x), lobjs) dmappingobjs = filter( lambda x: self.__is_lmapping_extract( routetblobj.PeerVPCId, x), lobjs) for s in smappingobjs: for d in dmappingobjs: obj = FlowMapObject(s, d, fwdmode) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) objs = utils.GetFilteredObjects(objs, maxlimits) utils.MergeFilteredObjects(objs, selected_objs) return objs for s in lobjs: if not self.__is_lmapping_valid(s): continue for d in lobjs: if not self.__is_lmapping_valid(d): continue if s.MappingId == d.MappingId: continue if l2l == 'SAME_VNIC': # Select ips from same vnic. if s.VNIC.VnicId != d.VNIC.VnicId: continue elif l2l == 'SAME_SUBNET': # Select ips from same subnet but different vnic if s.VNIC.VnicId == d.VNIC.VnicId: continue if s.VNIC.SUBNET.SubnetId != d.VNIC.SUBNET.SubnetId: continue elif l2l == 'SAME_VPC': # Select ips from different subnet in a VPC if s.VNIC.SUBNET.SubnetId == d.VNIC.SUBNET.SubnetId: continue if s.VNIC.SUBNET.VPC.VPCId != d.VNIC.SUBNET.VPC.VPCId: continue obj = FlowMapObject(s, d, fwdmode) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) else: for lobj in lmapping.GetMatchingObjects(mapsel, dutNode): if not self.__is_lmapping_valid(lobj): continue for robj in rmapping.GetMatchingObjects(rmapsel, dutNode): if lobj.VNIC.SUBNET.VPC.VPCId != robj.SUBNET.VPC.VPCId: continue # Select mappings from the same subnet if L2 is set if fwdmode == 'L2': if lobj.VNIC.SUBNET.SubnetId != robj.SUBNET.SubnetId: continue else: if lobj.VNIC.SUBNET.SubnetId == robj.SUBNET.SubnetId: continue if ipsecmode: if 'TUNNEL' in ipsecmode and \ not robj.TUNNEL.IsIpsecTunnelMode(): continue elif 'TRANSPORT' in ipsecmode and \ not robj.TUNNEL.IsIpsecTransportMode(): continue obj = FlowMapObject(lobj, robj, fwdmode, tunobj=robj.TUNNEL) if IsAlreadySelected(obj, selected_objs): continue objs.append(obj) objs = utils.GetFilteredObjects(objs, maxlimits) utils.MergeFilteredObjects(objs, selected_objs) return objs