Skip to content

Commit

Permalink
salt/volume: update device_info to handle noformat volume
Browse files Browse the repository at this point in the history
Refs: #2421
Signed-off-by: Sylvain Laperche <[email protected]>
  • Loading branch information
slaperche-scality committed Jul 3, 2020
1 parent ad254f3 commit 508c0e3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions salt/_modules/metalk8s_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,19 @@ def clean_up(self):

def device_info(self):
"""Return size and path of the underlying block device"""
path = '/dev/disk/by-uuid/{}'.format(self.get('metadata.uid'))
size = __salt__['disk.dump'](path)['getsize64']
return {'size': size, 'path': path}
size = __salt__['disk.dump'](self.persistent_path)['getsize64']
return {'size': size, 'path': self.persistent_path}

@abc.abstractproperty
def path(self):
"""Path to the backing device."""
return

@property
def persistent_path(self):
"""Return a persistent path to the backing device."""
return '/dev/disk/by-uuid/{}'.format(self.get('metadata.uid'))

@property
def is_prepared(self):
"""Check if the volume is already prepared by us."""
Expand Down Expand Up @@ -314,10 +318,6 @@ def path(self):
self.get('metadata.uid')
)

@property
def device_path(self):
return '/dev/disk/by-uuid/{}'.format(self.get('metadata.uid'))

@property
def size(self):
return _quantity_to_bytes(self.get('spec.sparseLoopDevice.size'))
Expand Down Expand Up @@ -368,7 +368,7 @@ def is_cleaned_up(self):
def clean_up(self):
LOOP_CLR_FD = 0x4C01 # From /usr/include/linux/loop.h
try:
with _open_fd(self.device_path, os.O_RDONLY) as fd:
with _open_fd(self.persistent_path, os.O_RDONLY) as fd:
fcntl.ioctl(fd, LOOP_CLR_FD, 0)
os.remove(self.path)
except OSError as exn:
Expand All @@ -383,7 +383,7 @@ class SparseLoopDeviceNoFormat(SparseLoopDevice):
PROVISIONING_COMMAND = ('losetup', '--find', '--partscan')

@property
def device_path(self):
def persistent_path(self):
return '/dev/disk/by-partlabel/{}'.format(self.get('metadata.uid'))

@property
Expand Down

0 comments on commit 508c0e3

Please sign in to comment.