ó h'dWc@s@dZddlmZddlmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;ddlm<Z<m=Z=m>Z>defd„ƒYZ?defd„ƒYZ@d efd „ƒYZAd efd „ƒYZBd efd„ƒYZCdefd„ƒYZDdefd„ƒYZEdefd„ƒYZFdS(sW Python packge with ctypes wrapper for libdiskmgt.so descriptor attributes. All DMDescriptors have an attributes property. The attributes is an NVList. These classes simply know the correct keys for each type of NVList attribute. NOTE: when subclassing libnvpair.nvl.NVList it is imperative to set the _type_ of the class for ctypes. iÿÿÿÿ(tNVList(8tBCYLtBHEADt BLOCKSIZEtBOOTIDtBSECTtBTYPEtCLOCKt CLUSTEREDtCTYPEtDEVICEIDtDEVTtDRIVE_UPtDRVTYPEtECYLtEFItEFI_NAMEtEHEADtESECTtFASTtFAST20tFAST40tFAST80tFDISKtFLAGtINDEXtLABELtLOADEDt LOCALNAMEtLUNtMTYPEt MULTIPLEXt NACCESSIBLEtNACTUALCYLINDERSt NALTCYLINDERSt NCYLINDERStNHEADStNPHYSCYLINDERStNSECTORStOPATHtPARTITION_TYPEt PATH_STATEtPNAMEt PRODUCT_IDtPTYPEtRELSECTt REMOVABLEtRPMtSIZEtSTARTtSTATUSt SYNC_SPEEDtTAGtTARGETt VENDOR_IDtWIDEtWWN(tDRIVE_TYPE_MAPtMEDIA_TYPE_MAPtPARTITION_TYPE_MAPt DMDriveAttrcBs¼eZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ ed „ƒZ ed „ƒZd „ZRS( s:NVList with specific keys, which have been made propertiescCs|tdfS(s.bool indicating if the disk media is removabletEBOOLEAN(R.(tself((s attributes.pyt removable;scCs|jr|tdfStSdS(s+bool indicating if the disk media is loadedR=N(R?RtTrue(R>((s attributes.pytloaded@s cCs |tdftkrdpdS(s"dive status, str in ("UP", "DOWN")tUINT32tUPtDOWN(R2R (R>((s attributes.pytstatusIscCst|tdfS(s&drive type, a str (see DRIVE_TYPE_MAP)RB(R9R (R>((s attributes.pyttypeNscCs|jtdfdƒS(s&string representing product ID or NonetSTRINGN(tgetR+tNone(R>((s attributes.pyt product_idSscCs|jtdfdƒS(s%string representing vendor ID or NoneRGN(RHR6RI(R>((s attributes.pyt vendor_idXscCs|jtdfdƒS(sint sync speed or NoneRBN(RHR3RI(R>((s attributes.pyt sync_speed]scCs|tdfS(sbool indicating disk is wideR=(R7(R>((s attributes.pytwidebscCs|jtdfdƒS(sint rpm or NoneRBN(RHR/RI(R>((s attributes.pytrpmgscCs|tdfS(s"bool indicating drive is clusteredR=(R(R>((s attributes.pyt clusteredlscCs|jtdfdƒS(sstr of drive opath or NoneRGN(RHR'RI(R>((s attributes.pytopathqscCsBdt|ƒg}|jd|jƒ|jd|jp<d|jpHdfƒ|jd|j|jfƒ|jd|jƒ|j}|jd|r¥t |ƒp¨dƒ|jd|j rÆd pÉd ƒ|j }|jd |ròt |ƒpõdƒ|jd |j rd pd ƒ|jd |j p0dƒdj|ƒS(NsDMDriveAttr <%d>s drive type: %ss product/vendor = %s/%stUNKNOWNs removable = %s (loaded = %s)s status is %ss sync speed is %ss disk is%s widesn'tts RPM is %ss disk is%s clustereds opath = "%s"s (tidtappendRFRJRKR?RARERLtstrRMRNRORPtjoin(R>trlisttspeedRN((s attributes.pyt__repr__vs$     ! # (t__name__t __module__t__doc__tpropertyR?RARERFRJRKRLRMRNRORPRY(((s attributes.pyR<8s tDMControllerAttrcBseZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ d „Z RS( s:NVList with specific keys, which have been made propertiescCs|tdfS(scontroller type, a strRG(R (R>((s attributes.pyRFŽscCs|tdfS(sTrue if controller is multiplexR=(R(R>((s attributes.pyt multiplex“scCs|jtdfdƒS(sTrue if controller is SCSI-wideR=N(RHR7RI(R>((s attributes.pyRM˜scCs|jtdfdƒS(sTrue if controller is SCSI-fastR=N(RHRRI(R>((s attributes.pytfastscCs|jtdfdƒS(s!True if controller is SCSI-fast20R=N(RHRRI(R>((s attributes.pytfast20¢scCs|jtdfdƒS(s!True if controller is SCSI-fast40R=N(RHRRI(R>((s attributes.pytfast40§scCs|jtdfdƒS(s!True if controller is SCSI-fast80R=N(RHRRI(R>((s attributes.pytfast80¬scCs|jtdfdƒS(s controller clock, an int or NoneRBN(RHRRI(R>((s attributes.pytclock±scCsdt|ƒg}|jd|jƒ|jd|jrB|jpEdƒ|jd|jrbdpedƒ|jd|jr‚dp…dƒ|jd |jr¢dp¥dƒ|jd |jrÂdpÅdƒ|jd |jrâdpådƒ|jd |j rdpdƒd j |ƒS(NsDMControllerAttr <%d>s type: %ss clock = %diÿÿÿÿs controller is%s multiplexsn'tRRs controller is%s wides controller is%s fasts controller is%s fast20s controller is%s fast40s controller is%s fast80s ( RSRTRFRdR_RMR`RaRbRcRV(R>RW((s attributes.pyRY¶s #      ( RZR[R\R]RFR_RMR`RaRbRcRdRY(((s attributes.pyR^‹st DMMediaAttrcBseZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ ed „ƒZ ed „ƒZed „ƒZed „ƒZed„ƒZed„ƒZed„ƒZd„ZRS(s:NVList with specific keys, which have been made propertiescCst|tdfS(s&media type, a str (see MEDIA_TYPE_MAP)RB(R:R(R>((s attributes.pyRFÌscCs|tdfS(sTrue if media is removableR=(R.(R>((s attributes.pyR?ÑscCs|tdfS(s(True if media is removable and is loadedR=(R(R>((s attributes.pyRAÖscCs|tdfS(sblock size, an intRB(R(R>((s attributes.pyt blocksizeÛscCs|tdfS(s&True if the media has fdisk partitionsR=(R(R>((s attributes.pytfdiskàscCs|tdfS(sTrue if drive is EFIR=(R(R>((s attributes.pytefiçscCs|tdfS(s size, an inttUINT64(R0(R>((s attributes.pytsizeìscCs|jtdfdƒS(sstart, and intRiN(RHR1RI(R>((s attributes.pytstartñscCs|jtdfdƒS(s#number of accessible blocks, an intRiN(RHR RI(R>((s attributes.pyt naccessibleöscCs|jtdfdƒS(sA number of cylinders, an int or None (available for drive < 1TB) RBN(RHR#RI(R>((s attributes.pyt ncylindersûscCs|jtdfdƒS(sc number of physical cylinders, an int or None (available for drives < 1TB) RBN(RHR%RI(R>((s attributes.pytnphyscylindersscCs|jtdfdƒS(sd number of alternate cylinders, an int or None (available for drives < 1TB) RBN(RHR"RI(R>((s attributes.pyt naltcylindersscCs|jtdfdƒS(s4 heads, an int or None (available for drives < 1TB) RBN(RHR$RI(R>((s attributes.pytnheadsscCs|jtdfdƒS(s@ number of sectors, an int or None (available for drives < 1TB) RBN(RHR&RI(R>((s attributes.pytnsectorsscCs|jtdfdƒS(sY number of actual cylinders, an int or None (available for drives < 1TB) RBN(RHR!RI(R>((s attributes.pytnactualcylindersscCs|jtdfdƒS(sdrive label, a str or NoneRGN(RHRRI(R>((s attributes.pytlabel!scCsbdt|ƒg}|jd|jƒ|jd|j|jfƒ|jd|j|jfƒ|jd|jr||jpdƒ|jd|j|j |j fƒ|j dkrÃdj |ƒS|jd ƒ|jd ƒ|jd |j ƒ|jd |jƒ|jd |jƒ|jd|jƒ|jd|jƒ|jd|jƒdj |ƒS(NsDMMediaAttr <%d>s type = %ss removable/loaded = %s/%ss fdisk = %s, efi = %ss label = %st-s, blocksize = %d, size = %d, naccessible = %ds s geometry:s cylinders:s number = %ds physical number = %ds alternate number = %ds actual number = %ds heads = %ds sectors = %d(RSRTRFR?RARgRhRsRfRjRlRmRIRVRnRoRrRpRq(R>RW((s attributes.pyRY&s& #    (RZR[R\R]RFR?RARfRgRhRjRkRlRmRnRoRpRqRrRsRY(((s attributes.pyReÉs$t DMPathAttrcBsDeZdZed„ƒZed„ƒZed„ƒZd„ZRS(s:NVList with specific keys, which have been made propertiescCs|tdfS(s type, a strRG(R (R>((s attributes.pyRF@scCs|jtdfdƒS(s7state, a str or None (only paths for drives have state)RGN(RHR)RI(R>((s attributes.pytstateEscCs|jtdfdƒS(s3wwn, a str or None (only pahts for drives have wwn)RGN(RHR8RI(R>((s attributes.pytwwnJscCstdt|ƒg}|jd|jƒ|jrG|jd|jƒn|jrg|jd|jƒndj|ƒS(NsDMPathAttr <%d>s type = %ss state = %ss wwn = %ss (RSRTRFRvRwRV(R>RW((s attributes.pyRYOs  (RZR[R\R]RFRvRwRY(((s attributes.pyRu=s t DMAliasAttrcBsSeZdZed„ƒZed„ƒZed„ƒZed„ƒZd„ZRS(s:NVList with specific keys, which have been made propertiescCs|jtdfdƒS(slun number, an int or NoneRBN(RHRRI(R>((s attributes.pytlun\scCs|jtdfdƒS(starget number, an int or NoneRBN(RHR5RI(R>((s attributes.pyttargetascCs|jtdfdƒS(swwn, a str or NoneRGN(RHR8RI(R>((s attributes.pyRwfscCs(|jtdfdƒtkr$dp'dS(sstatus, str in ("UP", "DOWN")RBRCRDN(RHR2RIR (R>((s attributes.pyREkscCsqdt|ƒg}|jdt|jƒt|jƒfƒ|jd|jƒ|jd|jƒdj|ƒS(NsDMAliasAttr <%d>s lun/target = %s/%ss wwn = %ss status = %ss (RSRTRURyRzRwRERV(R>RW((s attributes.pyRYps ( RZR[R\R]RyRzRwRERY(((s attributes.pyRxYs t DMBusAttrcBsDeZdZed„ƒZed„ƒZed„ƒZd„ZRS(s:NVList with specific keys, which have been made propertiescCs|tdfS(s type, a strRG(R(R>((s attributes.pyRF|scCs|jtdfdƒS(sclock, an int or NoneRBN(RHRRI(R>((s attributes.pyRdscCs|jtdfdƒS(spname, a str or NoneRGN(RHR*RI(R>((s attributes.pytpname†scCsbdt|ƒg}|jd|jƒ|jdt|jƒƒ|jd|jƒdj|ƒS(NsDMBusAttr <%d>s type = %ss clock = %ss pname = %ss (RSRTRFRURdR|RV(R>RW((s attributes.pyRY‹s (RZR[R\R]RFRdR|RY(((s attributes.pyR{ys t DMPartAttrcBs¼eZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ ed „ƒZ ed „ƒZd „ZRS( s:NVList with specific keys, which have been made propertiescCst|tdfS(s.partition type, a str (see PARTITION_TYPE_MAP)RB(R;R((R>((s attributes.pyRF–scCs|tdfS(sbootid, an intRB(R(R>((s attributes.pytbootid›scCs|tdfS(spartition ID, an intRB(R,(R>((s attributes.pyRS scCs|tdfS(spartition bhead, an intRB(R(R>((s attributes.pytbhead¥scCs|tdfS(spartition ehead, an intRB(R(R>((s attributes.pytbsectªscCs|tdfS(spartition bcyl, an intRB(R(R>((s attributes.pytbcyl¯scCs|tdfS(spartition bhead, an intRB(R(R>((s attributes.pytehead´scCs|tdfS(spartition ehead, an intRB(R(R>((s attributes.pytesect¹scCs|tdfS(spartition bcyl, an intRB(R(R>((s attributes.pytecyl¾scCs|tdfS(spartition relsect, an intRB(R-(R>((s attributes.pytrelsectÃscCs|tdfS(s partiion size in sectors, an intRB(R&(R>((s attributes.pyRqÈscCsÊdt|ƒg}|jd|jƒ|jd|jƒ|jd|jƒ|jd|j|j|jfƒ|jd|j|j|j fƒ|jd|j ƒ|jd|j ƒd j |ƒS( NsDMPartAttr <%d>s partition type: %ss partition bootid = %ds partition ID = %ss bhead/bsect/bcyl = %d/%d/%ds ehead/esect/ecyl = %d/%d/%ds relsect = %ds nsectors = %ds ( RSRTRFR~RR€RR‚RƒR„R…RqRV(R>RW((s attributes.pyRYÍs  (RZR[R\R]RFR~RSRR€RR‚RƒR„R…RqRY(((s attributes.pyR}“st DMSliceAttrcBs­eZdZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZed„ƒZ ed„ƒZ ed„ƒZ ed „ƒZ ed „ƒZ d „ZRS( s:NVList with specific keys, which have been made propertiescCs|tdfS(sslice index, an intRB(R(R>((s attributes.pytindexÞscCs|tdfS(sslice start, an intRi(R1(R>((s attributes.pyRkãscCs|tdfS(sslice size, an intRi(R0(R>((s attributes.pyRjèscCs|tdfS(s,True if slice is EFI, false if slice is VTOCR=(R(R>((s attributes.pyRhíscCs%|jtkrdS|tdfSdS(s(slice tag, an int (if EFI False) or NoneRBN(RhR@RIR4(R>((s attributes.pyttagòscCs%|jtkrdS|tdfSdS(s)slice flag, an int (if EFI False) or NoneRBN(RhR@RIR(R>((s attributes.pytflagúscCs*|jtkrdS|jtdfƒSdS(s.slice EFI name, a str (if EFI is True) or NoneRGN(RhtFalseRIRHR(R>((s attributes.pytefi_namescCs|jtdfdƒS(sslice localname, a str or NoneRGN(RHRRI(R>((s attributes.pyt localname scCs|jtdfdƒS(sslice devt, an intRiN(RHR RI(R>((s attributes.pytdevtscCs|jtdfdƒS(sslice deviceid, a str or NoneRGN(RHR RI(R>((s attributes.pytdeviceidscCsídt|ƒg}|jd|jƒ|jd|jƒ|jd|jƒ|jtkr~|jd|j|jfƒn|jd|j ƒ|j dk r¸|jd|j ƒn|jd|j ƒ|jd |j ƒd j|ƒS( NsDMSliceAttr <%d>s index: %ds start: %ds size: %ds VTOC: tag/flag = %d/%ds EFI: %ss Localname: %ss devt = %ds deviceid = %ss (RSRTR‡RkRjRhRŠRˆR‰R‹RŒRIRRŽRV(R>RW((s attributes.pyRYs (RZR[R\R]R‡RkRjRhRˆR‰R‹RŒRRŽRY(((s attributes.pyR†ÛsN(GR\t libnvpairRtlibdiskmgt.constRRRRRRRRR R R R R RRRRRRRRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)R*R+R,R-R.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R^ReRuRxR{R}R†(((s attributes.pyt$sÿ[ S>t H