56
56
import xmlrpc .client
57
57
import xs_errors
58
58
59
- from cowutil import getCowUtil , getVdiTypeFromImageFormat
59
+ from cowutil import getVdiTypeFromImageFormat
60
60
from srmetadata import \
61
61
NAME_LABEL_TAG , NAME_DESCRIPTION_TAG , IS_A_SNAPSHOT_TAG , SNAPSHOT_OF_TAG , \
62
62
TYPE_TAG , VDI_TYPE_TAG , READ_ONLY_TAG , SNAPSHOT_TIME_TAG , \
@@ -156,7 +156,7 @@ def attach_thin(session, journaler, linstor, sr_uuid, vdi_uuid):
156
156
157
157
device_path = linstor .get_device_path (vdi_uuid )
158
158
159
- linstorcowutil = LinstorCowUtil (session , linstor , getCowUtil ( vdi_type ) )
159
+ linstorcowutil = LinstorCowUtil (session , linstor , vdi_type )
160
160
161
161
# If the virtual COW size is lower than the LINSTOR volume size,
162
162
# there is nothing to do.
@@ -201,7 +201,7 @@ def check_vbd_count():
201
201
util .retry (check_vbd_count , maxretry = 10 , period = 1 )
202
202
203
203
device_path = linstor .get_device_path (vdi_uuid )
204
- linstorcowutil = LinstorCowUtil (session , linstor , getCowUtil ( vdi_type ) )
204
+ linstorcowutil = LinstorCowUtil (session , linstor , vdi_type )
205
205
new_volume_size = LinstorVolumeManager .round_up_volume_size (
206
206
# TODO: Replace pylint comment with this feature when possible:
207
207
# https://github.com/PyCQA/pylint/pull/2926
@@ -1162,7 +1162,7 @@ def _load_vdis_ex(self):
1162
1162
if not VdiType .isCowImage (vdi_type ):
1163
1163
managed = not volume_metadata .get (HIDDEN_TAG )
1164
1164
else :
1165
- image_info = LinstorCowUtil (self .session , self ._linstor , getCowUtil ( vdi_type ) ).get_info (vdi_uuid )
1165
+ image_info = LinstorCowUtil (self .session , self ._linstor , vdi_type ).get_info (vdi_uuid )
1166
1166
managed = not image_info .hidden
1167
1167
if image_info .parentUuid :
1168
1168
sm_config ['vhd-parent' ] = image_info .parentUuid
@@ -1303,7 +1303,7 @@ def _get_vdi_path_and_parent(self, vdi_uuid, volume_name):
1303
1303
return (device_path , None )
1304
1304
1305
1305
# Otherwise it's a COW and a parent can exist.
1306
- linstorcowutil = LinstorCowUtil (self .session , self ._linstor , getCowUtil ( vdi_type ) )
1306
+ linstorcowutil = LinstorCowUtil (self .session , self ._linstor , vdi_type )
1307
1307
if linstorcowutil .check (vdi_uuid ) != cowutil .CheckResult .Success :
1308
1308
return (None , None )
1309
1309
@@ -1419,7 +1419,7 @@ def _undo_clone(self, volume_names, vdi_uuid, base_uuid, snap_uuid):
1419
1419
util .SMlog ('*** INTERRUPTED CLONE OP: rollback fail' )
1420
1420
return
1421
1421
1422
- linstorcowutil = LinstorCowUtil (self .session , self ._linstor , getCowUtil ( base_type ) )
1422
+ linstorcowutil = LinstorCowUtil (self .session , self ._linstor , base_type )
1423
1423
1424
1424
# Un-hide the parent.
1425
1425
self ._linstor .update_volume_metadata (base_uuid , {READ_ONLY_TAG : False })
@@ -1468,7 +1468,8 @@ def _undo_clone(self, volume_names, vdi_uuid, base_uuid, snap_uuid):
1468
1468
# Inflate to the right size.
1469
1469
if VdiType .isCowImage (base_type ):
1470
1470
vdi = self .vdi (vdi_uuid )
1471
- volume_size = linstorcowutil .compute_volume_size (vdi .size , vdi .vdi_type )
1471
+ linstorcowutil = LinstorCowUtil (self .session , self ._linstor , vdi .vdi_type )
1472
+ volume_size = linstorcowutil .compute_volume_size (vdi .size )
1472
1473
linstorcowutil .inflate (
1473
1474
self ._journaler , vdi_uuid , vdi .path ,
1474
1475
volume_size , vdi .capacity
@@ -1667,7 +1668,7 @@ def create(self, sr_uuid, vdi_uuid, size) -> str:
1667
1668
1668
1669
# 2. Compute size and check space available.
1669
1670
size = self .linstorcowutil .cowutil .validateAndRoundImageSize (int (size ))
1670
- volume_size = self .linstorcowutil .compute_volume_size (size , self . vdi_type )
1671
+ volume_size = self .linstorcowutil .compute_volume_size (size )
1671
1672
util .SMlog (
1672
1673
'LinstorVDI.create: type={}, cow-size={}, volume-size={}'
1673
1674
.format (self .vdi_type , size , volume_size )
@@ -1831,7 +1832,7 @@ def attach(self, sr_uuid, vdi_uuid) -> str:
1831
1832
if (
1832
1833
not VdiType .isCowImage (self .vdi_type ) or
1833
1834
not writable or
1834
- self .capacity >= self .linstorcowutil .compute_volume_size (self .size , self . vdi_type )
1835
+ self .capacity >= self .linstorcowutil .compute_volume_size (self .size )
1835
1836
):
1836
1837
need_inflate = False
1837
1838
@@ -1876,7 +1877,7 @@ def detach(self, sr_uuid, vdi_uuid) -> None:
1876
1877
1877
1878
# The VDI is already deflated if the COW image size + metadata is
1878
1879
# equal to the LINSTOR volume size.
1879
- volume_size = self .linstorcowutil .compute_volume_size (self .size , self . vdi_type )
1880
+ volume_size = self .linstorcowutil .compute_volume_size (self .size )
1880
1881
already_deflated = self .capacity <= volume_size
1881
1882
1882
1883
if already_deflated :
@@ -1939,7 +1940,7 @@ def resize(self, sr_uuid, vdi_uuid, size) -> str:
1939
1940
1940
1941
# Compute the virtual COW and DRBD volume size.
1941
1942
size = self .linstorcowutil .cowutil .validateAndRoundImageSize (int (size ))
1942
- volume_size = self .linstorcowutil .compute_volume_size (size , self . vdi_type )
1943
+ volume_size = self .linstorcowutil .compute_volume_size (size )
1943
1944
util .SMlog (
1944
1945
'LinstorVDI.resize: type={}, cow-size={}, volume-size={}'
1945
1946
.format (self .vdi_type , size , volume_size )
@@ -1964,7 +1965,7 @@ def resize(self, sr_uuid, vdi_uuid, size) -> str:
1964
1965
# VDI is currently deflated, so keep it deflated.
1965
1966
new_volume_size = old_volume_size
1966
1967
else :
1967
- new_volume_size = self .linstorcowutil .compute_volume_size (size , self . vdi_type )
1968
+ new_volume_size = self .linstorcowutil .compute_volume_size (size )
1968
1969
assert new_volume_size >= old_volume_size
1969
1970
1970
1971
space_needed = new_volume_size - old_volume_size
0 commit comments