4141from journaler import Journaler
4242from refcounter import RefCounter
4343from ipc import IPCFlag
44+ from constants import NS_PREFIX_LVM , VG_LOCATION , VG_PREFIX
4445from lvmanager import LVActivator
4546from vditype import VdiType
4647import XenAPI # pylint: disable=import-error
5556import glob
5657from constants import CBTLOG_TAG
5758from fairlock import Fairlock
58- DEV_MAPPER_ROOT = os .path .join ('/dev/mapper' , lvhdutil . VG_PREFIX )
59+ DEV_MAPPER_ROOT = os .path .join ('/dev/mapper' , VG_PREFIX )
5960
6061geneology : Dict [str , List [str ]] = {}
6162CAPABILITIES = ["SR_PROBE" , "SR_UPDATE" , "SR_TRIM" ,
@@ -162,8 +163,8 @@ def load(self, sr_uuid) -> None:
162163 self .lock = lock .Lock (lock .LOCK_TYPE_SR , self .uuid )
163164 self .sr_vditype = SR .DEFAULT_TAP
164165 self .uuid = sr_uuid
165- self .vgname = lvhdutil . VG_PREFIX + self .uuid
166- self .path = os .path .join (lvhdutil . VG_LOCATION , self .vgname )
166+ self .vgname = VG_PREFIX + self .uuid
167+ self .path = os .path .join (VG_LOCATION , self .vgname )
167168 self .mdpath = os .path .join (self .path , self .MDVOLUME_NAME )
168169 self .provision = self .PROVISIONING_DEFAULT
169170
@@ -860,8 +861,8 @@ def _updateStats(self, uuid, virtAllocDelta):
860861 @deviceCheck
861862 def probe (self ) -> str :
862863 return lvutil .srlist_toxml (
863- lvutil .scan_srlist (lvhdutil . VG_PREFIX , self .dconf ['device' ]),
864- lvhdutil . VG_PREFIX ,
864+ lvutil .scan_srlist (VG_PREFIX , self .dconf ['device' ]),
865+ VG_PREFIX ,
865866 ('metadata' in self .srcmd .params ['sr_sm_config' ] and \
866867 self .srcmd .params ['sr_sm_config' ]['metadata' ] == 'true' ))
867868
@@ -990,7 +991,7 @@ def _undoCloneOp(self, lvs, origUuid, baseUuid, clonUuid):
990991 if base .readonly :
991992 self .lvmCache .setReadonly (base .name , False )
992993
993- ns = lvhdutil . NS_PREFIX_LVM + self .uuid
994+ ns = NS_PREFIX_LVM + self .uuid
994995 origRefcountBinary = RefCounter .check (origUuid , ns )[1 ]
995996 origRefcountNormal = 0
996997
@@ -1248,7 +1249,7 @@ def _updateSlavesOnClone(self, hostRefs, origOldLV, origLV,
12481249 "action1" : "refresh" ,
12491250 "lvName1" : origLV ,
12501251 "action2" : "activate" ,
1251- "ns2" : lvhdutil . NS_PREFIX_LVM + self .uuid ,
1252+ "ns2" : NS_PREFIX_LVM + self .uuid ,
12521253 "lvName2" : baseLV ,
12531254 "uuid2" : baseUuid }
12541255
@@ -1288,7 +1289,7 @@ def _updateSlavesOnRemove(self, hostRefs, baseUuid, baseLV):
12881289 args = {"vgName" : self .vgname ,
12891290 "action1" : "cleanupLockAndRefcount" ,
12901291 "uuid1" : baseUuid ,
1291- "ns1" : lvhdutil . NS_PREFIX_LVM + self .uuid }
1292+ "ns1" : NS_PREFIX_LVM + self .uuid }
12921293
12931294 masterRef = util .get_this_host_ref (self .session )
12941295 for hostRef in hostRefs :
@@ -1303,11 +1304,11 @@ def _updateSlavesOnRemove(self, hostRefs, baseUuid, baseLV):
13031304
13041305 def _cleanup (self , skipLockCleanup = False ):
13051306 """delete stale refcounter, flag, and lock files"""
1306- RefCounter .resetAll (lvhdutil . NS_PREFIX_LVM + self .uuid )
1307+ RefCounter .resetAll (NS_PREFIX_LVM + self .uuid )
13071308 IPCFlag (self .uuid ).clearAll ()
13081309 if not skipLockCleanup :
13091310 lock .Lock .cleanupAll (self .uuid )
1310- lock .Lock .cleanupAll (lvhdutil . NS_PREFIX_LVM + self .uuid )
1311+ lock .Lock .cleanupAll (NS_PREFIX_LVM + self .uuid )
13111312
13121313 def _prepareTestMode (self ):
13131314 util .SMlog ("Test mode: %s" % self .testMode )
@@ -1469,7 +1470,7 @@ def delete(self, sr_uuid, vdi_uuid, data_only=False) -> None:
14691470
14701471 try :
14711472 self .sr .lvmCache .remove (self .lvname )
1472- self .sr .lock .cleanup (vdi_uuid , lvhdutil . NS_PREFIX_LVM + sr_uuid )
1473+ self .sr .lock .cleanup (vdi_uuid , NS_PREFIX_LVM + sr_uuid )
14731474 self .sr .lock .cleanupAll (vdi_uuid )
14741475 except xs_errors .SRException as e :
14751476 util .SMlog (
@@ -1786,7 +1787,7 @@ def _snapshot(self, snapType, cloneOp=False, cbtlog=None, cbt_consistency=None):
17861787 baseLV = lvhdutil .LV_PREFIX [self .vdi_type ] + baseUuid
17871788 self .sr .lvmCache .rename (self .lvname , baseLV )
17881789 self .sr .lvActivator .replace (self .uuid , baseUuid , baseLV , False )
1789- RefCounter .set (baseUuid , 1 , 0 , lvhdutil . NS_PREFIX_LVM + self .sr .uuid )
1790+ RefCounter .set (baseUuid , 1 , 0 , NS_PREFIX_LVM + self .sr .uuid )
17901791 self .uuid = baseUuid
17911792 self .lvname = baseLV
17921793 self .path = os .path .join (self .sr .path , baseLV )
@@ -1861,7 +1862,7 @@ def _createSnap(self, snapUuid, snapSizeLV, isNew):
18611862 self .sr .lvmCache .create (snapLV , int (snapSizeLV ))
18621863 util .fistpoint .activate ("LVHDRT_clone_vdi_after_lvcreate" , self .sr .uuid )
18631864 if isNew :
1864- RefCounter .set (snapUuid , 1 , 0 , lvhdutil . NS_PREFIX_LVM + self .sr .uuid )
1865+ RefCounter .set (snapUuid , 1 , 0 , NS_PREFIX_LVM + self .sr .uuid )
18651866 self .sr .lvActivator .add (snapUuid , snapLV , False )
18661867 parentRaw = (self .vdi_type == VdiType .RAW )
18671868 vhdutil .snapshot (snapPath , self .path , parentRaw , lvhdutil .MSIZE_MB )
@@ -1898,7 +1899,7 @@ def _finishSnapshot(self, snapVDI, snapVDI2, hostRefs, cloneOp=False, snapType=N
18981899 (not snapVDI2 or snap2Parent != self .uuid ):
18991900 util .SMlog ("%s != %s != %s => deleting unused base %s" % \
19001901 (snapParent , self .uuid , snap2Parent , self .lvname ))
1901- RefCounter .put (self .uuid , False , lvhdutil . NS_PREFIX_LVM + self .sr .uuid )
1902+ RefCounter .put (self .uuid , False , NS_PREFIX_LVM + self .sr .uuid )
19021903 self .sr .lvmCache .remove (self .lvname )
19031904 self .sr .lvActivator .remove (self .uuid , False )
19041905 if hostRefs :
@@ -1921,7 +1922,7 @@ def _finishSnapshot(self, snapVDI, snapVDI2, hostRefs, cloneOp=False, snapType=N
19211922 # cannot affect the VDIs here because they cannot possibly be
19221923 # involved in coalescing at this point, and at the relinkSkip step
19231924 # that activates the children, which takes the SR lock.)
1924- ns = lvhdutil . NS_PREFIX_LVM + self .sr .uuid
1925+ ns = NS_PREFIX_LVM + self .sr .uuid
19251926 (cnt , bcnt ) = RefCounter .check (snapVDI .uuid , ns )
19261927 RefCounter .set (self .uuid , bcnt + 1 , 0 , ns )
19271928
@@ -2128,7 +2129,7 @@ def _loadThis(self):
21282129 def _chainSetActive (self , active , binary , persistent = False ):
21292130 if binary :
21302131 (count , bcount ) = RefCounter .checkLocked (self .uuid ,
2131- lvhdutil . NS_PREFIX_LVM + self .sr .uuid )
2132+ NS_PREFIX_LVM + self .sr .uuid )
21322133 if (active and bcount > 0 ) or (not active and bcount == 0 ):
21332134 return # this is a redundant activation/deactivation call
21342135
0 commit comments