1818# ISCSISR: ISCSI software initiator SR driver
1919#
2020
21+ from sm_typing import override
22+
2123import SR
24+ import VDI
2225import util
2326import time
2427import LUNperVDI
@@ -100,11 +103,12 @@ def address(self):
100103 self ._initPaths ()
101104 return self ._address
102105
103- def handles (type ):
106+ @override
107+ @staticmethod
108+ def handles (type ) -> bool :
104109 return False
105- handles = staticmethod (handles )
106110
107- def _synchroniseAddrList (self , addrlist ):
111+ def _synchroniseAddrList (self , addrlist ) -> None :
108112 if not self .multihomed :
109113 return
110114 change = False
@@ -133,7 +137,8 @@ def _synchroniseAddrList(self, addrlist):
133137 except :
134138 pass
135139
136- def load (self , sr_uuid ):
140+ @override
141+ def load (self , sr_uuid ) -> None :
137142 if self .force_tapdisk :
138143 self .sr_vditype = 'aio'
139144 else :
@@ -175,23 +180,23 @@ def load(self, sr_uuid):
175180 and ('chappassword' in self .dconf or 'chappassword_secret' in self .dconf ):
176181 self .chapuser = self .dconf ['chapuser' ].encode ('utf-8' )
177182 if 'chappassword_secret' in self .dconf :
178- self . chappassword = util .get_secret (self .session , self .dconf ['chappassword_secret' ])
183+ chappassword = util .get_secret (self .session , self .dconf ['chappassword_secret' ])
179184 else :
180- self . chappassword = self .dconf ['chappassword' ]
185+ chappassword = self .dconf ['chappassword' ]
181186
182- self .chappassword = self . chappassword .encode ('utf-8' )
187+ self .chappassword = chappassword .encode ('utf-8' )
183188
184189 self .incoming_chapuser = ""
185190 self .incoming_chappassword = ""
186191 if 'incoming_chapuser' in self .dconf \
187192 and ('incoming_chappassword' in self .dconf or 'incoming_chappassword_secret' in self .dconf ):
188193 self .incoming_chapuser = self .dconf ['incoming_chapuser' ].encode ('utf-8' )
189194 if 'incoming_chappassword_secret' in self .dconf :
190- self . incoming_chappassword = util .get_secret (self .session , self .dconf ['incoming_chappassword_secret' ])
195+ incoming_chappassword = util .get_secret (self .session , self .dconf ['incoming_chappassword_secret' ])
191196 else :
192- self . incoming_chappassword = self .dconf ['incoming_chappassword' ]
197+ incoming_chappassword = self .dconf ['incoming_chappassword' ]
193198
194- self .incoming_chappassword = self . incoming_chappassword .encode ('utf-8' )
199+ self .incoming_chappassword = incoming_chappassword .encode ('utf-8' )
195200
196201 self .port = DEFAULT_PORT
197202 if 'port' in self .dconf and self .dconf ['port' ]:
@@ -276,7 +281,7 @@ def _initPaths(self):
276281 self ._address = self .tgtidx
277282 self ._synchroniseAddrList (addrlist )
278283
279- def _init_adapters (self ):
284+ def _init_adapters (self ) -> None :
280285 # Generate a list of active adapters
281286 ids = scsiutil ._genHostList (ISCSI_PROCNAME )
282287 util .SMlog (ids )
@@ -293,7 +298,8 @@ def _init_adapters(self):
293298 pass
294299 self ._devs = scsiutil .cacheSCSIidentifiers ()
295300
296- def attach (self , sr_uuid ):
301+ @override
302+ def attach (self , sr_uuid ) -> None :
297303 self ._mpathHandle ()
298304
299305 multiTargets = False
@@ -391,10 +397,9 @@ def attach(self, sr_uuid):
391397 util ._incr_iscsiSR_refcount (self .targetIQN , sr_uuid )
392398 IQNs = []
393399 if "multiSession" in self .dconf :
394- IQNs = ""
395400 for iqn in self .dconf ['multiSession' ].split ("|" ):
396401 if len (iqn ):
397- IQNs += iqn .split (',' )[2 ]
402+ IQNs . append ( iqn .split (',' )[2 ])
398403 else :
399404 IQNs .append (self .targetIQN )
400405
@@ -429,7 +434,11 @@ def attach(self, sr_uuid):
429434 realdev = os .path .realpath (os .path .join (dev_path , dev ))
430435 util .set_scheduler (os .path .basename (realdev ))
431436
432- def detach (self , sr_uuid , delete = False ):
437+ @override
438+ def detach (self , sr_uuid ) -> None :
439+ self .detach_and_delete (sr_uuid , delete = False )
440+
441+ def detach_and_delete (self , sr_uuid , delete = True ) -> None :
433442 keys = []
434443 pbdref = None
435444 try :
@@ -470,7 +479,8 @@ def detach(self, sr_uuid, delete=False):
470479
471480 self .attached = False
472481
473- def create (self , sr_uuid , size ):
482+ @override
483+ def create (self , sr_uuid , size ) -> None :
474484 # Check whether an SR already exists
475485 SRs = self .session .xenapi .SR .get_all_records ()
476486 for sr in SRs :
@@ -499,11 +509,13 @@ def create(self, sr_uuid, size):
499509 self .session .xenapi .SR .set_sm_config (self .sr_ref , self .sm_config )
500510 return
501511
502- def delete (self , sr_uuid ):
512+ @override
513+ def delete (self , sr_uuid ) -> None :
503514 self .detach (sr_uuid )
504515 return
505516
506- def probe (self ):
517+ @override
518+ def probe (self ) -> str :
507519 SRs = self .session .xenapi .SR .get_all_records ()
508520 Recs = {}
509521 for sr in SRs :
@@ -513,8 +525,9 @@ def probe(self):
513525 sm_config ['targetIQN' ] == self .targetIQN :
514526 Recs [record ["uuid" ]] = sm_config
515527 return self .srlist_toxml (Recs )
516-
517- def scan (self , sr_uuid ):
528+
529+ @override
530+ def scan (self , sr_uuid ) -> None :
518531 if not self .passthrough :
519532 if not self .attached :
520533 raise xs_errors .XenError ('SRUnavailable' )
@@ -526,9 +539,10 @@ def scan(self, sr_uuid):
526539 if vdi .managed :
527540 self .physical_utilisation += vdi .size
528541 self .virtual_allocation = self .physical_utilisation
529- return super (BaseISCSISR , self ).scan (sr_uuid )
542+ super (BaseISCSISR , self ).scan (sr_uuid )
530543
531- def vdi (self , uuid ):
544+ @override
545+ def vdi (self , uuid ) -> VDI .VDI :
532546 return LUNperVDI .RAWVDI (self , uuid )
533547
534548 def _scan_IQNs (self ):
0 commit comments