]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/plugin/zfs/ceph_volume_zfs/devices/zfs/inventory.py
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / ceph-volume / plugin / zfs / ceph_volume_zfs / devices / zfs / inventory.py
1 import argparse
2 import json
3 from textwrap import dedent
4
5 # import ceph_volume.process
6
7 from ceph_volume_zfs.util.disk import Disks
8
9 class Inventory(object):
10
11 help = 'Generate a list of available devices'
12
13 def __init__(self, argv):
14 self.argv = argv
15
16 def format_report(self, inventory):
17 if self.args.format == 'json':
18 print(json.dumps(inventory.json_report()))
19 elif self.args.format == 'json-pretty':
20 print(json.dumps(inventory.json_report(), indent=4, sort_keys=True))
21 else:
22 print(inventory.pretty_report())
23
24 def main(self):
25 sub_command_help = dedent("""
26 Generate an inventory of available devices
27 """)
28 parser = argparse.ArgumentParser(
29 prog='ceph-volume zfs inventory',
30 description=sub_command_help,
31 )
32 parser.add_argument(
33 'path',
34 nargs='?',
35 default=None,
36 help=('Report on specific disk'),
37 )
38 parser.add_argument(
39 '--format',
40 choices=['plain', 'json', 'json-pretty'],
41 default='plain',
42 help='Output format',
43 )
44
45 self.args = parser.parse_args(self.argv)
46 if self.args.path:
47 self.format_report(Disks(self.args.path))
48 else:
49 self.format_report(Disks())
50