def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if utils.IsPipelineApulu(): if self.UseHostIf and self.HostIfUuid: if (utils.GetYamlSpecAttr( spec, 'hostif')) != self.HostIfUuid.GetUuid(): return False elif self.UseHostIf and self.SUBNET.HostIfUuid: if (utils.GetYamlSpecAttr( spec, 'hostif')) != self.SUBNET.HostIfUuid[0].GetUuid(): return False if not utils.IsBitwSmartSvcMode(self.Node): if spec['macaddress'] != self.MACAddr.getnum(): return False if spec['sourceguardenable'] != self.SourceGuard: return False if utils.GetYamlSpecAttr(spec, 'v4meterid') != utils.PdsUuid.GetUUIDfromId( self.V4MeterId, api.ObjectTypes.METER): return False if utils.GetYamlSpecAttr(spec, 'v6meterid') != utils.PdsUuid.GetUUIDfromId( self.V6MeterId, api.ObjectTypes.METER): return False return True
def ValidateLearntMacEntries(self, node, ret, cli_op): if utils.IsDryRun(): return True if not ret: logger.error("pdsctl show learn mac cmd failed") return False # split output per object mac_entries = cli_op.split("---") for mac in mac_entries: yamlOp = utils.LoadYaml(mac) if not yamlOp: continue yamlOp = yamlOp['macentry']['entryauto'] mac_key = yamlOp['key']['macaddr'] subnet_uuid = utils.GetYamlSpecAttr(yamlOp['key'], 'subnetid') vnic_uuid_str = utils.List2UuidStr( utils.GetYamlSpecAttr(yamlOp, 'vnicid')) # verifying if the info learnt is expected from config vnic_obj = self.GetVnicByL2MappingKey(node, mac_key, subnet_uuid, 0) if vnic_obj == None: logger.error( f"vnic not found in client object store for key {mac_key} {subnet_uuid}{0}" ) return False # verifying if VNIC has been programmed correctly by Learn args = "--id " + vnic_uuid_str ret, op = utils.RunPdsctlShowCmd(node, "vnic", args, True) if not ret: logger.error(f"show vnic failed for vnic id {vnic_uuid_str}") return False cmdop = op.split("---") logger.info("Num entries returned for vnic show id %s is %s" % (vnic_uuid_str, (len(cmdop) - 1))) for vnic_entry in cmdop: yamlOp = utils.LoadYaml(vnic_entry) if not yamlOp: continue vnic_spec = yamlOp['spec'] hostif = vnic_spec['hostif'] if utils.PdsUuid( hostif).GetUuid() != vnic_obj.HostIfUuid.GetUuid(): logger.error( f"host interface did not match for {vnic_uuid_str}") return False if vnic_spec['macaddress'] != vnic_obj.MACAddr.getnum(): logger.error( f"mac address did not match for {vnic_uuid_str}") return False logger.info( "Found VNIC %s entry for learn MAC MAC:%s, Subnet:%s, VNIC:%s " % (utils.List2UuidStr(utils.GetYamlSpecAttr( vnic_spec, 'id')), vnic_obj.MACAddr.get(), vnic_obj.SUBNET.UUID, vnic_uuid_str)) return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if not self.__validate_direction(spec['direction']): return False policer = spec.get('policer', None) if not policer: return False if self.type == 'bps': bpspolicer = policer.get('bpspolicer', None) if not bpspolicer: return False exp_rate = int(self.rate/self.token_refresh_rate) * self.token_refresh_rate if (bpspolicer['bytespersecond'] != exp_rate) or\ (bpspolicer['burst'] != self.burst): return False else: ppspolicer = policer.get('ppspolicer', None) if not ppspolicer: return False exp_rate = int(self.rate/self.token_refresh_rate) * self.token_refresh_rate if (ppspolicer['packetspersecond'] != exp_rate) or\ (ppspolicer['burst'] != self.burst): return False return True
def ValidateYamlSpec(self, spec): if self.IsOriginFixed() and utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec[ 'conntracken' ] != self.ConnTrackEn: return False if self.DefaultFWAction == types_pb2.SECURITY_RULE_ACTION_NONE: if spec[ 'defaultfwaction' ] != types_pb2.SECURITY_RULE_ACTION_DENY: return False else: if spec[ 'defaultfwaction' ] != self.DefaultFWAction: return False if spec[ 'tcpidletimeout' ] != self.TCPIdleTimeout: return False if spec[ 'udpidletimeout' ] != self.UDPIdleTimeout: return False if spec[ 'icmpidletimeout' ] != self.ICMPIdleTimeout: return False if spec[ 'otheridletimeout' ] != self.OtherIdleTimeout: return False if spec[ 'tcpcnxnsetuptimeout' ] != self.TCPCnxnSetupTimeout: return False if spec[ 'tcphalfclosetimeout' ] != self.TCPHalfCloseTimeout: return False if spec[ 'tcpclosetimeout' ] != self.TCPCloseTimeout: return False if spec[ 'tcpdroptimeout' ] != self.TCPDropTimeout: return False if spec[ 'udpdroptimeout' ] != self.UDPDropTimeout: return False if spec[ 'icmpdroptimeout' ] != self.ICMPDropTimeout: return False if spec[ 'otherdroptimeout' ] != self.OtherDropTimeout: return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec['protocol'] != self.ProtoNum: return False ports = spec['ports'] if ports['portlow'] != self.PortLo: return False if ports['porthigh'] != self.PortHi: return False return True
def VerifyLearntIpEntries(self, node, ret, cli_op): if utils.IsDryRun(): return True if not ret: logger.error("pdsctl show learn ip cmd failed") return False # split output per object ip_entries = cli_op.split("---") for ip in ip_entries: yamlOp = utils.LoadYaml(ip) if not yamlOp: continue ip = yamlOp['key']['ipaddr']['v4orv6']['v4addr'] ip_str = utils.Int2IPAddrStr(ip) vpc_uuid = utils.GetYamlSpecAttr(yamlOp['key'], 'vpcid') vpc_uuid_str = utils.List2UuidStr(vpc_uuid) subnet_uuid = utils.GetYamlSpecAttr(yamlOp['macinfo'], 'subnetid') mac_str = utils.Int2MacStr(yamlOp['macinfo']['macaddr']) # verifying if the info learnt is expected from config lmap_obj = self.GetLMapObjByEpIpKey(node, ip_str, vpc_uuid) if lmap_obj == None: logger.error(f"lmap not found in client object store for key {vpc_uuid_str}, {ip_str}") return False # verifying if the EP is from local mapping. args = " | grep " + vpc_uuid_str + " | grep " + ip_str + " | grep " + mac_str ret, op = utils.RunPdsctlShowCmd(node, "mapping internal local", args, False) if not ret: logger.error(f"show mapping internal local failed for VPC id {vpc_uuid_str}, IP {ip_str}") return False cmdop = op.split('\n') if not len(cmdop): logger.error("No (%s) entries found in lmap show VPC id %s, IP %s "%( len(cmdop), vpc_uuid_str, ip_str)) return False logger.info("Found (%s) LMAP entry for learn IP:%s, VPC:%s MAC:%s, Subnet:%s "%( (len(cmdop)-1), ip_str, vpc_uuid_str, mac_str, utils.List2UuidStr(subnet_uuid))) return True
def VerifyLearntIpEntriesWithRemoteMapping(self, node, peer_node, ret, cli_op): if utils.IsDryRun(): return True if not ret: logger.error("pdsctl show learn ip cmd failed for %s" % peer_node) return False # split output per object ip_entries = cli_op.split("---") for ip in ip_entries: yamlOp = utils.LoadYaml(ip) if not yamlOp: continue yamlOp = yamlOp['ipentry']['entryauto'] ip = yamlOp['key']['ipaddr']['v4orv6']['v4addr'] ip_str = utils.Int2IPAddrStr(ip) vpc_uuid = utils.GetYamlSpecAttr(yamlOp['key'], 'vpcid') subnet_uuid = utils.GetYamlSpecAttr(yamlOp['macinfo'], 'subnetid') mac = yamlOp['macinfo']['macaddr'] if not self.ValidateRemoteMappingInfo(node, ip_str, vpc_uuid, mac, subnet_uuid): return False return True
def CheckLifStatus(yaml_output, if_name, status): result = api.types.status.SUCCESS lif_entries = yaml_output.split("---") lif_uuid = None for lif in lif_entries: yamlOp = yaml.load(lif, Loader=yaml.FullLoader) if not yamlOp: continue if yamlOp['spec']['type'] != types_pb2.LIF_TYPE_HOST: continue if if_name == yamlOp['status']['name'] and \ status != yamlOp['status']['adminstate']: result = api.types.status.FAILURE lif_uuid = yaml_utils.List2UuidStr( yaml_utils.GetYamlSpecAttr(yamlOp['spec'], 'id')) break return result, lif_uuid
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec['af'] != utils.GetRpcIPAddrFamily(self.AddrFamily): return False if spec['priorityen'] != (self.PriorityType != None): return False if not utils.IsPipelineApulu(): # routes are not stored in other pipelines, so return return True # validate routes specRoutes = spec['routes'] if len(self.routes.values()) != len(specRoutes): return False for specRoute in specRoutes: key = utils.PdsUuid.GetIdfromUUID(specRoute['id']) route = self.routes.get(key, None) if not route: return False if not route.ValidateYamlSpec(specRoute): return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec['snaplen'] != self.SnapLen: return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec['protocol'] != self.Protocol: return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.GetKey(): return False if spec['af'] != utils.GetRpcIPAddrFamily(self.AddrFamily): return False return True
def ValidateYamlSpec(self, spec): if utils.GetYamlSpecAttr(spec) != self.UUID.GetUuid(): return False if spec['attrs']['nataction']['srcnataction'] != self.SNatAction: return False return True