From: Alfredo Deza Date: Fri, 29 Jun 2018 15:33:46 +0000 (-0400) Subject: ceph-volume lvm.auto move auto as a sub-command of lvm X-Git-Tag: v12.2.8~10^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5c86d96db698353bf40c21c2cffd761889960cbc;p=ceph.git ceph-volume lvm.auto move auto as a sub-command of lvm Signed-off-by: Alfredo Deza (cherry picked from commit 7fa5317e2f911f94c867a344c2c5cc5441a63db1) --- diff --git a/src/ceph-volume/ceph_volume/devices/auto/__init__.py b/src/ceph-volume/ceph_volume/devices/auto/__init__.py deleted file mode 100644 index 03faa2d2e48..00000000000 --- a/src/ceph-volume/ceph_volume/devices/auto/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from main import Auto # noqa diff --git a/src/ceph-volume/ceph_volume/devices/auto/main.py b/src/ceph-volume/ceph_volume/devices/auto/main.py deleted file mode 100644 index d9b50195f74..00000000000 --- a/src/ceph-volume/ceph_volume/devices/auto/main.py +++ /dev/null @@ -1,70 +0,0 @@ -import argparse -from textwrap import dedent -from ceph_volume import terminal, decorators -from ceph_volume.util import disk - - -device_list_template = """ - * {path: <25} {size: <10} {state}""" - - -def device_formatter(devices): - lines = [] - for path, details in devices: - lines.append(device_list_template.format( - path=path, size=details['human_readable_size'], - state='solid' if details['rotational'] == '0' else 'rotational') - ) - - return ''.join(lines) - - -class Auto(object): - - help = 'Auto-detect devices for multi-OSD provisioning with minimal interaction' - - _help = dedent(""" - Automatically detect devices ready for OSD provisioning based on configurable strategies. - - Detected devices: - {detected_devices} - - Current strategy: {strategy_name} - Path: {strategy_path} - - """) - - # TODO: add the reporting sub-command here (list?) - mapper = { - } - - def __init__(self, argv): - self.argv = argv - - def get_devices(self): - all_devices = disk.get_devices() - # remove devices with partitions - # XXX Should be optional when getting device info - for device, detail in all_devices.items(): - if detail.get('partitions') != {}: - del all_devices[device] - devices = sorted(all_devices.items(), key=lambda x: (x[0], x[1]['size'])) - return device_formatter(devices) - - def print_help(self, sub_help): - return self._help.format( - detected_devices=self.get_devices(), - strategy_name='default', - strategy_path='/etc/ceph/osd/strategies/default') - - @decorators.needs_root - def main(self): - terminal.dispatch(self.mapper, self.argv) - parser = argparse.ArgumentParser( - prog='ceph-volume auto', - formatter_class=argparse.RawDescriptionHelpFormatter, - description=self.print_help(terminal.subhelp(self.mapper)), - ) - parser.parse_args(self.argv) - if len(self.argv) <= 1: - return parser.print_help() diff --git a/src/ceph-volume/ceph_volume/devices/lvm/auto.py b/src/ceph-volume/ceph_volume/devices/lvm/auto.py new file mode 100644 index 00000000000..d9b50195f74 --- /dev/null +++ b/src/ceph-volume/ceph_volume/devices/lvm/auto.py @@ -0,0 +1,70 @@ +import argparse +from textwrap import dedent +from ceph_volume import terminal, decorators +from ceph_volume.util import disk + + +device_list_template = """ + * {path: <25} {size: <10} {state}""" + + +def device_formatter(devices): + lines = [] + for path, details in devices: + lines.append(device_list_template.format( + path=path, size=details['human_readable_size'], + state='solid' if details['rotational'] == '0' else 'rotational') + ) + + return ''.join(lines) + + +class Auto(object): + + help = 'Auto-detect devices for multi-OSD provisioning with minimal interaction' + + _help = dedent(""" + Automatically detect devices ready for OSD provisioning based on configurable strategies. + + Detected devices: + {detected_devices} + + Current strategy: {strategy_name} + Path: {strategy_path} + + """) + + # TODO: add the reporting sub-command here (list?) + mapper = { + } + + def __init__(self, argv): + self.argv = argv + + def get_devices(self): + all_devices = disk.get_devices() + # remove devices with partitions + # XXX Should be optional when getting device info + for device, detail in all_devices.items(): + if detail.get('partitions') != {}: + del all_devices[device] + devices = sorted(all_devices.items(), key=lambda x: (x[0], x[1]['size'])) + return device_formatter(devices) + + def print_help(self, sub_help): + return self._help.format( + detected_devices=self.get_devices(), + strategy_name='default', + strategy_path='/etc/ceph/osd/strategies/default') + + @decorators.needs_root + def main(self): + terminal.dispatch(self.mapper, self.argv) + parser = argparse.ArgumentParser( + prog='ceph-volume auto', + formatter_class=argparse.RawDescriptionHelpFormatter, + description=self.print_help(terminal.subhelp(self.mapper)), + ) + parser.parse_args(self.argv) + if len(self.argv) <= 1: + return parser.print_help()