[cura-tools] master: scripts: support older LMIShell (dfd153f)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit dfd153f6949d0002cafa6b5a31e0413a4d5833cd
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Dec 15 10:14:08 2014 +0100
scripts: support older LMIShell
LMIConnection in older openlmi-tools (currently shipped in RHEL7) does
not have client property. Support both older and newer interface.
>---------------------------------------------------------------
cli/lmi/scripts/common/session.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/scripts/common/session.py b/cli/lmi/scripts/common/session.py
index 8d2ad7e..9e892f4 100644
--- a/cli/lmi/scripts/common/session.py
+++ b/cli/lmi/scripts/common/session.py
@@ -107,8 +107,14 @@ class Session(object):
kwargs['prompt_prefix'] = '[%s] ' % hostname
connection = connect(hostname, username, password, **kwargs)
if connection is not None:
- tp = connection.client._cliconn.creds
- if tp is None:
+ client = None
+ if hasattr(connection, "client"):
+ client = connection.client
+ elif hasattr(connection, "_client"):
+ client = connection._client
+ if client is not None:
+ tp = client._cliconn.creds
+ if client is None or tp is None:
tp = ('', '')
self._credentials[hostname] = (tp[0], tp[1], True)
else:
9 years, 4 months
[cura-tools] master: setup: fixed generating REAMDE (a32c3a8)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit a32c3a8ba09323afd5889942f6b771512a26cf59
Author: Michal Minar <miminar(a)redhat.com>
Date: Fri Dec 12 14:01:29 2014 +0100
setup: fixed generating REAMDE
Fallback to proper README file when pandoc fails.
>---------------------------------------------------------------
cli/setup.py.skel | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/setup.py.skel b/cli/setup.py.skel
index 6309de7..50109f2 100644
--- a/cli/setup.py.skel
+++ b/cli/setup.py.skel
@@ -34,7 +34,7 @@ try:
except Exception as err:
sys.stderr.write('ERROR while reading README.txt: %s\n' % str(err))
if not long_description:
- long_description = open('README.md', 'rt').read()
+ long_description = open('../README.md', 'rt').read()
except IOError:
pass
9 years, 4 months
[cura-tools] master: README-scripts: updated requirements (a314037)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit a314037f02d0f49f3d23927b83bff4305765f576
Author: Michal Minar <miminar(a)redhat.com>
Date: Fri Dec 12 13:56:38 2014 +0100
README-scripts: updated requirements
>---------------------------------------------------------------
cli/README-scripts.md | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/README-scripts.md b/cli/README-scripts.md
index 6083fd7..a3a926f 100644
--- a/cli/README-scripts.md
+++ b/cli/README-scripts.md
@@ -28,7 +28,7 @@ Dependencies
Code base is written for `python 2.7`.
There are following python dependencies:
- * openlmi-tools >= 0.9 and < 0.9.1 ([PyPI][tools-PyPI])
+ * openlmi-tools >= 0.9 and < 0.10.0 ([PyPI][tools-PyPI])
* python-docopt
* pandoc
9 years, 4 months
[cura-tools] master: bump release version to 0.10.4 (ab33f1b)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit ab33f1bf93c03047d4e52700a75aa3fa64408c3e
Author: Michal Minar <miminar(a)redhat.com>
Date: Thu Dec 11 07:30:40 2014 +0100
bump release version to 0.10.4
Signed-off-by: Michal Minar <miminar(a)redhat.com>
>---------------------------------------------------------------
cli/lmi/shell/LMIShellVersion.py | 2 +-
cli/man/lmi.1 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index 14b6dcb..8942163 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -13,4 +13,4 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-__version__ = "0.10.3"
+__version__ = "0.10.4"
diff --git a/cli/man/lmi.1 b/cli/man/lmi.1
index 799a1db..1274b73 100644
--- a/cli/man/lmi.1
+++ b/cli/man/lmi.1
@@ -1,4 +1,4 @@
-.TH lmi 1 "December 2014" "openlmi-scripts 0.10.3" "User Commands"
+.TH lmi 1 "December 2014" "openlmi-scripts 0.10.4" "User Commands"
.SH NAME
lmi \- meta-command for managing systems with OpenLMI providers
9 years, 4 months
[cura-tools] master: docs: generate docs for openlmi-scripts pkg for epel (fdd587c)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit fdd587cffef87ffad8d4a37edce4ade6737558aa
Author: Michal Minar <miminar(a)redhat.com>
Date: Thu Dec 11 10:18:01 2014 +0100
docs: generate docs for openlmi-scripts pkg for epel
EPEL openlmi-scripts contains just metacommand and scripts common
library. Therefore its documentation shall contain the same.
Fallback to using openlmitheme - when generating docs for scripts in
epel.
Use exported COMMANDS variable in build-with-sphinx helper instead of
generating its own.
>---------------------------------------------------------------
doc/Makefile | 3 +-
doc/src/Makefile | 15 +++++++++-
doc/src/build-with-sphinx.sh | 5 +++-
doc/src/conf.py.skel | 25 +++++++++++++----
doc/src/genapi.sh | 62 ++++++++++++++++++++++++++++++-----------
doc/src/index-scripts.txt | 15 ++++++++++
6 files changed, 98 insertions(+), 27 deletions(-)
diff --git a/doc/Makefile b/doc/Makefile
index 8218f64..a4babf6 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,13 +5,14 @@ SPHINXOPTS =
SPHINXBUILD := sphinx-build
PAPER =
BUILDDIR ?= build
+JUST_SCRIPTS ?= 0
WITH_COMMANDS ?= 0
ifneq ($(WITH_COMMANDS), 0)
OPENLMI_SCRIPTS_DIR := $(abspath $(shell readlink openlmi-scripts))
endif
export BUILDDIR := $(abspath $(BUILDDIR))
-export WITH_COMMANDS OPENLMI_SCRIPTS_DIR
+export JUST_SCRIPTS WITH_COMMANDS OPENLMI_SCRIPTS_DIR
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 35db676..9e3c580 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -5,16 +5,20 @@ BUILDDIR ?= ../build
SPHINXBUILD ?= sphinx-build
SRCDIR ?= ../../cli
PROJECTNAME := OpenLMITools
+JUST_SCRIPTS ?= 0
WITH_COMMANDS ?= 0
ifeq ($(WITH_COMMANDS), 1)
TAGS := $(TAGS) -t with-commands
COMMANDS ?= $(notdir $(shell find $(OPENLMI_SCRIPTS_DIR)/commands -mindepth 1 \
-maxdepth 1 -type d | sort))
endif
+ifeq ($(JUST_SCRIPTS), 1)
+ TAGS := $(TAGS) -t just-scripts
+endif
ALLSPHINXOPTS ?= -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
ALLSPHINXOPTS := $(TAGS) $(ALLSPHINXOPTS)
-export WITH_COMMANDS OPENLMI_SCRIPTS_DIR COMMANDS
+export JUST_SCRIPTS WITH_COMMANDS OPENLMI_SCRIPTS_DIR COMMANDS
.PHONY: clean deps
@@ -47,12 +51,16 @@ index-%: subindexes-%
echo " :maxdepth: $$DEPTH"; \
echo ""; \
echo " metacommand-index"; \
+ if [ "$JUST_SCRIPTS" != 0 ]; then \
echo " shell-index"; \
+ fi; \
if [ "$*" == html -o "$*" == rtd ]; then \
echo " api"; \
fi; \
) > toc.txt
- if [[ "$*" =~ ^(html|rtd)$$ ]]; then \
+ if [[ "$$JUST_SCRIPTS" == 1 ]]; then \
+ ln -sf index-scripts.txt index.rst; \
+ elif [[ "$*" =~ ^(html|rtd)$$ ]]; then \
ln -sf index-$*.txt index.rst; \
else \
ln -sf index-other.txt index.rst; \
@@ -65,6 +73,8 @@ subindexes-%: shell-index-% metacommand-index-% api-%
@echo "Built subindexes for $* build."
shell-index-%:
+ @echo "Making shell index for $* build."
+ifeq ($(JUST_SCRIPTS), 0)
( \
case "$*" in \
html) DEPTH=1; ;; \
@@ -98,6 +108,7 @@ shell-index-%:
echo " shell/interactive_interface"; \
echo " shell/builtins"; \
) > shell-index.rst
+endif
metacommand-index-man:
@echo "Skipping metacommand documentation"
diff --git a/doc/src/build-with-sphinx.sh b/doc/src/build-with-sphinx.sh
index 9532df1..3e8aaa2 100755
--- a/doc/src/build-with-sphinx.sh
+++ b/doc/src/build-with-sphinx.sh
@@ -25,7 +25,10 @@ popd # ..
if [ "$WITH_COMMANDS" == 1 ]; then
echo "Installing commands"
pushd "$OPENLMI_SCRIPTS_DIR/commands"
- find . -maxdepth 1 -mindepth 1 -type d | while read cmd; do
+ if [[ -z "$COMMANDS" ]]; then
+ COMMANDS=`find . -maxdepth 1 -mindepth 1 -type d | sort`
+ fi
+ for cmd in $COMMANDS; do
pushd $cmd
python setup.py develop --install-dir=$tmp
popd
diff --git a/doc/src/conf.py.skel b/doc/src/conf.py.skel
index bf8cb08..e1ccd0a 100644
--- a/doc/src/conf.py.skel
+++ b/doc/src/conf.py.skel
@@ -110,8 +110,9 @@ if os.path.isfile(path + "/objects.inv"):
local_inventory = path + "/objects.inv"
intersphinx_mapping = {'http://docs.openlmi.org/en/latest': local_inventory}
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
+if not tags.has('just-scripts'):
+ # Add any paths that contain templates here, relative to this directory.
+ templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
@@ -124,6 +125,8 @@ master_doc = 'index'
# General information about the project.
project = 'OpenLMI Tools'
+if tags.has('just-scripts'):
+ project = 'OpenLMI Scripts'
copyright = '2012-2014, Red Hat Inc.'
# The version info for the project you're documenting, acts as replacement for
@@ -150,8 +153,10 @@ release = '@@VERSION@@'
exclude_patterns = ['scripts/commands/**/index.rst']
if tags.has('man-build'):
exclude_patterns.append('scripts')
-elif tags.has('html-build'):
+elif tags.has('html-build') and not tags.has('just-scripts'):
exclude_patterns.append('shell/man_page.rst')
+if tags.has('just-scripts'):
+ exclude_patterns.append('shell/*')
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
@@ -179,9 +184,17 @@ pygments_style = 'sphinx'
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only import and set the theme if we're building docs locally
- import sphinx_rtd_theme
- html_theme = 'sphinx_rtd_theme'
- html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+ try:
+ import sphinx_rtd_theme
+ html_theme = 'sphinx_rtd_theme'
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+ except ImportError:
+ if tags.has('just-scripts'):
+ # Fallback to openlmi theme if we build scripts doc for epel
+ html_theme = 'openlmitheme'
+ else:
+ # OpenLMI Tools shall have rtd theme
+ raise
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
diff --git a/doc/src/genapi.sh b/doc/src/genapi.sh
index 02e634a..95df2b0 100755
--- a/doc/src/genapi.sh
+++ b/doc/src/genapi.sh
@@ -6,6 +6,7 @@ TOPDIR=../..
DOCDIR=$TOPDIR/doc/src
SRCDIR=$TOPDIR/cli/lmi
WITH_COMMANDS=${WITH_COMMANDS:-0}
+JUST_SCRIPTS=${JUST_SCRIPTS:-0}
function get_modules() {
pushd "$SRCDIR/$1" >/dev/null
@@ -24,7 +25,9 @@ function get_module_name() {
function get_version_string() {
pushd $TOPDIR/cli >/dev/null
- out=`python setup.py --version`
+ setup=setup.py
+ [ $JUST_SCRIPTS = 1 ] && setup=setup-scripts.py
+ out=`python $setup --version`
git_version=`git describe HEAD 2>/dev/null`
echo -n "\`\`$out\`\`"
if [ -n "$git_version" ]; then
@@ -37,13 +40,17 @@ function get_scripts_version_string() {
cat $OPENLMI_SCRIPTS_DIR/VERSION 2>/dev/null
}
-for dir in shell scripts/common; do
+declare -a gendirs
+[ $JUST_SCRIPTS = 0 ] && gendirs+=("shell")
+gendirs+=("scripts/common")
+for dir in ${gendirs[@]}; do
[ -e $DOCDIR/api/$dir ] || mkdir -p $DOCDIR/api/$dir
[ -e $DOCDIR/api/$dir ] || mkdir -p $DOCDIR/api/$dir
done
# api.rst header
-cat >$DOCDIR/api.rst <<_EOF_
+if [[ $JUST_SCRIPTS = 0 ]]; then
+ cat >$DOCDIR/api.rst <<_EOF_
OpenLMI Tools API reference
===========================
@@ -61,6 +68,25 @@ Generated from version: $(get_version_string)
api/shell
api/scripts
_EOF_
+else
+ cat >$DOCDIR/api.rst <<_EOF_
+OpenLMI Scripts API reference
+=============================
+
+This is a generated documentation from *OpenLMI Scripts* sources.
+
+Generated from version: $(get_version_string)
+
+.. only:: html
+
+ **Contents:**
+
+.. toctree::
+ :maxdepth: 2
+
+ api/scripts
+_EOF_
+fi
cat >$DOCDIR/api/shell.rst <<_EOF_
LMIShell API reference
@@ -134,24 +160,26 @@ Generated from version: $(get_version_string)
_EOF_
-# Generate api/shell/*.rst
-for module_path in `get_modules shell`; do
- if [[ "$module_path" =~ ^compat ]]; then
- continue
- fi
- module=`echo "$module_path" | get_module_name`
- len=`echo $module | wc -c`
- len=$(($len-1))
- underline=""
- for i in `seq $len`; do underline="=$underline"; done
- echo >>$DOCDIR/api/shell.rst " shell/$module"
- cat >$DOCDIR/api/shell/${module}.rst <<-_EOF_
+if [[ $JUST_SCRIPTS = 0 ]]; then
+ # Generate api/shell/*.rst
+ for module_path in `get_modules shell`; do
+ if [[ "$module_path" =~ ^compat ]]; then
+ continue
+ fi
+ module=`echo "$module_path" | get_module_name`
+ len=`echo $module | wc -c`
+ len=$(($len-1))
+ underline=""
+ for i in `seq $len`; do underline="=$underline"; done
+ echo >>$DOCDIR/api/shell.rst " shell/$module"
+ cat >$DOCDIR/api/shell/${module}.rst <<-_EOF_
$module
$underline
.. automodule:: lmi.shell.$module
:members:
_EOF_
-done
+ done
+fi
# Generate api/scripts/common/*.rst
for module_path in `get_modules scripts/common`; do
@@ -170,7 +198,7 @@ for module_path in `get_modules scripts/common`; do
done
# Add commands api reference to api/scripts.rst
-if [ $WITH_COMMANDS = 1 ]; then
+if [[ $WITH_COMMANDS = 1 ]]; then
if [ -z "$COMMANDS" ]; then
COMMANDS=`find $OPENLMI_SCRIPTS_DIR/commands \
-mindepth 1 -maxdepth 1 -type d | sort | xargs basename -a`
diff --git a/doc/src/index-scripts.txt b/doc/src/index-scripts.txt
new file mode 100644
index 0000000..915de7a
--- /dev/null
+++ b/doc/src/index-scripts.txt
@@ -0,0 +1,15 @@
+OpenLMI Scripts documentation
+=============================
+
+OpenLMI Scripts comproses of *LMI Meta-command* and a collection of small
+python libraries with command-line wrappers.
+
+.. warning::
+ *LMI Meta-command* has been moved into *OpenLMI Tools*, where it logically
+ belongs, in version 0.2.8. Feature releases of `openlmi-scripts` package
+ on RHEL will lack this application as well. This package will be just a
+ collection of scripts.
+
+**Contents:**
+
+.. include:: toc.txt
9 years, 4 months
[cura-tools] master: setup fixes (e2f9b36)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit e2f9b36b417fad91f8954e58c77ddbced1d44025
Author: Michal Minar <miminar(a)redhat.com>
Date: Thu Dec 11 09:18:28 2014 +0100
setup fixes
* Do not lie about supporting python 3+.
* Updated setup script for openlmi-scripts.
* Bumped highest support version of tools
openlmi-scripts package for EPEL7 should support versions of
openlmi-tools until 0.10.0. Since 0.10.0 openlmi-tools ship metacommand
as well and thus makes openlmi-scripts package obsolete.
>---------------------------------------------------------------
cli/setup-scripts.py | 13 ++++++++++---
cli/setup.py.skel | 2 --
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/cli/setup-scripts.py b/cli/setup-scripts.py
index 28a101f..2fe3f9f 100644
--- a/cli/setup-scripts.py
+++ b/cli/setup-scripts.py
@@ -30,7 +30,7 @@ except IOError:
setup(
name='openlmi-scripts',
- version='0.3.0',
+ version='0.4.0',
description='Client-side library and command-line client',
long_description=long_description,
author='Michal Minar',
@@ -53,11 +53,18 @@ setup(
packages=[
'lmi',
'lmi.scripts',
+ 'lmi.scripts._metacommand',
'lmi.scripts.common',
'lmi.scripts.common.command',
'lmi.scripts.common.formatter',
- 'lmi.scripts._metacommand'],
- install_requires=['openlmi-tools >= 0.9, < 0.9.1', 'docopt >= 0.6'],
+ 'lmi.scripts.common.versioncheck'
+ ],
+ install_requires=[
+ # version of tools >= 0.10.0 contains metacommand - this package
+ # becomes redundant
+ 'openlmi-tools >= 0.9, < 0.10.0',
+ 'docopt >= 0.6',
+ "pyparsing"],
include_package_data=True,
zip_safe=False,
entry_points={
diff --git a/cli/setup.py.skel b/cli/setup.py.skel
index 622661d..6309de7 100644
--- a/cli/setup.py.skel
+++ b/cli/setup.py.skel
@@ -54,8 +54,6 @@ setup(
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.2",
"Intended Audience :: Developers",
"Environment :: Console",
],
9 years, 4 months
[cura-tools] master: fix LMIInstance.__setattr__() when assigning an empty array (0c1051e)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 0c1051e9ebdc086184760112dba4674d29deae0a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Dec 11 14:29:40 2014 +0100
fix LMIInstance.__setattr__() when assigning an empty array
>---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index f842ab8..62df756 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -131,7 +131,7 @@ class LMIInstance(LMIWrapperBaseObject):
value = value.wrapped_object
if name in self._cim_instance:
t = self._cim_instance.properties[name].type
- self._cim_instance[name] = lmi_cast_to_cim(t, value)
+ self._cim_instance.properties[name].value = lmi_cast_to_cim(t, value)
else:
self.__dict__[name] = value
9 years, 4 months
[cura-tools] master: lmi: test fixes (ac8a421)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit ac8a4212edd89b8f875346862af83fbba0ebeb85
Author: Michal Minar <miminar(a)redhat.com>
Date: Tue Dec 9 09:57:01 2014 +0100
lmi: test fixes
Support newer releases of providers (0.4.2+).
Support newer releases of openlmi-tools, declare correct requirements
of testing commands and cope with lmiwbem.
>---------------------------------------------------------------
cli/test/base.sh | 28 +++++
cli/test/cmdver/lmi/scripts/cmdver/__init__.py | 17 +++-
cli/test/cmdver/setup.py | 2 +-
cli/test/test_logging.sh | 147 +++++++++++++++---------
cli/test/test_versioning.sh | 46 +++-----
5 files changed, 156 insertions(+), 84 deletions(-)
diff --git a/cli/test/base.sh b/cli/test/base.sh
index acec1be..411dddd 100644
--- a/cli/test/base.sh
+++ b/cli/test/base.sh
@@ -49,3 +49,31 @@ export LMI
# for some tests no other options are welcomed
export LMI_=`echo $LMI | cut -d \ -f 1`
+function using_lmiwbem() {
+ python2 << EOF
+try:
+ import lmiwbem
+except ImportError:
+ import sys
+ sys.exit(1)
+EOF
+}
+
+function rlLogFile() {
+ file="$1"
+ rlLogInfo "Indented contents of $file:"
+ cat "$file" | while read -r line; do
+ rlLogInfo " $line"
+ done
+}
+
+function rlAssertNotDifferAndLog() {
+ fst="$1"
+ snd="$2"
+ rlAssertNotDiffer "$fst" "$snd"
+ if [[ $? != 0 ]]; then
+ rlLogFile "$fst"
+ rlLogFile "$snd"
+ fi
+}
+
diff --git a/cli/test/cmdver/lmi/scripts/cmdver/__init__.py b/cli/test/cmdver/lmi/scripts/cmdver/__init__.py
index ea646fc..47a0986 100644
--- a/cli/test/cmdver/lmi/scripts/cmdver/__init__.py
+++ b/cli/test/cmdver/lmi/scripts/cmdver/__init__.py
@@ -98,6 +98,20 @@ class PreHwCmd(HwCmd):
'hostname' : PreHostnameInfo
}
+class HigherHwCmd(HwCmd):
+ """
+ Hardware testing command for newer chassis (> 0.3.0).
+
+ Usage:
+ %(cmd)s system
+ %(cmd)s hostname
+ """
+ OWN_USAGE = True
+ COMMANDS = {
+ 'system' : SystemInfo,
+ 'hostname' : HostnameInfo
+ }
+
class NoHwRegistered(command.LmiLister):
"""
Hardware testing command.
@@ -116,7 +130,8 @@ class CmdverHw(command.LmiSelectCommand):
"""
SELECT = (
('OpenLMI-Hardware < 0.4.2', PreHwCmd),
- ('OpenLMI-Hardware >= 0.4.2 & class LMI_Chassis == 0.3.0', HwCmd)
+ ('OpenLMI-Hardware >= 0.4.2 & class LMI_Chassis == 0.3.0', HwCmd),
+ ('OpenLMI-Hardware >= 0.4.2', HigherHwCmd),
)
DEFAULT = NoHwRegistered
diff --git a/cli/test/cmdver/setup.py b/cli/test/cmdver/setup.py
index 58ea463..952fcff 100644
--- a/cli/test/cmdver/setup.py
+++ b/cli/test/cmdver/setup.py
@@ -30,7 +30,7 @@ setup(
'Environment :: Console',
],
- install_requires=['openlmi-scripts'],
+ install_requires=['openlmi-tools >= 0.9.1'],
namespace_packages=['lmi', 'lmi.scripts'],
packages=['lmi', 'lmi.scripts', 'lmi.scripts.cmdver'],
diff --git a/cli/test/test_logging.sh b/cli/test/test_logging.sh
index ef6060f..6c25f3f 100644
--- a/cli/test/test_logging.sh
+++ b/cli/test/test_logging.sh
@@ -52,6 +52,25 @@ FileFormat = %%(levelname)s: %%(message)s
OutputFile = %s
"
+temporary_files=""
+
+function mktempfile() {
+ result=`mktemp "$1"`
+ temporary_files="${temporary_files} $result"
+ echo $result
+}
+
+function make_expected_stderr_output_from() {
+ original="$1"
+ expected=`mktempfile expected_stderrXXXX`
+ if using_lmiwbem; then
+ egrep -v "^(INFO:\s*)?Connected to " "$original" >$expected
+ else
+ cat "$original" >$expected
+ fi
+ echo $expected
+}
+
rlJournalStart
rlPhaseStartSetup
@@ -73,23 +92,23 @@ rlPhaseStartTest
LMICMD="$LMI -c logging/defaults.conf"
- stdout=`mktemp stdoutXXXX`
- stderr=`mktemp stderrXXXX`
+ stdout=`mktempfile stdoutXXXX`
+ stderr=`mktempfile stderrXXXX`
rlRun "$LMICMD test log all >$stdout 2>$stderr" 0
- rlAssertNotDiffer logging/log_all_default.stdout $stdout
- rlAssertNotDiffer logging/log_all_warn.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_default.stdout $stdout
+ rlAssertNotDifferAndLog logging/log_all_warn.stderr $stderr
rlRun "$LMICMD test log all --with-traceback >$stdout 2>$stderr" 0
- rlAssertNotDiffer logging/log_all_default.stdout $stdout
- tmpout=`mktemp tmpoutXXXX`
+ rlAssertNotDifferAndLog logging/log_all_default.stdout $stdout
+ tmpout=`mktempfile tmpoutXXXX`
grep '^\(warning\|error\|critical\)' $stderr > $tmpout
- rlAssertNotDiffer logging/log_all_warn.stderr $tmpout
+ rlAssertNotDifferAndLog logging/log_all_warn.stderr $tmpout
rlAssertEquals "Correct number of exceptions were raised" 3 \
`grep '^RuntimeError: S\*\*t happens!' $stderr | wc -l`
rm $tmpout
- expected_out=`mktemp expected_stdoutXXXX`
- expected_err=`mktemp expected_stderrXXXX`
+ expected_out=`mktempfile expected_stdoutXXXX`
+ expected_err=`mktempfile expected_stderrXXXX`
for verbosity in 0 1 2; do
if [[ $verbosity -gt 0 ]]; then
option=`printf -- "-v %.0s" $(seq $verbosity)`
@@ -115,7 +134,7 @@ rlPhaseStartTest
echo -n "Option \"$opt_name\" not handled in function"; \
echo ' "level", ignoring.'; \
done; \
- echo "Connected to $HOSTNAME"; \
+ using_lmiwbem || echo "Connected to $HOSTNAME"; \
fi; \
if [ $(($verbosity + 2)) -ge $level ]; then \
if [ $level -lt 3 ]; then \
@@ -124,126 +143,144 @@ rlPhaseStartTest
echo "This is $level_name message."; \
fi \
) >$expected_err
- rlAssertNotDiffer $expected_err $stderr
+ rlAssertNotDifferAndLog $expected_err $stderr
+ if [[ $? != 0 ]]; then
+ rlLogFile "$expected_err"
+ rlLogFile "$stderr"
+ fi
rlAssertEquals "Nothing is written to stdout" 0 `cat $stdout | wc -c`
done
done
-
- rm $stdout $stderr $expected_out $expected_err
-
rlPhaseEnd
rlPhaseStartTest
rlLogInfo "Test logging with debug settings"
- config_file=`mktemp configXXXX`
- log_file=`mktemp log_fileXXXX`
+ config_file=`mktempfile configXXXX`
+ log_file=`mktempfile log_fileXXXX`
printf "$DEBUG_CONFIG_TEMPLATE" $log_file >$config_file
LMICMD="$LMI -c $config_file"
- stdout=`mktemp stdoutXXXX`
- stderr=`mktemp stderrXXXX`
+ stdout=`mktempfile stdoutXXXX`
+ stderr=`mktempfile stderrXXXX`
filter_debug=" | grep -v '^Option' > $stderr"
rlRun "$LMICMD test log all 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
- rlAssertNotDiffer logging/log_all_debug.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.stderr` \
+ $stderr
cat $log_file | grep -v '^DEBUG: Option' >${log_file}.tmp
mv ${log_file}{.tmp,}
- rlAssertNotDiffer logging/log_all_debug.file $log_file
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.file` \
+ $log_file
rm $log_file
rlRun "$LMICMD test log all --with-traceback 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
- tmpout=`mktemp tmpoutXXXX`
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
+ tmpout=`mktempfile tmpoutXXXX`
grep '^\(warning\|error\|critical\)' $stderr > $tmpout
- rlAssertNotDiffer logging/log_all_warn.stderr $tmpout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_warn.stderr` \
+ $tmpout
rlAssertEquals "Correct number of exceptions were raised" 5 \
`grep '^RuntimeError: S\*\*t happens!' $stderr | wc -l`
rlAssertEquals "Correct number of exceptions were raised" 5 \
`grep '^RuntimeError: S\*\*t happens!' $log_file | wc -l`
- rm $tmpout $log_file
+ rm $log_file
rlLogInfo "Try override log-file"
- new_log_file=`mktemp new_log_fileXXXX`
+ new_log_file=`mktempfile new_log_fileXXXX`
rlRun "$LMICMD --log-file $new_log_file test log all 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
- rlAssertNotDiffer logging/log_all_debug.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.stderr` \
+ $stderr
cat $new_log_file | grep -v '^DEBUG: Option' >${new_log_file}.tmp
mv ${new_log_file}{.tmp,}
- rlAssertNotDiffer logging/log_all_debug.file $new_log_file
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.file` \
+ $new_log_file
rlRun "[ -e $log_file ]" 1 "Log file from config file shall not be written"
- [ -e $new_log_file ] && rm $new_log_file
+ [ -e $new_log_file ] && rm ${new_log_file}.tmp
[ -e $log_file ] && rm $log_file
rlLogInfo "Try to disable logging to a file"
rlRun "$LMICMD --log-file '' test log all 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
- rlAssertNotDiffer logging/log_all_debug.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.stderr` \
+ $stderr
rlRun "[ -e $log_file ]" 1 "Log file from config file shall not be written"
[ -e $log_file ] && rm $log_file
rlLogInfo "Try override verbosity"
rlRun "$LMICMD -q test log all 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_silent.stdout $stdout
- rlAssertNotDiffer logging/log_all_error.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_silent.stdout $stdout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_error.stderr` \
+ $stderr
cat $log_file | grep -v '^DEBUG: Option' >${log_file}.tmp
mv ${log_file}{.tmp,}
- rlAssertNotDiffer logging/log_all_debug.file $log_file
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.file` \
+ $log_file
rm $log_file
rlRun "$LMICMD -v test log all >$stdout 2>$stderr" 0
- rlAssertNotDiffer logging/log_all_info.stdout $stdout
- rlAssertNotDiffer logging/log_all_info.stderr $stderr
+ rlAssertNotDifferAndLog logging/log_all_info.stdout $stdout
+ expected_err=`make_expected_stderr_output_from logging/log_all_info.stderr`
+ rlAssertNotDifferAndLog $expected_err $stderr
cat $log_file | grep -v '^DEBUG: Option' >${log_file}.tmp
mv ${log_file}{.tmp,}
- rlAssertNotDiffer logging/log_all_debug.file $log_file
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.file` \
+ $log_file
rm $log_file
rlLogInfo "Change file log level"
sed -i 's/DEBUG/WARNING/' $config_file
rlAssertGrep 'Level = WARNING' $config_file
rlRun "$LMICMD test log all 2>&1 >$stdout $filter_debug" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
- rlAssertNotDiffer logging/log_all_debug.stderr $stderr
- rlAssertNotDiffer logging/log_all_warn.file $log_file
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
+ rlAssertNotDifferAndLog \
+ `make_expected_stderr_output_from logging/log_all_debug.stderr` \
+ $stderr
+ rlAssertNotDifferAndLog logging/log_all_warn.file $log_file
[ -e $log_file ] && rm $log_file
rlLogInfo "Disable logging to console"
sed -i 's/\(LogToConsole.*\)True/\1False/' $config_file
rlAssertGrep 'LogToConsole = False' $config_file
rlRun "$LMICMD test log all >$stdout 2>$stderr" 0
- rlAssertNotDiffer logging/log_all_debug.stdout $stdout
+ rlAssertNotDifferAndLog logging/log_all_debug.stdout $stdout
rlAssertEquals "Nothing is written to stderr" `cat $stderr | wc -c` 0
- rlAssertNotDiffer logging/log_all_warn.file $log_file
+ rlAssertNotDifferAndLog logging/log_all_warn.file $log_file
[ -e $log_file ] && rm $log_file
rlLogInfo "Override tracing"
rlRun "$LMICMD --notrace test log all >$stdout 2>$stderr" 0
- rlAssertNotDiffer logging/log_all_debug_notrace.stdout $stdout
+ rlAssertNotDifferAndLog logging/log_all_debug_notrace.stdout $stdout
rlAssertEquals "Nothing is written to stderr" `cat $stderr | wc -c` 0
- rlAssertNotDiffer logging/log_all_warn.file $log_file
-
- for f in $log_file $new_log_file $config_file $stdout $stderr; do
- [ -e $f ] && rm $f
- done
-
+ rlAssertNotDifferAndLog logging/log_all_warn.file $log_file
rlPhaseEnd
rlPhaseStartTest
rlLogInfo "Test logging with settings"
- stdout=`mktemp stdoutXXXX`
- stderr=`mktemp stderrXXXX`
+ stdout=`mktempfile stdoutXXXX`
+ stderr=`mktempfile stderrXXXX`
rlRun "$LMI -c logging/defaults.conf test log all >$stdout 2>$stderr" 0
- rlAssertNotDiffer $stdout logging/log_all_default.stdout
- rlAssertNotDiffer $stderr logging/log_all_warn.stderr
+ rlAssertNotDifferAndLog $stdout logging/log_all_default.stdout
+ rlAssertNotDifferAndLog $stderr logging/log_all_warn.stderr
rm $stdout $stderr
rlPhaseEnd
-
rlPhaseStartCleanup
rlLogInfo "Removing temporary python sandbox"
rm -rf "$sandbox"
+ rlLogInfo "Removing temporary files"
+ rm $temporary_files 2>/dev/null
rlPhaseEnd
diff --git a/cli/test/test_versioning.sh b/cli/test/test_versioning.sh
index 0f7f5b6..7f38420 100644
--- a/cli/test/test_versioning.sh
+++ b/cli/test/test_versioning.sh
@@ -139,28 +139,25 @@ rlPhaseStartTest
rm $rlRun_LOG
else
- rlRun -s "$LMI help ver-hw"
- rlAssertGrep "^Hardware testing command\.$" $rlRun_LOG
- rlAssertGrep "^Usage:$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver-hw system$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver-hw hostname$" $rlRun_LOG
- rm $rlRun_LOG
-
- rlRun -s "$LMI help ver hw" 0
- rlAssertGrep "^Hardware testing command.$" $rlRun_LOG
- rlAssertGrep "^Usage:$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver hw system$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver hw hostname$" $rlRun_LOG
- rm $rlRun_LOG
+ for args in "help ver-hw" "help ver hw" "help ver hw system"; do
+ rlRun -s "$LMI $args" 0
+ if [[ `cmp2int $LMI_HARDWARE_PROVIDER_VERSION` -ge `cmp2int 0.6.0` ]]; then
+ rlAssertGrep "^Hardware testing command for newer chassis" $rlRun_LOG
+ else
+ rlAssertGrep "^Hardware testing command\.$" $rlRun_LOG
+ fi
- rlRun -s "$LMI help ver hw system" 0
- rlAssertGrep "^Hardware testing command.$" $rlRun_LOG
- rlAssertGrep "^Usage:$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver hw system$" $rlRun_LOG
- rlAssertGrep "^\s\+lmi ver hw hostname$" $rlRun_LOG
- rm $rlRun_LOG
+ rlAssertGrep "^Usage:$" $rlRun_LOG
+ if echo "$args" | grep -q "ver-hw"; then
+ rlAssertGrep "^\s\+lmi ver-hw system$" $rlRun_LOG
+ rlAssertGrep "^\s\+lmi ver-hw hostname$" $rlRun_LOG
+ else
+ rlAssertGrep "^\s\+lmi ver hw system$" $rlRun_LOG
+ rlAssertGrep "^\s\+lmi ver hw hostname$" $rlRun_LOG
+ fi
+ rm $rlRun_LOG
+ done
fi
-
rlPhaseEnd
rlPhaseStartTest
@@ -185,7 +182,7 @@ rlPhaseStartTest
else
rlRun -s "$LMI ver-sw"
- rlAssertGrep "Prov version.*${LMI_SOFTWARE_PROVIDER_VERSION} (DEVEL)" $rlRun_LOG
+ rlAssertGrep "Prov version.*[0-9.]\+ (DEVEL)" $rlRun_LOG
rm $rlRun_LOG
fi
@@ -214,13 +211,8 @@ rlPhaseStartTest
rlRun -s "$LMI ver-hw $cmd"
rlAssertEquals "Printed table has just 2 rows" \
`cat $rlRun_LOG | wc -l` 2
- rlAssertGrep "^Prov version\s\+$LMI_SOFTWARE_PROVIDER_VERSION$ver_suffix\$" \
+ rlAssertGrep "^Prov version\s\+$LMI_HARDWARE_PROVIDER_VERSION$ver_suffix\$" \
$rlRun_LOG
- if [[ $cmd == system ]]; then
- reg="^Chassis Type\s\+.*"
- else
- reg="^Hostname\s\+$HOSTNAME" $rlRun_LOG
- fi
rm $rlRun_LOG
done
fi
9 years, 4 months
[cura-tools] master: lmi: fixed profile version comparison (403c6a3)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 403c6a3903b07db1d960cfcda28cbcfa27f27fe7
Author: Michal Minar <miminar(a)redhat.com>
Date: Tue Dec 9 09:55:04 2014 +0100
lmi: fixed profile version comparison
Comparison of version was broken for operators:
>=, <=
New algorithm has been tested with more cases.
>---------------------------------------------------------------
cli/lmi/scripts/common/versioncheck/parser.py | 26 ++++++++++--------------
1 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/cli/lmi/scripts/common/versioncheck/parser.py b/cli/lmi/scripts/common/versioncheck/parser.py
index b5f9116..61cae0e 100644
--- a/cli/lmi/scripts/common/versioncheck/parser.py
+++ b/cli/lmi/scripts/common/versioncheck/parser.py
@@ -67,12 +67,12 @@ from pyparsing import Literal, Combine, Optional, ZeroOrMore, \
#: the condition. The latter causes the comparison to end on first satisfied
#: part.
OP_MAP = {
- '==' : (operator.eq, all),
- '<=' : (operator.le, all),
- '>=' : (operator.ge, all),
- '!=' : (operator.ne, any),
- '>' : (operator.gt, any),
- '<' : (operator.lt, any)
+ '==' : operator.eq,
+ '<=' : operator.le,
+ '>=' : operator.ge,
+ '!=' : operator.ne,
+ '>' : operator.gt,
+ '<' : operator.lt
}
def cmp_version(fst, snd, opsign='<'):
@@ -94,17 +94,13 @@ def cmp_version(fst, snd, opsign='<'):
return tuple(int(p) if p else -1 for p in ver.split('.'))
aparts = splitver(fst)
bparts = splitver(snd)
- op, which = OP_MAP[opsign]
- if which is all:
- for ap, bp in zip(aparts, bparts):
- if not op(ap, bp):
- return False
- else:
- for ap, bp in zip(aparts, bparts):
- if op(ap, bp):
- return True
+ op = OP_MAP[opsign]
+ for ap, bp in zip(aparts, bparts):
+ if not op(ap, bp):
if ap != bp:
return False
+ if ap != bp:
+ return op(ap, bp)
return op(len(aparts), len(bparts))
class SemanticGroup(object):
9 years, 4 months