summaryrefslogtreecommitdiffstats
path: root/commands/storage/lmi
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2014-02-17 10:10:30 +0100
committerJan Safranek <jsafrane@redhat.com>2014-02-17 10:10:30 +0100
commite8c6f0034bed952fe4c20cd8204253f0d0698b84 (patch)
treec13edadf970123fd5dba061f8205dabc6b2b86f2 /commands/storage/lmi
parent79480a0f6904f45a65a276828b6df4d101ef1567 (diff)
downloadopenlmi-scripts-e8c6f0034bed952fe4c20cd8204253f0d0698b84.tar.gz
openlmi-scripts-e8c6f0034bed952fe4c20cd8204253f0d0698b84.tar.xz
openlmi-scripts-e8c6f0034bed952fe4c20cd8204253f0d0698b84.zip
Introduce 'lmi storage' multiplexer.
All storage commands are now under 'lmi storage'.
Diffstat (limited to 'commands/storage/lmi')
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/__init__.py35
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/fs.py (renamed from commands/storage/lmi/scripts/storage/fs_cmd.py)50
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/lv.py (renamed from commands/storage/lmi/scripts/storage/lv_cmd.py)41
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/mount.py (renamed from commands/storage/lmi/scripts/storage/mount_cmd.py)55
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/partition.py (renamed from commands/storage/lmi/scripts/storage/partition_cmd.py)38
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/partition_table.py (renamed from commands/storage/lmi/scripts/storage/partitiontable_cmd.py)35
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/raid.py (renamed from commands/storage/lmi/scripts/storage/raid_cmd.py)38
-rw-r--r--commands/storage/lmi/scripts/storage/cmd/vg.py (renamed from commands/storage/lmi/scripts/storage/vg_cmd.py)38
-rw-r--r--commands/storage/lmi/scripts/storage/storage_cmd.py58
9 files changed, 248 insertions, 140 deletions
diff --git a/commands/storage/lmi/scripts/storage/cmd/__init__.py b/commands/storage/lmi/scripts/storage/cmd/__init__.py
new file mode 100644
index 0000000..2053981
--- /dev/null
+++ b/commands/storage/lmi/scripts/storage/cmd/__init__.py
@@ -0,0 +1,35 @@
+# Storage Management Providers
+#
+# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of the FreeBSD Project.
+#
+# Authors: Jan Safranek <jsafrane@redhat.com>
+#
+"""
+LMI storage provider command multiplexer. To be used only by 'lmi' command
+line utility.
+"""
diff --git a/commands/storage/lmi/scripts/storage/fs_cmd.py b/commands/storage/lmi/scripts/storage/cmd/fs.py
index 7623bd5..038cfc0 100644
--- a/commands/storage/lmi/scripts/storage/fs_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/fs.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
Filesystem and other data format management.
@@ -40,11 +40,11 @@ Usage:
%(cmd)s list-supported
Commands:
- list List filesystems and and other data formats (RAID metadata, ...)
- on given devices.
+ list List filesystems and and other data formats (RAID metadata,
+ ...) on given devices.
If no devices are provided, all filesystems are listed.
- If --all option is set, all filesystem, including system ones
- like tmpfs, cgroups, procfs, sysfs etc are listed.
+ If --all option is set, all filesystem, including system
+ ones like tmpfs, cgroups, procfs, sysfs etc are listed.
create Format device(s) with given filesystem.
If more devices are given, the filesystem will span
@@ -53,8 +53,8 @@ Commands:
For list of available filesystem types, see output of
%(cmd)s list-supported.
- delete Delete given filesystem or data format (like partition table,
- RAID metadata, LUKS, physical volume metadata etc)
+ delete Delete given filesystem or data format (like partition
+ table, RAID metadata, LUKS, physical volume metadata etc)
on given devices.
list-supported
@@ -62,10 +62,17 @@ Commands:
%(cmd)s create <fstype> option.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import fs
+from lmi.scripts.common import get_logger
+from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
-class Lister(command.LmiLister):
+LOG = get_logger(__name__)
+
+class FSList(command.LmiLister):
COLUMNS = ('Device', 'Name', "ElementName", "Type")
def transform_options(self, options):
@@ -98,7 +105,7 @@ class Lister(command.LmiLister):
yield (devname, name, label, fstype)
-class ListSupported(command.LmiLister):
+class FSListSupported(command.LmiLister):
COLUMNS = ('Filesystem',)
def execute(self, ns):
@@ -112,7 +119,7 @@ class ListSupported(command.LmiLister):
yield [fsname.lower()]
-class Create(command.LmiCheckResult):
+class FSCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -129,7 +136,7 @@ class Create(command.LmiCheckResult):
fs.create_fs(ns, devices, fstype, _label)
-class Delete(command.LmiCheckResult):
+class FSDelete(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -146,12 +153,11 @@ class Delete(command.LmiCheckResult):
for dev in devices:
fs.delete_format(ns, dev)
-
-Fs = command.register_subcommands(
- 'fs', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'delete' : Delete,
- 'list-supported': ListSupported,
- },
- )
+class FS(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : FSList,
+ 'create' : FSCreate,
+ 'delete' : FSDelete,
+ 'list-supported': FSListSupported,
+ }
diff --git a/commands/storage/lmi/scripts/storage/lv_cmd.py b/commands/storage/lmi/scripts/storage/cmd/lv.py
index 51d9f2e..bee5fcb 100644
--- a/commands/storage/lmi/scripts/storage/lv_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/lv.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
Logical Volume management.
@@ -58,19 +58,24 @@ Options:
'T', 'G', 'M' or 'K' suffix can be used to use specify other
units (TiB, GiB, MiB and KiB) - '1K' specifies 1 KiB
(= 1024 bytes).
- The suffix is case insensitive, i.e. 1g = 1G = 1073741824 bytes.
+ The suffix is case insensitive, i.e. 1g = 1G = 1073741824
+ bytes.
'E' suffix can be used to specify number of volume group
extents, '100e' means 100 extents.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import lvm, show
-from lmi.scripts.storage.common import str2size, size2str, str2device, str2vg
-from lmi.scripts.common import formatter
+from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
+LOG = get_logger(__name__)
-class Lister(command.LmiLister):
+class LVList(command.LmiLister):
COLUMNS = ('DeviceID', "Name", "ElementName", "Size")
def transform_options(self, options):
@@ -93,7 +98,7 @@ class Lister(command.LmiLister):
size)
-class Create(command.LmiCheckResult):
+class LVCreate(command.LmiCheckResult):
EXPECT = None
def execute(self, ns, vg, name, size):
@@ -104,7 +109,7 @@ class Create(command.LmiCheckResult):
lvm.create_lv(ns, vg, name, str2size(size, vg.ExtentSize, 'E'))
-class Delete(command.LmiCheckResult):
+class LVDelete(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -122,7 +127,7 @@ class Delete(command.LmiCheckResult):
lvm.delete_lv(ns, lv)
-class Show(command.LmiLister):
+class LVShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
def transform_options(self, options):
@@ -145,12 +150,12 @@ class Show(command.LmiLister):
for line in show.lv_show(ns, lv, self.app.config.human_friendly):
yield line
+class LV(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : LVList,
+ 'create' : LVCreate,
+ 'delete' : LVDelete,
+ 'show' : LVShow,
+ }
-Lv = command.register_subcommands(
- 'Lv', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'delete' : Delete,
- 'show' : Show,
- },
- )
diff --git a/commands/storage/lmi/scripts/storage/mount_cmd.py b/commands/storage/lmi/scripts/storage/cmd/mount.py
index 97a18d9..5107924 100644
--- a/commands/storage/lmi/scripts/storage/mount_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/mount.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -28,6 +29,7 @@
# policies, either expressed or implied, of the FreeBSD Project.
#
# Authors: Jan Synacek <jsynacek@redhat.com>
+# Jan Safranek <jsafrane@redhat.com>
#
"""
Mount management.
@@ -80,11 +82,15 @@ Commands:
attached to them. Optionally, show all mounted filesystems.
"""
-from lmi.scripts.common import command, get_logger
-from lmi.scripts.common.errors import LmiFailed
+from lmi.shell.LMIUtil import lmi_isinstance
+from lmi.scripts.common import command
+from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
-from lmi.scripts.storage import mount
-from lmi.scripts.storage.common import str2device
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
+LOG = get_logger(__name__)
def get_mounts_for_devices(ns, devices):
"""
@@ -99,9 +105,8 @@ def get_mounts_for_devices(ns, devices):
mounts += fs.associators(ResultClass="LMI_MountedFileSystem")
return mounts
-class Lister(command.LmiLister):
+class MountList(command.LmiLister):
COLUMNS = ('FileSystemSpec', 'FileSystemType', 'MountPointPath', 'Options', 'OtherOptions')
- OPT_NO_UNDERSCORES = True
def transform_options(self, options):
"""
@@ -110,7 +115,7 @@ class Lister(command.LmiLister):
"""
options['<devices>'] = options.pop('<device>')
- def execute(self, ns, all=None, devices=None):
+ def execute(self, ns, devices=None, _all=None):
"""
Implementation of 'mount list' command.
"""
@@ -119,7 +124,7 @@ class Lister(command.LmiLister):
else:
mounts = mount.get_mounts(ns)
- if all is False:
+ if _all is False:
transients = [mnt.Name for mnt in ns.LMI_TransientFileSystem.instances()]
for mnt in mounts:
@@ -128,7 +133,7 @@ class Lister(command.LmiLister):
if mnt.FileSystemSpec == 'rootfs':
continue
- if all is False and mnt.MountPointPath != '/':
+ if _all is False and mnt.MountPointPath != '/':
# do not list nodevice filesystems
name = 'PATH=' + mnt.MountPointPath
if name in transients:
@@ -142,9 +147,8 @@ class Lister(command.LmiLister):
opts_str[0],
opts_str[1])
-class Show(command.LmiLister):
+class MountShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
- OPT_NO_UNDERSCORES = True
def transform_options(self, options):
"""
@@ -154,7 +158,7 @@ class Show(command.LmiLister):
options['<devices>'] = options.pop('<device>')
- def execute(self, ns, all=None, devices=None):
+ def execute(self, ns, _all=None, devices=None):
"""
Implementation of 'mount show' command.
"""
@@ -163,7 +167,7 @@ class Show(command.LmiLister):
else:
mounts = mount.get_mounts(ns)
- if all is False:
+ if _all is False:
transients = [mnt.Name for mnt in ns.LMI_TransientFileSystem.instances()]
yield fcmd.NewTableCommand('Mounted filesystems')
@@ -173,7 +177,7 @@ class Show(command.LmiLister):
if mnt.FileSystemSpec == 'rootfs':
continue
- if all is False and mnt.MountPointPath != '/':
+ if _all is False and mnt.MountPointPath != '/':
# do not list nodevice filesystems
name = 'PATH=' + mnt.MountPointPath
if name in transients:
@@ -187,7 +191,7 @@ class Show(command.LmiLister):
yield('OtherOptions', opts_str[1])
yield ''
-class Create(command.LmiCheckResult):
+class MountCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -204,7 +208,7 @@ class Create(command.LmiCheckResult):
"""
return mount.mount_create(ns, device, mountpoint, fs_type, options, other_options)
-class Delete(command.LmiCheckResult):
+class MountDelete(command.LmiCheckResult):
EXPECT = None
def execute(self, ns, target):
@@ -213,11 +217,12 @@ class Delete(command.LmiCheckResult):
"""
return mount.mount_delete(ns, target)
-Mount = command.register_subcommands(
- 'Mount', __doc__,
- { 'list' : Lister,
- 'create' : Create,
- 'delete' : Delete,
- 'show' : Show,
- },
- )
+class Mount(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : MountList,
+ 'create' : MountCreate,
+ 'delete' : MountDelete,
+ 'show' : MountShow,
+ }
+
diff --git a/commands/storage/lmi/scripts/storage/partition_cmd.py b/commands/storage/lmi/scripts/storage/cmd/partition.py
index fbb3552..ae514ea 100644
--- a/commands/storage/lmi/scripts/storage/partition_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/partition.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
Partition management.
@@ -97,13 +97,17 @@ Options:
--extended Override the automatic behavior and request extended partition.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import partition, show
-from lmi.scripts.storage.common import str2size, str2device, size2str
-from lmi.scripts.common import formatter
+from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
+LOG = get_logger(__name__)
-class Lister(command.LmiLister):
+class PartitionList(command.LmiLister):
COLUMNS = ('DeviceID', "Name", "ElementName", "Type", "Size")
def transform_options(self, options):
@@ -138,7 +142,7 @@ class Lister(command.LmiLister):
size)
-class Create(command.LmiCheckResult):
+class PartitionCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
"""
@@ -165,7 +169,7 @@ class Create(command.LmiCheckResult):
print "Partition %s, with DeviceID %s created." % (p.Name, p.DeviceID)
-class Delete(command.LmiCheckResult):
+class PartitionDelete(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -183,7 +187,7 @@ class Delete(command.LmiCheckResult):
partition.delete_partition(ns, part)
-class Show(command.LmiLister):
+class PartitionShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
def transform_options(self, options):
@@ -207,12 +211,12 @@ class Show(command.LmiLister):
self.app.config.human_friendly):
yield line
+class Partition(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : PartitionList,
+ 'create' : PartitionCreate,
+ 'delete' : PartitionDelete,
+ 'show' : PartitionShow,
+ }
-Partition = command.register_subcommands(
- 'Partition', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'delete' : Delete,
- 'show' : Show,
- },
- )
diff --git a/commands/storage/lmi/scripts/storage/partitiontable_cmd.py b/commands/storage/lmi/scripts/storage/cmd/partition_table.py
index 33ea3f8..d10736e 100644
--- a/commands/storage/lmi/scripts/storage/partitiontable_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/partition_table.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
Partition table management.
@@ -70,15 +70,17 @@ Options:
--msdos Create MS-DOS partition table.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import partition, show
-from lmi.scripts.storage.common import size2str, str2device
-from lmi.scripts.common import formatter
-from lmi.scripts.common.formatter import command as fcmd
from lmi.scripts.common import get_logger
+from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
LOG = get_logger(__name__)
-class Lister(command.LmiLister):
+class PartitionTableList(command.LmiLister):
COLUMNS = ('DeviceID', 'Name', 'ElementName', 'Type', 'Largest free region')
def transform_options(self, options):
@@ -113,7 +115,7 @@ class Lister(command.LmiLister):
)
-class Create(command.LmiCheckResult):
+class PartitionTableCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -135,7 +137,7 @@ class Create(command.LmiCheckResult):
partition.create_partition_table(ns, device, ptype)
-class Show(command.LmiLister):
+class PartitionTableShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
def transform_options(self, options):
@@ -160,10 +162,11 @@ class Show(command.LmiLister):
ns, device, self.app.config.human_friendly):
yield line
-PartitionTable = command.register_subcommands(
- 'PartitionTable', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'show' : Show,
- },
- )
+class PartitionTable(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : PartitionTableList,
+ 'create' : PartitionTableCreate,
+ 'show' : PartitionTableShow,
+ }
+
diff --git a/commands/storage/lmi/scripts/storage/raid_cmd.py b/commands/storage/lmi/scripts/storage/cmd/raid.py
index 35bf748..c519d9d 100644
--- a/commands/storage/lmi/scripts/storage/raid_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/raid.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
MD RAID management.
@@ -69,13 +69,17 @@ Options:
level RAID level. Supported levels are: 0, 1, 4, 5, 6, 10.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import raid, show
-from lmi.scripts.storage.common import str2device
-from lmi.scripts.common import formatter
+from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
+LOG = get_logger(__name__)
-class Lister(command.LmiLister):
+class RaidList(command.LmiLister):
COLUMNS = ('DeviceID', 'Name', "Level", "Nr. of members")
def execute(self, ns):
@@ -87,7 +91,7 @@ class Lister(command.LmiLister):
yield (r.DeviceID, r.ElementName, r.Level, len(members))
-class Create(command.LmiCheckResult):
+class RaidCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -104,7 +108,7 @@ class Create(command.LmiCheckResult):
raid.create_raid(ns, devices, int(level), _name)
-class Delete(command.LmiCheckResult):
+class RaidDelete(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -122,7 +126,7 @@ class Delete(command.LmiCheckResult):
raid.delete_raid(ns, dev)
-class Show(command.LmiLister):
+class RaidShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
def transform_options(self, options):
@@ -145,12 +149,12 @@ class Show(command.LmiLister):
for line in show.raid_show(ns, r, self.app.config.human_friendly):
yield line
+class Raid(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : RaidList,
+ 'create' : RaidCreate,
+ 'delete' : RaidDelete,
+ 'show' : RaidShow,
+ }
-Raid = command.register_subcommands(
- 'raid', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'delete' : Delete,
- 'show' : Show,
- },
- )
diff --git a/commands/storage/lmi/scripts/storage/vg_cmd.py b/commands/storage/lmi/scripts/storage/cmd/vg.py
index c2b0dc1..5a2a61d 100644
--- a/commands/storage/lmi/scripts/storage/vg_cmd.py
+++ b/commands/storage/lmi/scripts/storage/cmd/vg.py
@@ -1,6 +1,7 @@
+# coding=utf-8
# Storage Management Providers
#
-# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -29,7 +30,6 @@
#
# Authors: Jan Safranek <jsafrane@redhat.com>
#
-
"""
Volume Group management.
@@ -76,12 +76,17 @@ Options:
The suffix is case insensitive, i.e. 1g = 1G = 1073741824 bytes.
"""
+from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
-from lmi.scripts.storage import lvm, show
-from lmi.scripts.storage.common import str2size, size2str, str2vg
+from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
+from lmi.scripts.storage.common import (size2str, get_devices, get_children,
+ get_parents, str2device, str2size, str2vg)
+
+LOG = get_logger(__name__)
-class Lister(command.LmiLister):
+class VGList(command.LmiLister):
COLUMNS = ('InstanceID', 'ElementName', "ExtentSize", "Total space",
"Free space")
@@ -103,7 +108,7 @@ class Lister(command.LmiLister):
remaining_space)
-class Create(command.LmiCheckResult):
+class VGCreate(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -122,7 +127,7 @@ class Create(command.LmiCheckResult):
lvm.create_vg(ns, devices, name, _extent_size)
-class Delete(command.LmiCheckResult):
+class VGDelete(command.LmiCheckResult):
EXPECT = None
def transform_options(self, options):
@@ -140,7 +145,7 @@ class Delete(command.LmiCheckResult):
lvm.delete_vg(ns, vg)
-class Show(command.LmiLister):
+class VGShow(command.LmiLister):
COLUMNS = ('Name', 'Value')
def transform_options(self, options):
@@ -163,12 +168,13 @@ class Show(command.LmiLister):
for line in show.vg_show(ns, vg, self.app.config.human_friendly):
yield line
+class VG(command.LmiCommandMultiplexer):
+ OWN_USAGE = __doc__
+ COMMANDS = {
+ 'list' : VGList,
+ 'create' : VGCreate,
+ 'delete' : VGDelete,
+ 'show' : VGShow,
+ }
+
-Vg = command.register_subcommands(
- 'vg', __doc__,
- { 'list' : Lister ,
- 'create' : Create,
- 'delete' : Delete,
- 'show' : Show,
- },
- )
diff --git a/commands/storage/lmi/scripts/storage/storage_cmd.py b/commands/storage/lmi/scripts/storage/storage_cmd.py
index 80641df..b4b750f 100644
--- a/commands/storage/lmi/scripts/storage/storage_cmd.py
+++ b/commands/storage/lmi/scripts/storage/storage_cmd.py
@@ -35,13 +35,34 @@
Basic storage device information.
Usage:
- %(cmd)s list [ <device> ...]
+ %(cmd)s fs <cmd> [<args> ...]
+ %(cmd)s lv <cmd> [<args> ...]
+ %(cmd)s mount <cmd> [<args> ...]
+ %(cmd)s partition <cmd> [<args> ...]
+ %(cmd)s partition-table <cmd> [<args> ...]
+ %(cmd)s raid <cmd> [<args> ...]
+ %(cmd)s vg <cmd> [<args> ...]
%(cmd)s depends [ --deep ] [ <device> ...]
+ %(cmd)s list [ <device> ...]
%(cmd)s provides [ --deep ] [ <device> ...]
%(cmd)s show [ <device> ...]
%(cmd)s tree [ <device> ]
Commands:
+ fs Filesystem and other data format management.
+
+ lv Logical Volume management.
+
+ mount Mount management.
+
+ partition Partition management.
+
+ partition-table Partition table management.
+
+ raid MD RAID management.
+
+ vg Volume Group management.
+
list List short information about given device. If no devices
are given, all devices are listed.
@@ -51,7 +72,7 @@ Commands:
provides Show devices, which are created from given devices
(= show children of the devices).
- For example, if disk is provided, all partitions on it are
+ For example, if a disk is provided, all partitions on it are
returned. If 'deep' is used, all RAIDs, Volume Groups and
Logical Volumes indirectly allocated from it are returned too.
@@ -60,11 +81,9 @@ Commands:
For example, if a Logical Volume is provided, its Volume Group
is returned. If 'deep' is used, also all Physical Volumes and
- disk are returned.
+ appropriate disk(s) are returned.
tree Show tree of devices, similar to lsblk.
- (Note that the output is really crude and needs to be worked
- on).
If no device is provided, all devices are shown, starting
with physical disks.
@@ -72,6 +91,7 @@ Commands:
If a device is provided, tree starts with the device
and all dependent devices are shown.
+
Options:
device Identifier of the device. Either one of:
@@ -98,12 +118,24 @@ from lmi.shell.LMIUtil import lmi_isinstance
from lmi.scripts.common import command
from lmi.scripts.common import get_logger
from lmi.scripts.common.formatter import command as fcmd
-from lmi.scripts.storage import show, fs
+from lmi.scripts.storage import show, fs, lvm, mount, raid, partition
from lmi.scripts.storage.common import (size2str, get_devices, get_children,
- get_parents, str2device)
-from lmi.scripts.storage.lvm import get_vgs
+ get_parents, str2device, str2size, str2vg)
+
+import lmi.scripts.storage.cmd.fs
+import lmi.scripts.storage.cmd.lv
+import lmi.scripts.storage.cmd.mount
+import lmi.scripts.storage.cmd.partition
+import lmi.scripts.storage.cmd.partition_table
+import lmi.scripts.storage.cmd.raid
+import lmi.scripts.storage.cmd.vg
+
LOG = get_logger(__name__)
+##############################################################################
+# Storage
+##############################################################################
+
def get_device_info(ns, device, human_friendly):
"""
Return detailed information of the device to show.
@@ -274,7 +306,7 @@ class Tree(command.LmiLister):
for dev in get_devices(ns):
devices[self.get_obj_id(ns, dev)] = dev
# Add *all* LMI_VGStoragePools.
- for vg in get_vgs(ns):
+ for vg in lvm.get_vgs(ns):
devices[self.get_obj_id(ns, vg)] = vg
# deps = array of tuples (parent devid, child devid)
@@ -372,5 +404,13 @@ Storage = command.register_subcommands(
'tree' : Tree,
'provides': Provides,
'depends' : Depends,
+ 'fs' : lmi.scripts.storage.cmd.fs.FS,
+ 'lv' : lmi.scripts.storage.cmd.lv.LV,
+ 'mount' : lmi.scripts.storage.cmd.mount.Mount,
+ 'partition': lmi.scripts.storage.cmd.partition.Partition,
+ 'partition-table': lmi.scripts.storage.cmd.partition_table.PartitionTable,
+ 'raid' : lmi.scripts.storage.cmd.raid.Raid,
+ 'vg' : lmi.scripts.storage.cmd.vg.VG,
},
)
+