Exemple #1
0
    def ValidateRemoteMappingInfo(self, node, ip_str, vpc_uuid, mac,
                                  subnet_uuid):
        # verifying if the info learnt is expected from the dol object
        rmap_obj = self.GetRMapObjByEpIpKey(node, ip_str, vpc_uuid)
        if rmap_obj == None:
            logger.error(f"rmap not found in client object store "
                         f"in {node} for key {vpc_uuid_str} {ip_str}")
            return False

        vpc_uuid_str = utils.List2UuidStr(vpc_uuid)
        mac_str = utils.Int2MacStr(mac)

        # verifying if Remote mapping is present for learnt IP from a peer node.
        args = " --type l3"
        args = args + " | grep " + vpc_uuid_str + " | grep " + ip_str + " | grep " + mac_str
        ret, op = utils.RunPdsctlShowCmd(node, "mapping internal remote", args,
                                         False)
        if not ret:
            logger.error(f"show mapping internal remote failed for "
                         f"VPC id:{vpc_uuid_str} IP:{ip_str} MAC:{mac_str}")
            return False

        cmdop = op.split('\n')
        if not len(cmdop):
            logger.error(
                "No (%s) entries found in rmap show VPC id:%s, IP:%s MAC:%s" %
                (len(cmdop), vpc_uuid_str, ip_str, mac_str))
            return False

        logger.info(
            "Found (%s) RMAP entry for learn VPC:%s IP:%s MAC:%s Subnet:%s " %
            ((len(cmdop) - 1), vpc_uuid_str, ip_str, mac_str,
             utils.List2UuidStr(subnet_uuid)))
        return True
Exemple #2
0
def GetNumLocalMapping(node):
    args = " | grep " + "\"No. of mappings:\""
    ret, cli_op = utils.RunPdsctlShowCmd(node, "mapping internal local", args, yaml=False)
    if not ret:
        logger.error(f"show mapping internal local failed for node {node}")
        return -1
    data = cli_op.split("No. of mappings: ", 1)
    return (int(data[1]) if len(data) > 1 else 0)
Exemple #3
0
 def ReadLifs(self, node):
     if utils.IsDryRun(): return
     ret, op = utils.RunPdsctlShowCmd(node, "lif", yaml=True)
     if not ret:
         logger.error(f"show lif failed for node {node}")
         return False
     cmdop = op.split("---")
     return cmdop
Exemple #4
0
    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
Exemple #5
0
def GetNumVnic(node, subnet=None):
    if subnet:
        args = f" | grep {subnet.UUID.UuidStr}"
    else:
        args = None
    ret, cli_op = utils.RunPdsctlShowCmd(node, "vnic", args, yaml=False)
    if not ret:
        logger.error(f"show vnic failed for node {node}")
        return 0
    return len(cli_op.split("\n"))
Exemple #6
0
def GetNumLearnIp(node, subnet=None):
    if subnet:
        args = f"--mode auto --subnet {subnet.UUID.UuidStr}"
    else:
        args = ""
    ret, cli_op = utils.RunPdsctlShowCmd(node, "learn ip", args, yaml=True)
    if not ret:
        logger.error(f"show learn ip failed for node {node}")
        return -1
    return (len(cli_op.split("---")) - 1)
Exemple #7
0
 def ValidateLearnIPInfo(self, node):
     if not EzAccessStoreClient[node].IsDeviceLearningEnabled():
         return True
     logger.info(f"Reading LMAP & learn ip objects from {node} ")
     # verify learn db against store
     ret, cli_op = utils.RunPdsctlShowCmd(node, "learn ip", None)
     if not self.VerifyLearntIpEntries(node, ret, cli_op):
         logger.error(f"learn ip object validation failed {ret} for {node} {cli_op}")
         return False
     return True
Exemple #8
0
 def ValidateLearnMACInfo(self, node):
     if not EzAccessStoreClient[node].IsDeviceLearningEnabled():
         return True
     logger.info(f"Reading VNIC & learn mac objects from {node} ")
     # verify learn db against store
     ret, cli_op = utils.RunPdsctlShowCmd(node, "learn mac", "--mode auto")
     if not self.ValidateLearntMacEntries(node, ret, cli_op):
         logger.error(
             f"learn mac object validation failed {ret} for {node} {cli_op}"
         )
         return False
     return True
Exemple #9
0
 def ValidateLearnIPWithRMapInfo(self, node, peer_node):
     if not EzAccessStoreClient[node].IsDeviceLearningEnabled():
         return True
     # verify learn db against store
     ret, cli_op = utils.RunPdsctlShowCmd(peer_node, "learn ip",
                                          "--mode auto")
     if not self.VerifyLearntIpEntriesWithRemoteMapping(
             node, peer_node, ret, cli_op):
         logger.error(
             f"learn ip object validation failed {ret} for remote {node} {cli_op}"
         )
         return False
     return True
Exemple #10
0
    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