raise RuntimeError(
'OSD files not found, required "keyring" file is not present at: %s' % path
)
- for _file in os.listdir(path):
- file_path = os.path.join(path, _file)
+ for file_ in os.listdir(path):
+ file_path = os.path.join(path, file_)
+ file_json_key = file_
+ if file_.endswith('_dmcrypt'):
+ file_json_key = file_.rstrip('_dmcrypt')
+ logger.info(('reading file {}, stripping _dmcrypt',
+ 'suffix').format(file_))
if os.path.islink(file_path):
if os.path.exists(file_path):
- osd_metadata[_file] = self.scan_device(file_path)
+ osd_metadata[file_json_key] = self.scan_device(file_path)
else:
msg = 'broken symlink found %s -> %s' % (file_path, os.path.realpath(file_path))
terminal.warning(msg)
if 'keyring' in file_path:
content = parse_keyring(content)
try:
- osd_metadata[_file] = int(content)
+ osd_metadata[file_json_key] = int(content)
except ValueError:
- osd_metadata[_file] = content
+ osd_metadata[file_json_key] = content
# we must scan the paths again because this might be a temporary mount
path_mounts = system.get_mounts(paths=True)