mirror of
https://github.com/ceph/ceph
synced 2025-04-17 04:41:36 +00:00
ceph-volume lvm.batch use new Device class and validator
Signed-off-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
parent
21df602949
commit
d74ce8e54d
@ -2,6 +2,8 @@ import argparse
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from ceph_volume import terminal, decorators
|
from ceph_volume import terminal, decorators
|
||||||
from ceph_volume.util import disk, prompt_bool
|
from ceph_volume.util import disk, prompt_bool
|
||||||
|
from ceph_volume.util.device import Device
|
||||||
|
from ceph_volume.util import arg_validators
|
||||||
from . import strategies
|
from . import strategies
|
||||||
|
|
||||||
|
|
||||||
@ -56,12 +58,12 @@ def filestore_mixed_type(device_facts):
|
|||||||
Detect if devices are HDDs as well as solid state so that the journal can be
|
Detect if devices are HDDs as well as solid state so that the journal can be
|
||||||
placed in solid devices while data is kept in the spinning drives.
|
placed in solid devices while data is kept in the spinning drives.
|
||||||
"""
|
"""
|
||||||
types = [device['rotational'] for device in device_facts]
|
types = [device.sys_api['rotational'] for device in device_facts]
|
||||||
if len(set(types)) > 1:
|
if len(set(types)) > 1:
|
||||||
return strategies.filestore.MixedType
|
return strategies.filestore.MixedType
|
||||||
|
|
||||||
|
|
||||||
def get_strategy(devices, args):
|
def get_strategy(args):
|
||||||
"""
|
"""
|
||||||
Given a set of devices as input, go through the different detection
|
Given a set of devices as input, go through the different detection
|
||||||
mechanisms to narrow down on a strategy to use. The strategies are 4 in
|
mechanisms to narrow down on a strategy to use. The strategies are 4 in
|
||||||
@ -84,9 +86,9 @@ def get_strategy(devices, args):
|
|||||||
strategies = filestore_strategies
|
strategies = filestore_strategies
|
||||||
|
|
||||||
for strategy in strategies:
|
for strategy in strategies:
|
||||||
backend = strategy(devices)
|
backend = strategy(args.devices)
|
||||||
if backend:
|
if backend:
|
||||||
return backend(devices, args)
|
return backend(args.devices, args)
|
||||||
|
|
||||||
|
|
||||||
class Batch(object):
|
class Batch(object):
|
||||||
@ -126,25 +128,8 @@ class Batch(object):
|
|||||||
detected_devices=self.get_devices(),
|
detected_devices=self.get_devices(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_filtered_devices(self, devices):
|
|
||||||
"""
|
|
||||||
Parse all devices in the current system and keep only the ones that are
|
|
||||||
being explicity passed in
|
|
||||||
"""
|
|
||||||
system_devices = disk.get_devices()
|
|
||||||
if not devices:
|
|
||||||
return system_devices.values()
|
|
||||||
parsed_devices = []
|
|
||||||
for device in devices:
|
|
||||||
try:
|
|
||||||
parsed_devices.append(system_devices[device])
|
|
||||||
except KeyError:
|
|
||||||
continue
|
|
||||||
|
|
||||||
return parsed_devices
|
|
||||||
|
|
||||||
def report(self, args):
|
def report(self, args):
|
||||||
strategy = get_strategy(self.get_filtered_devices(args.devices), args)
|
strategy = get_strategy(args)
|
||||||
if args.format == 'pretty':
|
if args.format == 'pretty':
|
||||||
strategy.report_pretty()
|
strategy.report_pretty()
|
||||||
elif args.format == 'json':
|
elif args.format == 'json':
|
||||||
@ -175,6 +160,7 @@ class Batch(object):
|
|||||||
'devices',
|
'devices',
|
||||||
metavar='DEVICES',
|
metavar='DEVICES',
|
||||||
nargs='*',
|
nargs='*',
|
||||||
|
type=arg_validators.ValidDevice(),
|
||||||
default=[],
|
default=[],
|
||||||
help='Devices to provision OSDs',
|
help='Devices to provision OSDs',
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user