Example #1
0
 def ValidateGrpcRead(self, node, getResp):
     if utils.IsDryRun(): return True
     numObjs = 0
     for obj in getResp:
         if not utils.ValidateGrpcResponse(obj):
             logger.error("GRPC get request failed for ", obj)
             continue
         #TODO handle singleton object
         resps = obj.Response
         for resp in resps:
             if not self.IsGrpcSpecMatching(resp.Spec):
                 continue
             numObjs += 1
             key = self.GetKeyfromSpec(resp.Spec)
             cfgObj = self.GetObjectByKey(node, key)
             if not utils.ValidateObject(cfgObj, resp):
                 logger.error("GRPC read validation failed for ", obj)
                 if cfgObj:
                     cfgObj.Show()
                 logger.info(f"Key:{key} Spec:{resp.Spec}")
                 return False
             if hasattr(cfgObj, 'Status'):
                 cfgObj.Status.Update(resp.Status)
     logger.info(f"GRPC read count {numObjs} for {self.ObjType.name} in {node}")
     return (numObjs == self.GetNumHwObjects(node))
Example #2
0
 def ValidatePdsctlRead(self, node, ret, stdout):
     if utils.IsDryRun(): return True
     if not ret:
         logger.error("pdsctl show cmd failed for ", self.ObjType)
         return False
     device = self.GetObjectByKey(node, 0)
     if "API_STATUS_NOT_FOUND" in stdout:
         if device.IsHwHabitant():
             logger.error(f"GRPC get request failed for {device} with {stdout}")
             device.Show()
             return False
         return True
     # split output per object
     cmdop = stdout.split("---")
     for op in cmdop:
         yamlOp = utils.LoadYaml(op)
         if not yamlOp:
             continue
         device = self.GetObjectByKey(node, 0)
         resp = yamlOp['response']
         if not utils.ValidateObject(device, resp, yaml=True):
             logger.error("pdsctl read validation failed for ", op)
             device.Show()
             return False
     return True
Example #3
0
 def ValidateGrpcRead(self, node, getResp):
     if utils.IsDryRun(): return True
     device = self.GetObjectByKey(node, 0)
     for obj in getResp:
         if not utils.ValidateGrpcResponse(obj):
             if device.IsHwHabitant():
                 logger.error(f"GRPC get request failed for {device} with {obj}")
                 device.Show()
                 return False
             return True
         resp = obj.Response
         if not utils.ValidateObject(device, resp):
             logger.error("GRPC read validation failed for  ", obj)
             device.Show()
             return False
     return True
Example #4
0
 def ValidatePdsctlRead(self, node, ret, stdout):
     if utils.IsDryRun(): return True
     if not ret:
         logger.error("pdsctl show cmd failed for ", self.ObjType)
         return False
     # split output per object
     cmdop = stdout.split("---")
     assert((len(cmdop) - 1) == self.GetNumHwObjects(node))
     for op in cmdop:
         yamlOp = utils.LoadYaml(op)
         if not yamlOp:
             continue
         key = self.GetKeyfromSpec(yamlOp['spec'], yaml=True)
         cfgObj = self.GetObjectByKey(node, key)
         if not utils.ValidateObject(cfgObj, yamlOp, yaml=True):
             logger.error("pdsctl read validation failed for ", op)
             cfgObj.Show()
             return False
     return True
Example #5
0
 def ValidateObjects(self, getResp, node):
     if utils.IsDryRun(): return True
     numObjs = 0
     for obj in getResp:
         if not utils.ValidateGrpcResponse(obj):
             logger.error("INTERFACE get request failed for ", obj)
             continue
         for resp in obj.Response:
             key = self.GetKeyfromSpec(resp.Spec)
             inf = self.GetInterfaceObject(node, key)
             if inf is not None:
                 numObjs += 1
                 if not utils.ValidateObject(inf, resp):
                     logger.error("INTERFACE validation failed for ",
                                  resp.Spec)
                     inf.Show()
                     return False
                 # update status for this interface object
                 inf.Status.Update(resp.Status)
     logger.info(
         f"GRPC read count {numObjs} for {self.ObjType.name} in {node}")
     return (numObjs == self.GetNumHwObjects(node))