def readFromTarget(self): """See if we can read from the target""" return runCmdWithOutput(["dd", "if=" + self.dev, "iflag=direct", "of=/dev/null", "skip=1", "bs=4096", "count=1"])
def writeToTarget(self): """See if we can write to the target (destructive!) """ return runCmdWithOutput(["dd", "if=/dev/zero", "of=" + self.dev, "oflag=direct", "bs=4096", "skip=1", "seek=1", "count=1"])
def getDiskInquirySn(self): """Get the Disk Serial Number""" res = runCmdWithOutput(["sg_inq", self.dev]) ret = None if res.result == 0: if "Unit serial number" in res.lines[-1]: line = res.lines[-1] ret = line.split()[-1] log.debug("getDiskInquirySn(%s) -> %s" % (self.dev, ret)) return ret
def runSgCmdWithOutput(self, cmd): """Run the SG command on specified host""" my_cmd = ["sg_persist", "-n"] + cmd + [self.dev] return runCmdWithOutput(my_cmd)
def runTur(self): """Clear any UA by sending TUR""" res = runCmdWithOutput(["sg_turs", self.dev]) return res.result