aboutsummaryrefslogtreecommitdiff
path: root/docker/kolla-toolbox
diff options
context:
space:
mode:
authorSamYaple <sam@yaple.net>2016-03-18 13:52:32 +0000
committerSamYaple <sam@yaple.net>2016-03-19 22:36:30 +0000
commit5250a00781a214911fec78718ef6dfb91154b0de (patch)
treec5bd5bad7788f7b45d7377950a485b51cfb7fbcd /docker/kolla-toolbox
parent6d0cd535d34ac10f144ab5d909256364363e7f38 (diff)
downloadkolla-5250a00781a214911fec78718ef6dfb91154b0de.tar.gz
kolla-5250a00781a214911fec78718ef6dfb91154b0de.zip
Allow external ceph journals and fix bootstrap
This allows us to specify external journals for osds which can greatly improve performance when the external journals are on the solid-state drives. The new lookup and startup methods fix the previous races we had preventing osds from being created properly. This retains the same functionality as before and is completely compatible with the previous method and labels, however this does set new labels for all new bootstrap OSDs. This was due to a limitation in the length of the name of a GPT partition. Closes-Bug: #1558853 DocImpact Partially-Implements: blueprint ceph-improvements Change-Id: I61fd10cb35c67dabc53bd82270f26909ef51fc38
Diffstat (limited to 'docker/kolla-toolbox')
-rw-r--r--docker/kolla-toolbox/find_disks.py84
1 files changed, 60 insertions, 24 deletions
diff --git a/docker/kolla-toolbox/find_disks.py b/docker/kolla-toolbox/find_disks.py
index 6ebf2b6a2..e72dcc6fb 100644
--- a/docker/kolla-toolbox/find_disks.py
+++ b/docker/kolla-toolbox/find_disks.py
@@ -66,6 +66,61 @@ EXAMPLES = '''
import json
import pyudev
+import re
+
+
+def is_dev_matched_by_name(dev, name, mode):
+ if dev.get('DEVTYPE', '') == 'partition':
+ dev_name = dev.get('ID_PART_ENTRY_NAME', '')
+ else:
+ dev_name = dev.get('ID_FS_LABEL', '')
+
+ if mode == 'strict':
+ return dev_name == name
+ elif mode == 'prefix':
+ return dev_name.startswith(name)
+ else:
+ return False
+
+
+def find_disk(ct, name, match_mode):
+ for dev in ct.list_devices(subsystem='block'):
+ if is_dev_matched_by_name(dev, name, match_mode):
+ yield dev
+
+
+def extract_disk_info(ct, dev, name):
+ if not dev:
+ return
+ kwargs = dict()
+ kwargs['fs_uuid'] = dev.get('ID_FS_UUID', '')
+ kwargs['fs_label'] = dev.get('ID_FS_LABEL', '')
+ if dev.get('DEVTYPE', '') == 'partition':
+ kwargs['device'] = dev.find_parent('block').device_node
+ kwargs['partition'] = dev.device_node
+ kwargs['partition_num'] = \
+ re.sub(r'.*[^\d$]', '', dev.device_node)
+ if is_dev_matched_by_name(dev, name, 'strict'):
+ kwargs['external_journal'] = False
+ kwargs['journal'] = dev.device_node[:-1] + '2'
+ kwargs['journal_device'] = kwargs['device']
+ kwargs['journal_num'] = 2
+ else:
+ kwargs['external_journal'] = True
+ journal_name = dev.get('ID_PART_ENTRY_NAME', '') + '_J'
+ for journal in find_disk(ct, journal_name, 'strict'):
+ kwargs['journal'] = journal.device_node
+ kwargs['journal_device'] = \
+ journal.find_parent('block').device_node
+ kwargs['journal_num'] = \
+ re.sub(r'.*[^\d$]', '', journal.device_node)
+ break
+ if 'journal' not in kwargs:
+ # NOTE(SamYaple): Journal not found, not returning info
+ return
+ else:
+ kwargs['device'] = dev.device_node
+ yield kwargs
def main():
@@ -78,33 +133,14 @@ def main():
match_mode = module.params.get('match_mode')
name = module.params.get('name')
- def is_dev_matched_by_name(dev, name):
- if dev.get('DEVTYPE', '') == 'partition':
- dev_name = dev.get('ID_PART_ENTRY_NAME', '')
- else:
- dev_name = dev.get('ID_FS_LABEL', '')
-
- if match_mode == 'strict':
- return dev_name == name
- elif match_mode == 'prefix':
- return dev_name.startswith(name)
- else:
- return False
-
try:
ret = list()
ct = pyudev.Context()
- for dev in ct.list_devices(subsystem='block'):
- if is_dev_matched_by_name(dev, name):
- fs_uuid = dev.get('ID_FS_UUID', '')
- fs_label = dev.get('ID_FS_LABEL', '')
- if dev.get('DEVTYPE', '') == 'partition':
- device_node = dev.find_parent('block').device_node
- else:
- device_node = dev.device_node
- ret.append({'device': device_node,
- 'fs_uuid': fs_uuid,
- 'fs_label': fs_label})
+ for dev in find_disk(ct, name, match_mode):
+ for info in extract_disk_info(ct, dev, name):
+ if info:
+ ret.append(info)
+
module.exit_json(disks=json.dumps(ret))
except Exception as e:
module.exit_json(failed=True, msg=repr(e))