Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit bd09abb9b7b7a48eb1c062500a881183a0e3ae3e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 23 13:21:53 2013 +0200
fix return value, when JobOutParameters is None
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index ea97ae0..034c55d 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -189,11 +189,14 @@ class LMIMethod(LMIWrapperBaseObject):
# Adjust return value from the job object
if job_refresh:
job_inst.refresh()
- rparams = pywbem.NocaseDict({
+ rval = None
+ rparams = pywbem.NocaseDict()
+ if not job_inst.JobOutParameters is None:
+ rparams = pywbem.NocaseDict({
k: x.value
- for k, x in job_inst.JobOutParameters.properties.iteritems()})
- rval = rparams["__ReturnValue"]
- del rparams["__ReturnValue"] # NocaseDict has no pop()
+ for k, x in job_inst.JobOutParameters.properties.iteritems()})
+ rval = rparams["__ReturnValue"]
+ del rparams["__ReturnValue"] # NocaseDict has no pop()
errorstr = ""
# Is job in exception state? If so, adjust corresponding error string
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 5b1400663412a766a29f6f21fb74a27ac57acfe4
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 23 08:44:38 2013 +0200
doc, fix username/password authentication
>---------------------------------------------------------------
doc/src/startup.rst | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/doc/src/startup.rst b/doc/src/startup.rst
index f2d269f..307eb37 100644
--- a/doc/src/startup.rst
+++ b/doc/src/startup.rst
@@ -22,12 +22,13 @@ or:
Establish a connection
----------------------
-Following examples demonstrate, how to connect to a `CIMOM`.
+Following examples demonstrate, how to connect to a `CIMOM` by issuing a
+:py:func:`.connect` call.
-Username/Password connection
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-To access CIM objects provided by a broker, you have to create a connection
-object, which does the communication, e.g. by running:
+Username/Password authentication
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Common means of performing the authentication is done by providing a *username*
+and *password* to :py:func:`.connect` function. See the following example:
.. code-block:: python
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit dceff203268ea0fff868a820b7f5081306dae40e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 23 09:14:36 2013 +0200
bump release version to v0.8
>---------------------------------------------------------------
cli/lmi/shell/LMIShellVersion.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index 6c58759..d2d2271 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -14,4 +14,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.7"
+__version__ = "0.8"
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 5ed9c304642a9f6ce85fdc3342f7eebe97cd6e25
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 23 08:43:57 2013 +0200
doc, add client-side certificate authentication
>---------------------------------------------------------------
doc/src/startup.rst | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/doc/src/startup.rst b/doc/src/startup.rst
index 3ba853e..f2d269f 100644
--- a/doc/src/startup.rst
+++ b/doc/src/startup.rst
@@ -42,6 +42,19 @@ or:
> c = connect("host", "username", "password")
>
+Certificate authentication
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+LMIShell is capable of creating a connection by using a *X509* certificate. For
+the purpose of creating a connection object, it is necessary to provide two file
+names, which contain a *certificate* and a *private key*.
+
+See the following example:
+
+.. code-block:: python
+
+ > c = connect("host", key_file="key_file", cert_file="cert_file")
+ >
+
Unix socket
^^^^^^^^^^^
LMIShell can connect directly to the CIMOM using Unix socket. For this type of
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit da1632c53f7f614ce9db3174c76daaba72140cd5
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Oct 22 15:18:56 2013 +0200
doc, fix indication subscription
>---------------------------------------------------------------
doc/src/indications.rst | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/doc/src/indications.rst b/doc/src/indications.rst
index 75e9426..585f82e 100644
--- a/doc/src/indications.rst
+++ b/doc/src/indications.rst
@@ -14,17 +14,16 @@ How to subscribe to an indication, please, follow the next example:
.. code-block:: python
- > # When connecting to CIMOM, ensure, that the user account can create
- > # objects in the namespace root/PG_InterOp
> c = connect("host", "privileged_user", "password")
- > # Create an indication
- > c.root.PG_InterOp.create_indication(
- ... FilterCreationClassName="CIM_IndicationFilter",
- ... FilterSystemCreationClassName="CIM_ComputerSystem",
- ... FilterSourceNamespace="root/cimv2",
+ > c.subscribe_indication(
... QueryLanguage="WQL",
... Query='SELECT * FROM CIM_InstModification',
... Name="cpu",
+ ... CreationNamespace="root/interop",
+ ... SubscriptionCreationClassName="CIM_IndicationSubscription",
+ ... FilterCreationClassName="CIM_IndicationFilter",
+ ... FilterSystemCreationClassName="CIM_ComputerSystem",
+ ... FilterSourceNamespace="root/cimv2",
... HandlerCreationClassName="CIM_IndicationHandlerCIMXML",
... HandlerSystemCreationClassName="CIM_ComputerSystem",
... # destination computer, where the indications will be delivered
@@ -33,6 +32,9 @@ How to subscribe to an indication, please, follow the next example:
LMIReturnValue(rval=True, rparams={}, errorstr="")
>
+**NOTE:** Make sure, that you are logged-in with an account, which has write
+privileges in the *root/interop* namespace.
+
In this state, we have a indication subscription created.
Auto-delete subscriptions
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 92195374e319145755bcc65bd0d8ef358b35235a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Oct 22 12:28:17 2013 +0200
introduce zsh completion
>---------------------------------------------------------------
cli/completion/README_zsh.md | 12 ++++++++++++
cli/completion/_lmishell | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/cli/completion/README_zsh.md b/cli/completion/README_zsh.md
new file mode 100644
index 0000000..3c66c06
--- /dev/null
+++ b/cli/completion/README_zsh.md
@@ -0,0 +1,12 @@
+# OpenLMI Shell Completion for Zsh
+Supplied completion function defined in `_lmishell` supports completion of all
+command line arguments of `lmishell`. The completion also works for script
+filename completion with `.lmi` or `.py` extension.
+
+## Setup
+To use the completion, it is necessary to place `_lmishell` into `fpath`.
+
+You need to modify your `zshrc`, so it contains following line:
+```sh
+autoload -U compinit && compinit
+```
diff --git a/cli/completion/_lmishell b/cli/completion/_lmishell
new file mode 100644
index 0000000..f6e7c33
--- /dev/null
+++ b/cli/completion/_lmishell
@@ -0,0 +1,35 @@
+#compdef lmishell
+
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Authors: Peter Hatina <phatina(a)redhat.com>
+#
+# Zsh completion for OpenLMI Shell
+
+_lmishell() {
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments -C \
+ '(- 1 *)'{-h,--help}'[print help message and exit]' \
+ '(- 1 *):OpenLMI Shell Script:_files -g \*.\(lmi\|py\)' \
+ '(-i --interact)'{-i,--interact}'[inspect interactively after running a script]' \
+ '(-v --verbose)'{-v,--verbose}'[print log messages to stderr]' \
+ '(-m --more-verbose)'{-m,--more-verbose}'[print all log messages to stderr]' \
+ '(-q --quiet)'{-q,--quiet}'[do not print any log messages to stderr]' \
+ '(-n --noverify)'{-n,--noverify}'[do not verify CIMOM SSL certificate]'
+}
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 622024b88522e2f358c2b1517191eee0b9c6f98c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 9 10:30:41 2013 +0200
update man page
>---------------------------------------------------------------
man/lmishell.1 | 87 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 67 insertions(+), 20 deletions(-)
diff --git a/man/lmishell.1 b/man/lmishell.1
index 33ca818..7eab8bf 100644
--- a/man/lmishell.1
+++ b/man/lmishell.1
@@ -1,4 +1,4 @@
-.TH lmishell "1" "August 2013" "openlmi-tools v0.7" "User Commands"
+.TH lmishell "1" "October 2013" "openlmi-tools v0.7" "User Commands"
.SH NAME
lmishell \- (non)interactive WBEM client and interpreter.
.SH SYNOPSIS
@@ -98,6 +98,16 @@ are OK, otherwise `None` is returned:
> c is None
True
>
+.SS SERVER'S CERTIFICATE VALIDATION
+When using https transport protocol, LMIShell tries to validate each server-
+side certificate against platform provided CA trust store. It is necessary to
+copy the server's certificate from each CIMOM to the platform specific trust
+store directory.
+
+\fBNOTE:\fR It is possible to make LMIShell skip the certificate validation process by passing `-n` or `--noverify` CLI option to lmishell; see following example:
+
+ $ lmishell --noverify
+ >
.SH NAMESPACES
Namespaces in CIM and LMIShell provide a natural way, how to organize all
available classes. In the shell, they provide a hierarchic access point to
@@ -123,6 +133,11 @@ If you want to access any namespace deeper (eg. cimv2), run this:
> cimv2_namespace = c.root.cimv2
>
+
+or:
+
+ > cimv2_namespace = c.get_namespace("root/cimv2")
+ >
.SS AVAILABLE CLASSES
Each namespace object can print its available classes. To print/get the list
of the classes, run this:
@@ -214,8 +229,8 @@ Both methods `.instances()` or `.instance_names()` can filter returned objects
by their keys/values. The filtering is achieved by passing a dictionary of
`{property : value`} to the corresponding method. See following example:
- > inst_lst = cls.instances({"FilterProperty" : "FilterValue"})
- > inst_names_lst = cls.instance_names({"FilterProperty" : "FilterValue"})
+ > inst_lst = cls.instances({"FilterProperty" : FilterValue})
+ > inst_names_lst = cls.instance_names({"FilterProperty" : FilterValue})
>
.SS NEW INSTANCE NAME
LMIShell is able to create a new wrapped CIMInstanceName, if you know all the
@@ -278,16 +293,18 @@ To get a list of methods, run following:
To execute a method within an object, run this:
> instance.Method(
- ... Param1=value1,
- ... Param2=value2, ...)
+ ... {"Param1" : value1,
+ ... "Param2" : value2, ...})
LMIReturnValue(rval=ReturnValue, rparams=ReturnParametersDictionary, errorstr="Possible error string")
>
+\fBNOTE:\fR Method parameters are passed in a dictionary, as seen in the previous example.
+
To get the result from a method call, see following:
> (rval, rparams, errorstr) = instance.Method(
- ... Param1=value1,
- ... Param2=value2, ...)
+ ... {"Param1" : value1,
+ ... "Param2" : value2, ...})
>
The tuple in the previous example will contain return value of the method call
@@ -310,8 +327,8 @@ then it uses polling method instead.
Following example illustrates, how to perform a synchronous method call:
> (rval, rparams, errorstr) = instance.SyncMethod(
- ... Param1=value1,
- ... Param2=value2, ...)
+ ... {"Param1" : value1,
+ ... "Param2" : value2, ...})
>
\fBNOTE:\fR See the prefix `Sync` in front of a `Method` name.
@@ -326,12 +343,16 @@ It is possible to force LMIShell to use only polling method, see the next
example:
> (rval, rparams, errorstr) = instance.SyncMethod(
- ... PreferPolling=True,
- ... Param1=value1,
- ... Param2=value2, ...)
+ ... {"Param1" : value1,
+ ... "Param2" : value2, ...},
+ ... PreferPolling=True)
>
.TP 4
-.B VALUEMAP PARAMETERS
+.B SIGNAL HANDLING
+LMIShell can properly handle SIGINT and SIGTERM, which instruct the shell to
+cancel the synchronous call. When such signal is received, the background job,
+for which the LMIShell is waiting, will be asked to terminate, as well.
+.SS VALUEMAP PARAMETERS
A CIM Method may contain ValueMap parameters (aliases for constant values) in
its MOF definition. To access these parameters, which contain constant values,
see following code:
@@ -387,14 +408,23 @@ To modify a property, execute following:
> instance.Property = NewPropertyValue
> instance.push()
- LMIReturnValue(rval=0, rparams={}, errorstr='')
+ LMIReturnValue(rval=0, rparams={}, errorstr="")
>
\fBNOTE:\fR If you change an instance object property, you have to execute a `.push()` method to propagate the change to the CIMOM.
+.SS OBJECT REFRESHING
+Local objects used by LMIShell, which represent CIM objects at CIMOM side, can
+get outdated, if such object changes while working with LMIShell's one. To
+update object's properties, methods, etc, follow the next example:
+
+ > instance.refresh()
+ LMIReturnValue(rval=True, rparams={}, errorstr="")
+ >
.SS DELETE AN INSTANCE
A single instance can be removed from the CIMOM by executing:
> instance.delete()
+ True
>
\fBNOTE:\fR After executing the `.delete()` method, all the object properties, methods will become inaccessible.
@@ -587,9 +617,9 @@ example:
... Name="cpu",
... HandlerCreationClassName="CIM_IndicationHandlerCIMXML",
... HandlerSystemCreationClassName="CIM_ComputerSystem",
- ... Destination="http://192.168.122.1:5988" # this is the destination computer, where all the indications will be delivered
+ ... Destination="http://192.168.122.1:5988" # this is the destination computer, where the indications will be delivered
... )
- LMIReturnValue(rval=True, rparams={}, errorstr='')
+ LMIReturnValue(rval=True, rparams={}, errorstr="")
>
In this state, we have a indication subscription created.
@@ -612,7 +642,7 @@ shell quits. If you want to delete the subscriptions sooner, you can use
following methods:
> c.unsubscribe_indication(indication_name)
- LMIReturnValue(rval=True, rparams={}, errorstr='')
+ LMIReturnValue(rval=True, rparams={}, errorstr="")
> c.unsubscribe_all_indications()
>
.SS INDICATION HANDLER
@@ -706,8 +736,7 @@ The cache can be also turned off, see next example:
> c.use_cache(False)
>
-.TP 4
-.B TAB-COMPLETION
+.SS TAB-COMPLETION
Interactive interface also supports tab-completion for basic programming
structures and also for CIM objects (such as namespace, classes, methods and
properties completion, ). Following code shows few examples:
@@ -751,9 +780,27 @@ configuration file, you can set these properties:
If you want to inspect a script after it has been interpreted by the shell,
run this:
- $ lmishell -i some_script.py
+ $ lmishell -i some_script.lmi
# some stuff done
>
+
+\fBNOTE:\fR Preffered extension of LMIShell's scripts is `.lmi`.
+.SS LMI IS INSTANCE
+LMIShell is able to verify, if a LMIInstance or LMIInstanceName object passed
+to `lmi_isinstance()` is a instance of LMIClass. The function is similar to
+python's `isinstance()`.
+
+ > lmi_isinstance(inst, cls)
+ True/False
+ >
+.SS LMI ASSOCIATORS
+LMIShell can speed up associated objects' traversal by manual joining, instead
+of calling `object.associators()`. The call needs to get a list of
+\fBassociation\fR classes, for which the referenced objects will be joined. The
+list must contain objects of `LMIClass`. See following example:
+
+ > associators = lmi_associators(list_of_association_classes)
+ >
.SH "AUTHORS"
.LP
Peter Hatina <phatina(a)redhat.com>