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 '
48 self
.args
= parser
.parse_args(self
.argv
)
50 self
.format_report(Device(self
.args
.path
, with_lsm
=self
.args
.with_lsm
))
52 self
.format_report(Devices(filter_for_batch
=self
.args
.filter_for_batch
,
53 with_lsm
=self
.args
.with_lsm
))
57 return Device(self
.args
.path
, with_lsm
=self
.args
.with_lsm
).json_report()
59 return Devices(filter_for_batch
=self
.args
.filter_for_batch
, with_lsm
=self
.args
.with_lsm
).json_report()
61 def format_report(self
, inventory
):
62 if self
.args
.format
== 'json':
63 print(json
.dumps(inventory
.json_report()))
64 elif self
.args
.format
== 'json-pretty':
65 print(json
.dumps(inventory
.json_report(), indent
=4, sort_keys
=True))
67 print(inventory
.pretty_report())