diff options
author | Jan Safranek <jsafrane@redhat.com> | 2013-08-13 15:59:27 +0200 |
---|---|---|
committer | Jan Safranek <jsafrane@redhat.com> | 2013-08-13 16:37:10 +0200 |
commit | 3d3807cd5b48a8e36fa362c90ea792ff33d41bf3 (patch) | |
tree | 600bcd34ce5aa1bcc4398fcfe53aa6b000050fcc /commands/storage | |
parent | 4a343dfa4722672a365cac643a170748012b4869 (diff) | |
download | openlmi-scripts-3d3807cd5b48a8e36fa362c90ea792ff33d41bf3.tar.gz openlmi-scripts-3d3807cd5b48a8e36fa362c90ea792ff33d41bf3.tar.xz openlmi-scripts-3d3807cd5b48a8e36fa362c90ea792ff33d41bf3.zip |
Add documentation
Diffstat (limited to 'commands/storage')
-rw-r--r-- | commands/storage/doc/Makefile | 153 | ||||
-rw-r--r-- | commands/storage/doc/common.rst | 7 | ||||
-rw-r--r-- | commands/storage/doc/conf.py | 242 | ||||
-rw-r--r-- | commands/storage/doc/fs.rst | 7 | ||||
-rw-r--r-- | commands/storage/doc/index.rst | 25 | ||||
-rw-r--r-- | commands/storage/doc/lvm.rst | 7 | ||||
-rw-r--r-- | commands/storage/doc/partition.rst | 7 | ||||
-rw-r--r-- | commands/storage/doc/raid.rst | 7 | ||||
-rw-r--r-- | commands/storage/doc/show.rst | 7 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/common.py | 71 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/fs.py | 126 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/lvm.py | 93 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/partition.py | 105 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/partitiontable_cmd.py | 3 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/raid.py | 38 | ||||
-rw-r--r-- | commands/storage/lmi/scripts/storage/show.py | 52 |
16 files changed, 701 insertions, 249 deletions
diff --git a/commands/storage/doc/Makefile b/commands/storage/doc/Makefile new file mode 100644 index 0000000..6e6a6a0 --- /dev/null +++ b/commands/storage/doc/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make <target>' where <target> is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OpenLMIStorageScripts.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OpenLMIStorageScripts.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/OpenLMIStorageScripts" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/OpenLMIStorageScripts" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/commands/storage/doc/common.rst b/commands/storage/doc/common.rst new file mode 100644 index 0000000..c69ec00 --- /dev/null +++ b/commands/storage/doc/common.rst @@ -0,0 +1,7 @@ +Common functions +================ + +.. automodule:: lmi.scripts.storage.common + :members: + + diff --git a/commands/storage/doc/conf.py b/commands/storage/doc/conf.py new file mode 100644 index 0000000..e273622 --- /dev/null +++ b/commands/storage/doc/conf.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# +# OpenLMI Storage Scripts documentation build configuration file, created by +# sphinx-quickstart on Thu Aug 8 15:36:58 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('..')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'OpenLMI Storage Scripts' +copyright = u'2013, Red Hat, Inc.' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.5.3' +# The full version, including alpha/beta/rc tags. +release = '0.5.3' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'OpenLMIStorageScriptsdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'OpenLMIStorageScripts.tex', u'OpenLMI Storage Scripts Documentation', + u'Red Hat, Inc.', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'openlmistoragescripts', u'OpenLMI Storage Scripts Documentation', + [u'Red Hat, Inc.'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'OpenLMIStorageScripts', u'OpenLMI Storage Scripts Documentation', + u'Red Hat, Inc.', 'OpenLMIStorageScripts', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' diff --git a/commands/storage/doc/fs.rst b/commands/storage/doc/fs.rst new file mode 100644 index 0000000..6ddf49e --- /dev/null +++ b/commands/storage/doc/fs.rst @@ -0,0 +1,7 @@ +Filesystems and data formats +============================ + +.. automodule:: lmi.scripts.storage.fs + :members: + + diff --git a/commands/storage/doc/index.rst b/commands/storage/doc/index.rst new file mode 100644 index 0000000..ec0f11b --- /dev/null +++ b/commands/storage/doc/index.rst @@ -0,0 +1,25 @@ +.. OpenLMI Storage Scripts documentation + +OpenLMI Storage Scripts documentation +===================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + common + partition + lvm + raid + fs + show + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/commands/storage/doc/lvm.rst b/commands/storage/doc/lvm.rst new file mode 100644 index 0000000..f945de4 --- /dev/null +++ b/commands/storage/doc/lvm.rst @@ -0,0 +1,7 @@ +Logical Volume Management +========================= + +.. automodule:: lmi.scripts.storage.lvm + :members: + + diff --git a/commands/storage/doc/partition.rst b/commands/storage/doc/partition.rst new file mode 100644 index 0000000..5c263fc --- /dev/null +++ b/commands/storage/doc/partition.rst @@ -0,0 +1,7 @@ +Partitioning +============ + +.. automodule:: lmi.scripts.storage.partition + :members: + + diff --git a/commands/storage/doc/raid.rst b/commands/storage/doc/raid.rst new file mode 100644 index 0000000..b6caa3a --- /dev/null +++ b/commands/storage/doc/raid.rst @@ -0,0 +1,7 @@ +MD RAID +======= + +.. automodule:: lmi.scripts.storage.raid + :members: + + diff --git a/commands/storage/doc/show.rst b/commands/storage/doc/show.rst new file mode 100644 index 0000000..4325089 --- /dev/null +++ b/commands/storage/doc/show.rst @@ -0,0 +1,7 @@ +Printing +======== + +.. automodule:: lmi.scripts.storage.show + :members: + + diff --git a/commands/storage/lmi/scripts/storage/common.py b/commands/storage/lmi/scripts/storage/common.py index cfccb7d..d141739 100644 --- a/commands/storage/lmi/scripts/storage/common.py +++ b/commands/storage/lmi/scripts/storage/common.py @@ -32,26 +32,25 @@ LOG = get_logger(__name__) def escape_cql(s): """ - Escape potentially unsafe string. + Escape potentially unsafe string for CQL. - :param s: (``string``) String to escape. - :retval: Escaped string. + :type s: string + :param s: String to escape. + :rtype: string """ return re.sub(r'(["\\])', r'\\\1', s) def str2device(c, device): """ Convert string with name of device to LMIInstance of the device. - - :param c: (``LmiConnection``) - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` or - ``string`` with name of device) If ``LMIInstance`` is given, nothing is - done and the instance is just returned. If string is given, appropriate - ``LMIInstance`` is looked up and returned. - - :retval: ``LMIInstance`` of appropriate CIM_StorageExtent. - + If LMIInstance is provided, nothing is done and the instance is just + returned. If string is given, appropriate LMIInstance is looked up and + returned. This functions throws an error when the device cannot be found. + + :type device: LMIInstance/CIM_StorageExtent or string with name of device + :param device: Device to convert. + :rtype: LMIInstance/CIM_StorageExtent """ if isinstance(device, LMIInstance): return device @@ -77,21 +76,25 @@ multipliers = { } -def str2size(size, additional_multiplier=None, additional_suffix=None): +def str2size(size, additional_unit_size=None, additional_unit_suffix=None): """ Convert string from human-friendly size to bytes. + The string is expected to be integer number, optionally with on of these + suffixes: - :param size: (``string``) Size. Optionally with these suffixes: * k, K - kilobytes, 1024 bytes, * m, M - megabytes, 1024 * 1024 bytes, * g, G - gigabytes, 1024 * 1024 * 1024 bytes, * t, T - terabytes, 1024 * 1024 * 1024 * 1024 bytes, - :param additional_multiplier: (``int``) Additional multiplier for - additional_suffix, e.g. 4 * 1024*1024 for extent size. - :param additional_suffix: (``string``) Additional allowed suffix, e.g. - 'E' for extents. - :retval: ``int`` with the size. + :type size: string + :param size: The size to convert. + :type additional_unit_size: int + :param additional_unit_size: Additional unit size for + additional_unit_suffix, e.g. 4 * 1024*1024 for extent size. + :type additional_unit_suffix: string + :param additional_unit_suffix: Additional suffix, e.g. 'E' for extents. + :rtype: int """ if size.isdigit(): return int(size) @@ -103,13 +106,13 @@ def str2size(size, additional_multiplier=None, additional_suffix=None): m = multipliers.get(suffix.upper(), None) if not m: - if additional_suffix and suffix.upper() == additional_suffix.upper(): - m = additional_multiplier + if additional_unit_suffix and suffix.upper() == additional_unit_suffix.upper(): + m = additional_unit_size else: # Sort the units by their size units = multipliers.items() - if additional_suffix: - units.append((additional_suffix, additional_multiplier)) + if additional_unit_suffix: + units.append((additional_unit_suffix, additional_unit_size)) units = sorted(units, key=lambda x: x[1]) raise LmiFailed("'%s' has invalid unit. Known units: %s." % (size, ",".join([unit[0] for unit in units]))) @@ -117,11 +120,11 @@ def str2size(size, additional_multiplier=None, additional_suffix=None): def size2str(size): """ - Convert size (in bytes) to human-friendly string. + Convert size (in bytes) to human-friendly string converted to KB, MB, ... - :param size: (``int``) Size of something in bytes. - :retval: ``string`` with human friendly size in nearest units (KiB, MiB, - ...) + :type size: int + :param size: Size of something in bytes. + :rtype: string """ # find the highest multiplier, where the size/multiplier > 1 mul = 1 @@ -155,14 +158,16 @@ def size2str(size): def get_devices(c, devices=None): """ - Returns list of devices. - If no devices are given, all devices are returned. + Returns list of block devices. + If no devices are given, all block devices on the system are returned. + + This functions just converts list of strings to list of appropriate + LMIInstances. - :param devices: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or list of ``string``s with name of the devices.) Devices to list. + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param devices: Devices to list. - :retval: (list of ``LMIInstance``s of ``CIM_StorageExtent`` List of - the devices. + :rtype: list of LMIInstance/CIM_StorageExtent. """ if devices: for dev in devices: diff --git a/commands/storage/lmi/scripts/storage/fs.py b/commands/storage/lmi/scripts/storage/fs.py index 5bca00f..fb5cae0 100644 --- a/commands/storage/lmi/scripts/storage/fs.py +++ b/commands/storage/lmi/scripts/storage/fs.py @@ -18,12 +18,12 @@ # # Authors: Jan Safranek <jsafrane@redhat.com> # -from lmi.scripts.common.errors import LmiFailed -from lmi.scripts.storage import partition """ Filesystem management functions. """ +from lmi.scripts.common.errors import LmiFailed +from lmi.scripts.storage import partition from lmi.scripts.common import get_logger LOG = get_logger(__name__) from lmi.scripts.storage import common @@ -36,18 +36,20 @@ FORMAT_ALL = FORMAT_FS | FORMAT_DATA def str2format(c, fmt): """ - Convert string with name of device to LMIInstance of the format on the device. + Convert string with name of device to LMIInstance of the format on the + device. - :param c: (``LmiConnection``) - :param device: (Either ``LMIInstance`` of ``CIM_LocalFileSystem`` or - ``LMI_DataFormat`` or ``string`` with name of device) If ``LMIInstance`` is - given, nothing is done and the instance is just returned. If string is - given, appropriate ``LMIInstance`` is looked up and returned. - - :retval: ``LMIInstance`` of appropriate LMI_DataFormat or - CIM_LocalFileSystem. + If LMIInstance is provided, nothing is done and the instance is just + returned. If a string is given, appropriate LMIInstance is looked up and + returned. This functions throws an error when the device cannot be found. + + :type fmt: LMIInstance/CIM_LocalFileSystem or LMIInstance/LMI_DataFormat or + string + :param fmt: The format. + + :retval: LMIInstance/CIM_LocalFileSystem or LMIInstance/LMI_DataFormat """ if isinstance(fmt, LMIInstance): return fmt @@ -56,12 +58,14 @@ def str2format(c, fmt): device = common.str2device(fmt) return get_format_on_device(c, device) -def get_fs_id(c, fsname): +def _get_fs_id(c, fsname): """ - Return integer value of given filesystem name in + Return integer value for given filesystem name in LMI_FileSystemConfigurationService.LMI_CreateFileSystem.FileSystemType - :param fsname: (``string``) Name of the filesystem. + :type fsname: string + :param fsname: Name of the filesystem. + :rtype: int """ service = c.root.cimv2.LMI_FileSystemConfigurationService.first_instance() service.LMI_CreateFileSystem.XXX @@ -70,17 +74,18 @@ def get_format_on_device(c, device, format_type=FORMAT_ALL): """ Return filesystem or data format, which is on given device. - :param device: (Either ``LMIInstance``s of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device to to query. - :param format_type: (``int``) Type of formats to find. - FORMAT_ALL - return either CIM_LocalFileSystem or LMI_DataFormat. - FORMAT_FS - return only CIM_LocalFileSystem or None, if there is no - filesystem on the device. - FORMAT_DATA - return only LMI_DataFormat or None, if there is no - data format on the device. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device to to examine. + :type format_type: int + :param format_type: Type of format to find. + + * FORMAT_ALL - return either CIM_LocalFileSystem or LMI_DataFormat. + * FORMAT_FS - return only CIM_LocalFileSystem or None, if there is no + filesystem on the device. + * FORMAT_DATA - return only LMI_DataFormat or None, if there is no + data format on the device. - :retval: (``LMIInstance`` of ``CIM_LocalFileSystem`` or ``LMI_DataFormat``) - or None, if there is no recognizable format on the device. + :rtype: LMIInstance/CIM_LocalFileSystem or LMIInstance/LMI_DataFormat """ device = common.str2device(c, device) if format_type == FORMAT_ALL: @@ -105,23 +110,25 @@ def get_format_on_device(c, device, format_type=FORMAT_ALL): def get_formats(c, devices=None, format_type=FORMAT_ALL, nodevfs=False): """ Retrieve list of filesystems on given devices. + If no devices are given, all formats on all devices are returned. - :param c: - :param devices: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or list of ``string``s with name of the devices.) Devices to list formats - on. - FORMAT_ALL - return either CIM_LocalFileSystem or LMI_DataFormat. - FORMAT_FS - return only CIM_LocalFileSystem or None, if there is no - filesystem on the device. - FORMAT_DATA - return only LMI_DataFormat or None, if there is no - data format on the device. - :param nodevfs: Whether non-device filesystems like tmpfs, cgroup, procfs - etc. + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param devices: Devices to list formats on. + :type format_type: int + :param format_type: Type of formats to find. - If no devices are given, all formats on all devices are returned. + * FORMAT_ALL - return either CIM_LocalFileSystem or LMI_DataFormat. + * FORMAT_FS - return only CIM_LocalFileSystem or None, if there is no + filesystem on the device. + * FORMAT_DATA - return only LMI_DataFormat or None, if there is no + data format on the device. - :retval: list of ``LMIInstance``s of ``CIM_LocalFileSystem`` or - ``LMI_DataFormat`` + :type nodevfs: bool + :param nodevfs: Whether non-device filesystems like tmpfs, cgroup, procfs + etc. should be returned. + + :rtype: list of LMIInstance/CIM_LocalFileSystem or + LMIInstance/LMI_DataFormat """ if devices: for device in devices: @@ -142,14 +149,17 @@ def get_formats(c, devices=None, format_type=FORMAT_ALL, nodevfs=False): def create_fs(c, devices, fs, label=None): """ Format given devices with a filesystem. - - :param c: - :param devices: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or list of ``string``s with name of the devices.) Devices to list formats - on. - :param fs: (``string``) Requested filesystem type. - :param label: (``string``) The filesystem label. - :retval: (``LMIInstance``) of the CIM_LocalFileSystem. + If multiple devices are provided, the format will span over all these + devices (currently supported only for btrfs). + + + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param devices: Devices to format. + :type fs: string + :param fs: Requested filesystem type (case-insensitive). + :type label: string + :param label: The filesystem label. + :rtype: LMIInstance/CIM_LocalFileSystem """ devs = [] for device in devices: @@ -173,10 +183,8 @@ def delete_format(c, fmt): """ Remove given filesystem or data format from all devices, where it resides. - :param c: - :param fmt: (Either ``LMIInstance``s of ``LMI_DataFormat`` or - ``CIM_LocalFileSystem`` or ``string`` with name of the device.) - Format to delete. + :type fmt: LMIInstance/CIM_LocalFileSystem or LMIInstance/LMI_DataFormat + :param fmt: Format to delete. """ fmt = str2format(c, fmt) if not fmt: @@ -191,13 +199,12 @@ def delete_format(c, fmt): def get_format_label(c, fmt): """ - Return short text description of the format. + Return short text description of the format, ready for printing. - :param fmt: (Either ``LMIInstance``s of ``LMI_DataFormat`` or - ``CIM_LocalFileSystem`` or ``string`` with name of the device.) - Format to describe. + :type fmt: LMIInstance/CIM_LocalFileSystem or LMIInstance/LMI_DataFormat + :param fmt: Format to describe. - :retval: (``string``) The label. + :rtype: string """ if "FormatType" in fmt.properties(): return fmt.FormatTypeDescription @@ -208,12 +215,12 @@ def get_format_label(c, fmt): def get_device_format_label(c, device): """ - Return short text description of the format on the device. + Return short text description of the format, ready for printing. - :param fmt: (Either ``LMIInstance``s of ``CIM_StorageExtent`` or - or ``string`` with name of the device.) Device to describe. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device to describe. - :retval: (``string``) The label. + :rtype: string """ fmt = get_format_on_device(c, device) if fmt: @@ -229,4 +236,3 @@ def get_device_format_label(c, device): return cls.PartitionStyleValues.value_name( table.PartitionStyle) + " partition table" return "Unknown" - diff --git a/commands/storage/lmi/scripts/storage/lvm.py b/commands/storage/lmi/scripts/storage/lvm.py index 6db1bdd..fec3e62 100644 --- a/commands/storage/lmi/scripts/storage/lvm.py +++ b/commands/storage/lmi/scripts/storage/lvm.py @@ -18,12 +18,12 @@ # # Authors: Jan Safranek <jsafrane@redhat.com> # -from lmi.scripts.common.errors import LmiFailed """ LVM management functions. """ +from lmi.scripts.common.errors import LmiFailed from lmi.scripts.common import get_logger LOG = get_logger(__name__) from lmi.scripts.storage import common @@ -33,17 +33,18 @@ import pywbem def str2vg(c, vg): """ Convert string with name of volume group to LMIInstance of the - LMI_VGStoragePool - - :param c: (``LmiConnection``) - :param device: (Either ``LMIInstance`` of ``LMI_VGStoragePool`` or - or ``string`` with name of volume group) If ``LMIInstance`` is - given, nothing is done and the instance is just returned. If string is - given, appropriate ``LMIInstance`` is looked up and returned. + LMI_VGStoragePool. - :retval: ``LMIInstance`` of appropriate LMI_VGStoragePool. + If LMIInstance is provided, nothing is done and the instance is just + returned. If string is provided, appropriate LMIInstance is looked up and + returned. This functions throws an error when the device cannot be found. + + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: VG to retrieve. + :rtype: LMIInstance/LMI_VGStoragePool + """ if isinstance(vg, LMIInstance): return vg @@ -69,10 +70,9 @@ def get_lvs(c, vgs=None): If no volume groups are provided, all logical volumes on the system are returned. - :param c: - :param devices: (Either list of ``LMIInstance``s of ``LMI_VGStoragePool`` - or list of ``string``s with name of the pools.) Volume groups to list. - :retval: list of ``LMIInstance``s of LMI_LVStorageExtent. + :type vgs: list of LMIInstance/LMI_VGStoragePool or list of strings + :param vgs: Volume Groups to examine. + :rtype: list of LMIInstance/LMI_LVStorageExtent. """ if vgs: for vg in vgs: @@ -86,14 +86,15 @@ def get_lvs(c, vgs=None): def create_lv(c, vg, name, size): """ - Create a Logical Volume on given Volume Group. + Create new Logical Volume on given Volume Group. - :param c: - :param vg: (Either list of ``LMIInstance``s of ``LMI_VGStoragePool`` - or ``string``s with name of the VG.) Volume Group to allocate from. - :param name: (``string``) Name of the logical volume. - :param size: (``int``) Size of the storage volume in bytes. - :retval: (``LMIInstance``) of the created LMI_LVStorageExtent. + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: Volume Group to allocate the volume from. + :type name: string + :param name: Name of the logical volume. + :type size: int + :param size: Size of the logical volume in bytes. + :rtype: LMIInstance/LMI_LVStorageExtent """ vg = str2vg(c, vg) service = c.root.cimv2.LMI_StorageConfigurationService.first_instance() @@ -109,11 +110,10 @@ def create_lv(c, vg, name, size): def delete_lv(c, lv): """ - Destroy given Logical Volume + Destroy given Logical Volume. - :param c: - :param lv: (Either ``LMIInstance`` of ``LMI_LVStorageExtent`` - or ``string``s with name of the LV.) LogicalVolume to remove. + :type lv: LMIInstance/LMI_LVStorageExtent or string + :param lv: Logical Volume to destroy. """ lv = common.str2device(c, lv) service = c.root.cimv2.LMI_StorageConfigurationService.first_instance() @@ -126,23 +126,22 @@ def get_vgs(c): """ Retrieve list of all volume groups on the system. - :param c: - :retval: list of ``LMIInstance``s of LMI_VGStoragePool. + :rtype: list of LMIInstance/LMI_VGStoragePool """ for vg in c.root.cimv2.LMI_VGStoragePool.instances(): yield vg def create_vg(c, devices, name, extent_size=None): """ - Create a Logical Volume on given Volume Group. + Create new Volume Group from given devices. - :param c: - :param device: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or ``string``s with name of the devices.) Devices to add to the Volume - Group. - :param name: (``string``) Name of the volume group. - :param extent_size: (``int``) Extent size in bytes. - :retval: (``LMIInstance``) of the created LMI_VGStoragePool. + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param device: Devices to add to the Volume Group. + :type name: string + :param name: Name of the Volume gGoup. + :type extent_size: int + :param extent_size: Extent size in bytes. + :rtype: LMIInstance/LMI_VGStoragePool """ devs = [common.str2device(c, device) for device in devices] args = { 'InExtents': devs, @@ -182,9 +181,8 @@ def delete_vg(c, vg): """ Destroy given Volume Group. - :param c: - :param vg: (Either ``LMIInstance`` of ``LMI_VGStoragePool`` - or ``string``s with name of the VG.) Volume Group to remove. + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: Volume Group to delete. """ vg = str2vg(c, vg) service = c.root.cimv2.LMI_StorageConfigurationService.first_instance() @@ -195,11 +193,11 @@ def delete_vg(c, vg): def get_vg_lvs(c, vg): """ - Return list of logical volumes on given volume group. + Return list of Logical Volumes on given Volume Group. - :param vg: (Either ``LMIInstance`` of ``LMI_VGStoragePool`` - or ``string``s with name of the VG.) Volume Group to examine. - :retval: (list of ``LMIInstance`` of LMI_LVStorageExtents) + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: Volume Group to examine. + :rtype: list of LMIInstance/LMI_LVStorageExtent """ vg = str2vg(c, vg) return vg.associators(AssocClass="LMI_LVAllocatedFromStoragePool") @@ -208,10 +206,9 @@ def get_lv_vg(c, lv): """ Return Volume Group of given Logical Volume. - :param vg: (Either ``LMIInstance`` of ``LMI_LVStorageExtent`` - or ``string``s with name of the LV.) Logical Volume to examine. - :retval: (``LMIInstance`` of LMI_VGStoragePool) or None, - if there is no such VG. + :type lv: LMIInstance/LMI_LVStorageExtent or string + :param lv: Logical Volume to examine. + :rtype: LMIInstance/LMI_VGStoragePool """ lv = common.str2device(c, lv) return lv.first_associator(AssocClass="LMI_LVAllocatedFromStoragePool") @@ -220,9 +217,9 @@ def get_vg_pvs(c, vg): """ Return Physical Volumes of given Volume Group. - :param vg: (Either ``LMIInstance`` of ``LMI_VGStoragePool`` - or ``string``s with name of the VG.) Volume Group to examine. - :retval: (list of ``LMIInstance`` of CIM_StorageExtent) Physical Volumes. + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: Volume Group to examine. + :rtype: list of LMIInstance/CIM_StorageExtent """ vg = str2vg(c, vg) return vg.associators(AssocClass="LMI_VGAssociatedComponentExtent") diff --git a/commands/storage/lmi/scripts/storage/partition.py b/commands/storage/lmi/scripts/storage/partition.py index 8235ba0..8b728a2 100644 --- a/commands/storage/lmi/scripts/storage/partition.py +++ b/commands/storage/lmi/scripts/storage/partition.py @@ -18,12 +18,11 @@ # # Authors: Jan Safranek <jsafrane@redhat.com> # -from lmi.scripts.common.errors import LmiFailed - """ Partition management functions. """ +from lmi.scripts.common.errors import LmiFailed from lmi.scripts.common import get_logger LOG = get_logger(__name__) from lmi.scripts.storage import common @@ -39,9 +38,10 @@ PARTITION_TABLE_TYPE_MSDOS = 2 def get_disk_partitions(c, disk): """ Return list of partitions on the device (not necessarily disk). - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device which should be partitioned. - :retval: List of ``LMIInstance``s of ``CIM_GenericDiskPartition``. + + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device which should be partitioned. + :rtype: List of LMIInstance/CIM_GenericDiskPartition. """ disk = common.str2device(c, disk) parts = disk.associators( @@ -60,12 +60,11 @@ def get_disk_partitions(c, disk): def get_partition_disk(c, partition): """ - Return device on which is the given partition located. - - :param partition: (Either ``LMIInstance`` of ``CIM_GenericDiskPartition`` - or ``string`` with name of the device.) + Return a device on which is located the given partition. - :retval: ``LMIInstance`` of ``CIM_GenericDiskPartition``. + :type partition: LMIInstance/CIM_GenericDiskPartition or string + :param partition: Partition to examine. + :rtype: LMIInstance/CIM_StorageExtent. """ partition = common.str2device(c, partition) device = partition.first_associator( @@ -79,15 +78,11 @@ def get_partition_disk(c, partition): def get_partitions(c, devices=None): """ Retrieve list of partitions on given devices. - - :param c: - :param devices: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or list of ``string``s with name of the devices.) Devices to list partitions - on. - If no devices are given, all partitions on all devices are returned. - :retval: list of ``LMIInstance``s of CIM_GenericPartition. + :type devices: List of LMIInstance/CIM_StorageExtent or list of string + :param devices: Devices to list partitions on. + :rtype: List of LMIInstance/CIM_GenericPartition. """ if devices: for device in devices: @@ -103,20 +98,21 @@ def get_partitions(c, devices=None): def create_partition(c, device, size=None, partition_type=None): """ - Create a partition on given device. - - :param c: - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device which should be partitioned. - :param size: (``int``) Size of the device, in blocks. See device's BlockSize - to get it. If no size is provided, the largest possible partition - will be created. - :param partition_type: (``int``) Requested partition type. - See PARTITION_TYPE_xxx variables. If no type is given, extended partition - will be automatically created as 4th partition on MS-DOS style partition - table with a logical partition with requested size on it. - - :retval: (``LMIInstance``) of the partition. + Create new partition on given device. + + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device which should be partitioned. + :type size: int + :param size: Size of the device, in blocks. See device's BlockSize + to get it. If no size is provided, the largest possible partition + is created. + :type partition_type: int + :param partition_type: Requested partition type. + See PARTITION_TYPE_xxx variables. If no type is given, extended partition + will be automatically created as 4th partition on MS-DOS style partition + table with a logical partition with requested size on it. + + :rtype: LMIInstance/CIM_GenericDiskPartition. """ device = common.str2device(c, device) setting = None @@ -155,9 +151,8 @@ def delete_partition(c, partition): """ Remove given partition - :param c: - :param partition: (Either ``LMIInstance`` of ``CIM_GenericDiskPartition`` - or ``string`` with name of the device.) + :type partition: LMIInstance/CIM_GenericDiskPartition + :param partition: Partition to delete. """ partition = common.str2device(c, partition) service = c.root.cimv2.LMI_DiskPartitionConfigurationService.first_instance() @@ -171,10 +166,11 @@ def create_partition_table(c, device, table_type): Create new partition table on a device. The device must be empty, i.e. must not have any partitions on it. - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device which should be partitioned. - :param table_type: (``int``) Requested partition table type. - See PARTITION_TABLE_TYPE_xxx variables. + :type device: LMIInstance/CIM_StorageExtent + :param device: Device where the partition table should be created. + :type table_type: int + :param table_type: Requested partition table type. See + PARTITION_TABLE_TYPE_xxx variables. """ device = common.str2device(c, device) query = "SELECT * FROM LMI_DiskPartitionConfigurationCapabilities WHERE " \ @@ -195,16 +191,14 @@ def create_partition_table(c, device, table_type): def get_partition_tables(c, devices=None): """ - Returns list of partition tables. + Returns list of partition tables on given devices. If no devices are given, all partitions on all devices are returned. - :param devices: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or list of ``string``s with name of the devices.) Devices to list partition - tables on. + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param devices: Devices to list partition tables on. - :retval: (list of tuples ``(LMIInstance, LMIInstance)``) List of all - partition tables as - (CIM_StorageDevice, LMI_DiskPartitionConfigurationCapabilities) tuples. + :rtype: List of tuples (LMIInstance/CIM_StorageExtent, + LMIInstance/LMI_DiskPartitionConfigurationCapabilities). """ if not devices: tables = c.root.cimv2.LMI_InstalledPartitionTable.instances() @@ -219,14 +213,12 @@ def get_partition_tables(c, devices=None): def get_disk_partition_table(c, device): """ Returns LMI_DiskPartitionTableCapabilities representing partition table - on the disk. + on given disk. - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device which should be examined. - There must be partition table present on this device. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device which should be examined. - :retval: (``LMIInstance`` of ``LMI_DiskPartitionConfigurationCapabilities``) - Partition table on the device or None, if the device is not partitioned. + :rtype: LMIInstance/LMI_DiskPartitionConfigurationCapabilities. """ device = common.str2device(c, device) table = device.first_associator( @@ -235,14 +227,13 @@ def get_disk_partition_table(c, device): def get_largest_partition_size(c, device): """ - Returns size of the largest free region, which can accommodate a partition. - - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string`` with name of the device.) Device which should be examined. + Returns size of the largest free region (in blocks), which can accommodate + a partition on given device. There must be partition table present on this device. - :retval: (``int``) Size of the largest available region for new partition, - in bytes. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device which should be examined. + :rtype: int """ device = common.str2device(c, device) # find the partition table (=LMI_DiskPartitionConfigurationCapabilities) diff --git a/commands/storage/lmi/scripts/storage/partitiontable_cmd.py b/commands/storage/lmi/scripts/storage/partitiontable_cmd.py index a260ace..125b246 100644 --- a/commands/storage/lmi/scripts/storage/partitiontable_cmd.py +++ b/commands/storage/lmi/scripts/storage/partitiontable_cmd.py @@ -36,9 +36,6 @@ Commands: show Show detailed information about partition table on given devices. If no devices are provided, all of them are displayed. - -Remarks: - Use 'lmi fs delete' to remove a partition table from a device. """ from lmi.scripts.common import command diff --git a/commands/storage/lmi/scripts/storage/raid.py b/commands/storage/lmi/scripts/storage/raid.py index d7ea440..7e30b76 100644 --- a/commands/storage/lmi/scripts/storage/raid.py +++ b/commands/storage/lmi/scripts/storage/raid.py @@ -18,12 +18,11 @@ # # Authors: Jan Safranek <jsafrane@redhat.com> # -from lmi.scripts.common.errors import LmiFailed - """ MD RAID management functions. """ +from lmi.scripts.common.errors import LmiFailed from lmi.scripts.common import get_logger LOG = get_logger(__name__) from lmi.scripts.storage import common @@ -31,25 +30,24 @@ import pywbem def get_raids(c): """ - Retrieve list of all MD RAIDs. + Retrieve list of all MD RAIDs on the system. - :param c: - :retval: list of ``LMIInstance``s of LMI_MDRAIDStorageExtent. + :rtype: list of LMIInstance/LMI_MDRAIDStorageExtent. """ for raid in c.root.cimv2.LMI_MDRAIDStorageExtent.instances(): yield raid def create_raid(c, devices, level, name=None): """ - Create a MD RAID device. - - :param c: - :param device: (Either list of ``LMIInstance``s of ``CIM_StorageExtent`` - or ``string``s with name of the devices.) Devices to add to the RAID. - :param level: (``int``) RAID level. - :param name: (``string``) RAID name. - - :retval: (``LMIInstance``) of the MD RAID. + Create new MD RAID device. + + :type devices: list of LMIInstance/CIM_StorageExtent or list of strings + :param device: Devices to add to the RAID. + :type level: int + :param level: RAID level. + :type name: string + :param name: RAID name. + :rtype: LMIInstance/LMI_MDRAIDStorageExtent """ devs = [common.str2device(c, device) for device in devices] args = { 'InExtents': devs, @@ -68,9 +66,8 @@ def delete_raid(c, raid): """ Destroy given RAID device - :param c: - :param raid: (Either ``LMIInstance`` of ``LMI_MDRAIDStorageExtent`` - or ``string`` with name of the device.) + :type raid: LMIInstance/LMI_MDRAIDStorageExtent + :param raid: MD RAID to destroy. """ raid = common.str2device(c, raid) service = c.root.cimv2.LMI_StorageConfigurationService.first_instance() @@ -83,10 +80,9 @@ def get_raid_members(c, raid): """ Return member devices of the RAID. - :param device: (Either ``LMIInstance`` of ``LMI_MDRAIDStorageExtent`` - or ``string`` with name of the device.) RAID to query. - - :retval: List of ``LMIInstance``s of ``CIM_StorageExtent``. + :type raid: LMIInstance/LMI_MDRAIDStorageExtent + :param raid: MD RAID to examine. + :rtype: List of LMIInstance/CIM_StorageExtent """ raid = common.str2device(c, raid) members = raid.associators(AssocClass="LMI_MDRAIDBasedOn", diff --git a/commands/storage/lmi/scripts/storage/show.py b/commands/storage/lmi/scripts/storage/show.py index 8201e54..fa3c2ae 100644 --- a/commands/storage/lmi/scripts/storage/show.py +++ b/commands/storage/lmi/scripts/storage/show.py @@ -18,12 +18,11 @@ # # Authors: Jan Safranek <jsafrane@redhat.com> # -from lmi.scripts.common.errors import LmiFailed - """ -Functions to display block devices. +Functions to display information about block devices. """ +from lmi.scripts.common.errors import LmiFailed from lmi.scripts.common import get_logger LOG = get_logger(__name__) from lmi.scripts.storage import common, partition, raid, lvm, fs @@ -32,8 +31,8 @@ def device_show(c, device): """ Print extended information about the device. - :param part: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string``s with name of the device.) Device to show. + :type device: LMIInstance/CIM_StorageExtent or string + :param part: Device to show. """ device = common.str2device(c, device) if device.classname == "LMI_MDRAIDStorageExtent": @@ -53,8 +52,8 @@ def partition_show(c, part): """ Print extended information about the partition. - :param part: (Either ``LMIInstance`` of ``CIM_GenericPartition`` - or ``string``s with name of the partition.) Partition to show. + :type part: LMIInstance/CIM_GenericDiskPartition or string + :param part: Partition to show. """ part = common.str2device(c, part) print "Partition", part.DeviceID @@ -87,9 +86,8 @@ def partition_table_show(c, disk): """ Print extended information about the partition table on given disk. - :param part: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string``s with name of the device.) Device with partition table - to show. + :type disk: LMIInstance/CIM_StorageExtent or string + :param disk: Device with partition table to show. """ disk = common.str2device(c, disk) print "Partition Table", disk.DeviceID @@ -113,8 +111,8 @@ def raid_show(c, r): """ Print extended information about the RAID. - :param r: (Either ``LMIInstance`` of ``LMI_MDRAIDStorageExtent`` - or ``string``s with name of the r.) RAID to show. + :type r: LMIInstance/LMI_MDRAIDStorageExtent or string + :param r: RAID to show. """ r = common.str2device(c, r) print "MD RAID Array", r.DeviceID @@ -128,10 +126,10 @@ def raid_show(c, r): def vg_show(c, vg): """ - Print extended information about the volume group. + Print extended information about the Volume Group. - :param vg: (Either ``LMIInstance`` of ``LMI_VGStoragePool`` - or ``string``s with name of the VG.) Volume Group to show. + :type vg: LMIInstance/LMI_VGStoragePool or string + :param vg: Volume Group to show. """ vg = lvm.str2vg(c, vg) print "InstanceID:", vg.InstanceID @@ -152,10 +150,10 @@ def vg_show(c, vg): def lv_show(c, lv): """ - Print extended information about the logical volume. + Print extended information about the Logical Volume. - :param lv: (Either ``LMIInstance`` of ``LMI_LVStorageExtent`` - or ``string``s with name of the LV.) Logical Volume to show. + :type lv: LMIInstance/LMI_LVStorageExtent or string + :param lv: Logical Volume to show. """ lv = common.str2device(c, lv) print "Logical Volume", lv.DeviceID @@ -171,8 +169,8 @@ def device_show_device(c, device): """ Print basic information about storage device, common to all device types. - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string``s with name of the device.) Device to show. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device to show. """ device = common.str2device(c, device) @@ -186,8 +184,8 @@ def device_show_data(c, device): """ Display description of data on the device. - :param device: (Either ``LMIInstance`` of ``CIM_StorageExtent`` - or ``string``s with name of the device.) Device to show. + :type device: LMIInstance/CIM_StorageExtent or string + :param device: Device to show. """ device = common.str2device(c, device) fmt = fs.get_format_on_device(c, device) @@ -207,8 +205,8 @@ def format_show(c, fmt): """ Display description of data on the device. - :param fmt: (Either ``LMIInstance`` of ``LMI_DataFormat`` - or ``string``s with name of the format.) Format to show. + :type fmt: LMIInstance/LMI_DataFormat or string + :param fmt: Format to show. """ fmt = fs.str2format(c, fmt) print "Data Format:", fmt.FormatTypeDescription @@ -217,10 +215,10 @@ def format_show(c, fmt): def fs_show(c, fmt): """ - Display description of data on the device. + Display description of filesystem on the device. - :param fmt: (Either ``LMIInstance`` of ``CIM_LocalFileSystem`` - or ``string``s with name of the format.) Format to show. + :type fmt: LMIInstance/CIM_LocalFileSystem or string + :param fmt: Filesystem to show. """ print "Filesystem:", fmt.FileSystemType if "UUID" in fmt.properties() and fmt.UUID: |