Skip to content

Commit

Permalink
Merge pull request #290 from jschmid1/wip-pathbyid
Browse files Browse the repository at this point in the history
Internal vs external rep of disks
  • Loading branch information
jschmid1 authored May 29, 2017
2 parents 5eff34e + 10e48a8 commit 48c933d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions srv/salt/_modules/osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,8 @@ def configured(**kwargs):
if 'format' in kwargs and kwargs['format'] != 'filestore':
return []
log.debug("devices: {}".format(devices))
for device in devices:
# find real device
cmd = "readlink -f {}".format(device)
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
proc.wait()
result = proc.stdout.read().rstrip()
osds.append(result)
log.debug(pprint.pformat(result))
log.debug(pprint.pformat(proc.stderr.read()))
return osds

return devices

def list():
"""
Expand Down Expand Up @@ -322,7 +314,8 @@ def __init__(self, device, **kwargs):
filters = kwargs.get('filters', None)
# top_level_identifiier
self.tli = self._set_tli()
self.device = device
self.device = self.set_device(device)
self.by_id_path = device
self.capacity = self.set_capacity()
self.size = self.set_bytes()
self.small = self._set_small()
Expand Down Expand Up @@ -361,6 +354,18 @@ def set_bytes(self):
log.error(error)
raise RuntimeError(error)

def set_device(self, device):
"""
Return the short symlink for a by-id device path
"""
cmd = "readlink -f {}".format(device)
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
proc.wait()
result = proc.stdout.read().rstrip()
log.debug(pprint.pformat(result))
log.debug(pprint.pformat(proc.stderr.read()))
return result

def set_capacity(self):
"""
Return the capacity from the mine for this disk
Expand Down Expand Up @@ -741,7 +746,9 @@ def osd_partition(self):
TODO: dmcrypt
"""
device = self.osd.device
if 'osds' in self.settings and device in self.settings['osds']:
internal_ident = self.osd.by_id_path
# self.settings['osds'] holds the pillardata, hence the by-id path
if 'osds' in self.settings and internal_ident in self.settings['osds']:
if self.osd.disk_format == 'filestore':
if self.osd.journal:
# Journal on separate device
Expand Down

0 comments on commit 48c933d

Please sign in to comment.