class SesPageSas(SesPage): """ Read and write SES pages through SAS. """ def __init__(self, ptdev): """ pt is a SCSI passthrough device file name """ super(SesPageSas, self).__init__() self.pt = ScsiPT(ptdev) def close(self): del self.pt self.pt = None def __del__(self): self.close() super(SesPageSas, self).__del__() def readpage(self, pagenum): """ Read the SES page specified by integer pagenum, returning a string. """ data = self._getsespage(pagenum, 4) if pagenum == 0x80: data = self._getsespage(pagenum, 5) length = 4 + \ (ord(data[2]) << 8) + \ (ord(data[3]) << 0) return self._getsespage(pagenum, length) def writepage(self, data): """ Write the SES page specified by integer pagenum with string, data. """ cmd = Cmd("sd", { "self-test_code": 0, "pf": 1, "parameter_list_length": len(data) }) cdb = CDB(cmd.cdb) cdb.set_data_out(data) result = self.pt.sendcdb(cdb) return result def _getsespage(self, page, length): # uses pt cmd = Cmd("rdr", {"pcv": 1, "page_code": page, "alloc": length}) #for q in cmd.cdb: print "%.2x" % q, #print cdb = CDB(cmd.cdb) cdb.set_data_in(length) self.pt.sendcdb(cdb) return cdb.buf
class SesPageSas(SesPage): """ Read and write SES pages through SAS. """ def __init__(self, ptdev): """ pt is a SCSI passthrough device file name """ super(SesPageSas, self).__init__() self.pt = ScsiPT(ptdev) def close(self): del self.pt self.pt = None def __del__(self): self.close() super(SesPageSas, self).__del__() def readpage(self, pagenum): """ Read the SES page specified by integer pagenum, returning a string. """ data = self._getsespage(pagenum, 4) if pagenum == 0x80: data = self._getsespage(pagenum, 5) length = 4 + \ (ord(data[2]) << 8) + \ (ord(data[3]) << 0) return self._getsespage(pagenum, length) def writepage(self, data): """ Write the SES page specified by integer pagenum with string, data. """ cmd = Cmd("sd", {"self-test_code":0, "pf":1, "parameter_list_length":len(data)}) cdb = CDB(cmd.cdb) cdb.set_data_out(data) result = self.pt.sendcdb(cdb) return result def _getsespage(self, page, length): # uses pt cmd = Cmd("rdr", {"pcv":1, "page_code":page, "alloc":length}) #for q in cmd.cdb: print "%.2x" % q, #print cdb = CDB(cmd.cdb) cdb.set_data_in(length) self.pt.sendcdb(cdb) return cdb.buf
def __init__(self, ptdev, expanderid=None): """ pt is a SCSI passthrough device file name expanderid can have one of the values 0x01: SBB Canister A 0x02: SBB Canister B 0x03: FEM Canister A SAS Expander 1 0x04: FEM Canister A SAS Expander 2 0x05: FEM Canister B SAS Expander 1 0x06: FEM Canister B SAS Expander 2 Alternately, the first parameter may be a sequence of (ptdev,expanderid). """ super(CliCmdSas, self).__init__() if not isinstance(ptdev, str): # If it's not a string, assume it's a sequence. ptdev, expanderid = ptdev self.ses = SesPageSas(ptdev) self.pt = ScsiPT(ptdev) self.expanderid = expanderid
class CliCmdSas(CliCmd): def __init__(self, ptdev, expanderid=None): """ pt is a SCSI passthrough device file name expanderid can have one of the values 0x01: SBB Canister A 0x02: SBB Canister B 0x03: FEM Canister A SAS Expander 1 0x04: FEM Canister A SAS Expander 2 0x05: FEM Canister B SAS Expander 1 0x06: FEM Canister B SAS Expander 2 Alternately, the first parameter may be a sequence of (ptdev,expanderid). """ super(CliCmdSas, self).__init__() if not isinstance(ptdev, str): # If it's not a string, assume it's a sequence. ptdev, expanderid = ptdev self.ses = SesPageSas(ptdev) self.pt = ScsiPT(ptdev) self.expanderid = expanderid def close(self): pass def __del__(self): #del self.ses pass def execute(self, command): """ Send a CLI command through SES page 0xe8. """ cmd = Cmd.clicommandout(self.expanderid, command) cdb = CDB(cmd.cdb) cdb.set_data_out(cmd.dat) self.pt.sendcdb(cdb) page = self.ses.parse(self.ses.readpage(0xe8)) return page["data"].response.val
def __init__(self, ptdev): """ pt is a SCSI passthrough device file name """ super(SesPageSas, self).__init__() self.pt = ScsiPT(ptdev)