1 # -*- coding: utf-8 -*-
6 from ceph_volume
.util
.device
import Devices
, Device
9 class Inventory(object):
11 help = "Get this nodes available disk inventory"
13 def __init__(self
, argv
):
17 parser
= argparse
.ArgumentParser(
18 prog
='ceph-volume inventory',
19 formatter_class
=argparse
.RawDescriptionHelpFormatter
,
20 description
=self
.help,
26 help=('Report on specific disk'),
30 choices
=['plain', 'json', 'json-pretty'],
37 help=('Filter devices unsuitable to pass to an OSD service spec, '
38 'no effect when <path> is passed'),
44 help=('Attempt to retrieve additional health and metadata through '
51 help=('Whether ceph-volume should list lvm devices'),
54 self
.args
= parser
.parse_args(self
.argv
)
56 self
.format_report(Device(self
.args
.path
, with_lsm
=self
.args
.with_lsm
))
58 self
.format_report(Devices(filter_for_batch
=self
.args
.filter_for_batch
,
59 with_lsm
=self
.args
.with_lsm
,
60 list_all
=self
.args
.list_all
))
64 return Device(self
.args
.path
, with_lsm
=self
.args
.with_lsm
).json_report()
66 return Devices(filter_for_batch
=self
.args
.filter_for_batch
,
67 with_lsm
=self
.args
.with_lsm
,
68 list_all
=self
.args
.list_all
).json_report()
70 def format_report(self
, inventory
):
71 if self
.args
.format
== 'json':
72 print(json
.dumps(inventory
.json_report()))
73 elif self
.args
.format
== 'json-pretty':
74 print(json
.dumps(inventory
.json_report(), indent
=4, sort_keys
=True))
76 print(inventory
.pretty_report())