[cura-tools] master: bump release version to 0.10.2 (2128c15)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 2128c15e299de4e1fc927641bcd8c7e89eddf81d
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 29 08:45:00 2014 +0100
bump release version to 0.10.2
>---------------------------------------------------------------
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 d32920a..e951d1a 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.1"
+__version__ = "0.10.2"
diff --git a/cli/man/lmi.1 b/cli/man/lmi.1
index f803377..1ee7a63 100644
--- a/cli/man/lmi.1
+++ b/cli/man/lmi.1
@@ -1,4 +1,4 @@
-.TH lmi 1 "September 2014" "openlmi-scripts 1.0.0" "User Commands"
+.TH lmi 1 "October 2014" "openlmi-scripts 1.0.0" "User Commands"
.SH NAME
lmi \- meta-command for managing systems with OpenLMI providers
9 years, 6 months
[cura-tools] master: improve exception wrapping (655d6a3)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 655d6a36ca7c358e7654fe49cbeb365f3f1c623f
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Oct 14 08:10:24 2014 +0200
improve exception wrapping
CIMError and ConnectionError now contain more informative args when executing CIM operations.
>---------------------------------------------------------------
cli/lmi/shell/LMICIMXMLClient.py | 83 +++++++++++++++-----------
cli/lmi/shell/LMIClass.py | 6 +-
cli/lmi/shell/LMIDecorators.py | 117 +++++++++++++++++++-------------------
cli/lmi/shell/LMIWSMANClient.py | 76 +++++++++++++-----------
4 files changed, 150 insertions(+), 132 deletions(-)
diff --git a/cli/lmi/shell/LMICIMXMLClient.py b/cli/lmi/shell/LMICIMXMLClient.py
index fc62394..950a80f 100644
--- a/cli/lmi/shell/LMICIMXMLClient.py
+++ b/cli/lmi/shell/LMICIMXMLClient.py
@@ -27,8 +27,8 @@ from lmi.shell.LMIUtil import lmi_set_use_exceptions
from lmi.shell.LMIUtil import lmi_instance_to_path
from lmi.shell.LMIUtil import lmi_is_localhost
-from lmi.shell.LMIDecorators import lmi_process_cim_exceptions
-from lmi.shell.LMIDecorators import lmi_process_cim_exceptions_rval
+from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions
+from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions_rval
from lmi.shell.LMIExceptions import CIMError
from lmi.shell.LMIExceptions import ConnectionError
@@ -119,7 +119,7 @@ class LMICIMXMLClient(object):
self.disconnect()
del self._cliconn
- @lmi_process_cim_exceptions(False)
+ @lmi_wrap_cim_exceptions(False)
def connect(self):
"""
Connects to CIMOM.
@@ -172,7 +172,6 @@ class LMICIMXMLClient(object):
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
- @lmi_process_cim_exceptions()
def get_instance_names(self, classname, namespace=None, inst_filter=None,
limit=-1, **kwargs):
"""
@@ -198,6 +197,12 @@ class LMICIMXMLClient(object):
:raises: :py:exc:`.LMIFilterError`, :py:exc:`.CIMError`,
:py:exc:`.ConnectionError`
"""
+ @lmi_wrap_cim_exceptions(prefix="EnumerateInstanceNames " + classname)
+ def get_instance_names_core(classname, namespace):
+ return LMIReturnValue(
+ rval=self._cliconn.EnumerateInstanceNames(
+ classname, namespace))
+
filter_value = ""
filter_key = "Name"
if inst_filter is None:
@@ -217,7 +222,7 @@ class LMICIMXMLClient(object):
if filter_value:
inst_filter[filter_key] = filter_value
try:
- inst_name_list = self._cliconn.EnumerateInstanceNames(
+ inst_name_list, _, errorstr = get_instance_names_core(
classname, namespace)
if inst_filter:
inst_name_list_filtered = []
@@ -234,9 +239,8 @@ class LMICIMXMLClient(object):
errorstr = "Can not filter by '%s'" % filter_key
lmi_raise_or_dump_exception(LMIFilterError(errorstr))
return LMIReturnValue(rval=None, errorstr=errorstr)
- return LMIReturnValue(rval=inst_name_list)
+ return LMIReturnValue(rval=inst_name_list, errorstr=errorstr)
- @lmi_process_cim_exceptions()
def get_instance(self, instance, LocalOnly=True, IncludeQualifiers=False,
IncludeClassOrigin=False, PropertyList=None):
"""
@@ -275,18 +279,21 @@ class LMICIMXMLClient(object):
:raises: :py:exc:`.CIMError`, :py:exc:`.ConnectionError`,
:py:exc:`TypeError`
"""
- return LMIReturnValue(
- rval=self._cliconn.GetInstance(
- lmi_instance_to_path(instance),
- **filter_kwargs(
- LocalOnly=LocalOnly,
- IncludeQualifiers=IncludeQualifiers,
- IncludeClassOrigin=IncludeClassOrigin,
- PropertyList=PropertyList)))
+ @lmi_wrap_cim_exceptions(prefix="GetInstance " + instance.classname)
+ def get_instance_core(path, **kwargs):
+ return LMIReturnValue(
+ rval=self._cliconn.GetInstance(path, **kwargs))
+
+ return get_instance_core(
+ lmi_instance_to_path(instance),
+ **filter_kwargs(
+ LocalOnly=LocalOnly,
+ IncludeQualifiers=IncludeQualifiers,
+ IncludeClassOrigin=IncludeClassOrigin,
+ PropertyList=PropertyList))
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
- @lmi_process_cim_exceptions()
def get_instances(self, classname, namespace=None, inst_filter=None,
client_filtering=False, limit=-1, **kwargs):
"""
@@ -314,6 +321,12 @@ class LMICIMXMLClient(object):
corresponding error string.
:raises: :py:exc:`.CIMError`, :py:exc:`.ConnectionError`
"""
+ @lmi_wrap_cim_exceptions([], prefix="EnumerateInstances " + classname)
+ def get_instances_core(classname, namespace, **kwargs):
+ return LMIReturnValue(
+ rval=self._cliconn.EnumerateInstances(
+ classname, namespace, **kwargs))
+
filter_value = ""
filter_key = "Name"
if inst_filter is None:
@@ -348,16 +361,13 @@ class LMICIMXMLClient(object):
else:
query += " %s" % filter_value
more = True
- inst_list, _, errorstr = self.exec_query(
+ return self.exec_query(
LMICIMXMLClient.QUERY_LANG_WQL, query, namespace)
- if inst_list is None:
- return LMIReturnValue(rval=None, errorstr=errorstr)
- return LMIReturnValue(rval=inst_list)
# Client-side filtering - this is not a pretty solution, but it needs
# to be present due to TOG-Pegasus, which does not raise an exception,
# if an error occurs while performing CQL/WQL query.
- inst_list = self._cliconn.EnumerateInstances(
+ inst_list, _, errorstr = get_instances_core(
classname,
namespace,
LocalOnly=False,
@@ -374,9 +384,9 @@ class LMICIMXMLClient(object):
else:
inst_list_filtered.append(inst)
inst_list = inst_list_filtered
- return LMIReturnValue(rval=inst_list)
+ return LMIReturnValue(rval=inst_list, errorstr=errorstr)
- @lmi_process_cim_exceptions()
+ @lmi_wrap_cim_exceptions(prefix="EnumerateClassNames")
def get_class_names(self, namespace=None, ClassName=None,
DeepInheritance=False):
"""
@@ -404,7 +414,7 @@ class LMICIMXMLClient(object):
ClassName=ClassName,
DeepInheritance=DeepInheritance)))
- @lmi_process_cim_exceptions()
+ @lmi_wrap_cim_exceptions(prefix="GetClass")
def get_class(self, classname, namespace=None, LocalOnly=True,
IncludeQualifiers=True, IncludeClassOrigin=False,
PropertyList=None):
@@ -468,7 +478,6 @@ class LMICIMXMLClient(object):
rval=None, rparams=rparams, errorstr=errorstr)
return LMIReturnValue(rval=minimal_class.superclass)
- @lmi_process_cim_exceptions(-1)
def call_method(self, instance, method, **params):
"""
Executes a method within a given instance.
@@ -490,11 +499,15 @@ class LMICIMXMLClient(object):
:raises: :py:exc:`.CIMError`, :py:exc:`.ConnectionError`,
:py:exc:`TypeError`
"""
+ @lmi_wrap_cim_exceptions(-1, prefix="InvokeMethod " + method)
+ def call_method_core(path, method, **params):
+ rval, rparams = self._cliconn.InvokeMethod(method, path, **params)
+ return LMIReturnValue(rval=rval, rparams=rparams)
+
path = lmi_instance_to_path(instance)
- rval, rparams = self._cliconn.InvokeMethod(method, path, **params)
- return LMIReturnValue(rval=rval, rparams=rparams)
+ return call_method_core(path, method, **params)
- @lmi_process_cim_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="AssociatorNames")
def get_associator_names(self, instance, AssocClass=None, ResultClass=None,
Role=None, ResultRole=None, limit=-1):
"""
@@ -549,7 +562,7 @@ class LMICIMXMLClient(object):
Role=Role,
ResultRole=ResultRole))
- @lmi_process_cim_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="Associators")
def get_associators(self, instance, AssocClass=None, ResultClass=None,
Role=None, ResultRole=None, IncludeQualifiers=False,
IncludeClassOrigin=False, PropertyList=None,
@@ -617,7 +630,7 @@ class LMICIMXMLClient(object):
IncludeClassOrigin=IncludeClassOrigin,
PropertyList=PropertyList))
- @lmi_process_cim_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="ReferenceNames")
def get_reference_names(self, instance, ResultClass=None, Role=None,
limit=-1):
"""
@@ -655,7 +668,7 @@ class LMICIMXMLClient(object):
ResultClass=ResultClass,
Role=Role))
- @lmi_process_cim_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="References")
def get_references(self, instance, ResultClass=None, Role=None,
IncludeQualifiers=False, IncludeClassOrigin=False,
PropertyList=None, limit=-1):
@@ -709,7 +722,7 @@ class LMICIMXMLClient(object):
IncludeClassOrigin=IncludeClassOrigin,
PropertyList=PropertyList))
- @lmi_process_cim_exceptions(None)
+ @lmi_wrap_cim_exceptions(None, prefix="CreateInstance")
def create_instance(self, classname, namespace=None, host=None,
properties=None, qualifiers=None, property_list=None):
"""
@@ -741,7 +754,7 @@ class LMICIMXMLClient(object):
cim_path = self._cliconn.CreateInstance(NewInstance=cim_instance)
return self.get_instance(cim_path, LocalOnly=False)
- @lmi_process_cim_exceptions(-1)
+ @lmi_wrap_cim_exceptions(-1, prefix="ModifyInstance")
def modify_instance(self, instance, IncludeQualifiers=True,
PropertyList=None):
"""
@@ -770,7 +783,7 @@ class LMICIMXMLClient(object):
PropertyList=PropertyList))
return LMIReturnValue(rval=0)
- @lmi_process_cim_exceptions(False)
+ @lmi_wrap_cim_exceptions(False, prefix="DeleteInstance")
def delete_instance(self, instance):
"""
Deletes a :py:class:`wbem.CIMInstance` from the CIMOM side.
@@ -792,7 +805,7 @@ class LMICIMXMLClient(object):
self._cliconn.DeleteInstance(lmi_instance_to_path(instance))
return LMIReturnValue(rval=True)
- @lmi_process_cim_exceptions()
+ @lmi_wrap_cim_exceptions(prefix="ExecQuery")
def exec_query(self, query_lang, query, namespace=None):
"""
Executes a query and returns a list of :py:class:`wbem.CIMInstance`
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index 4d800ee..83efb37 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -25,7 +25,7 @@ from lmi.shell.LMIObjectFactory import LMIObjectFactory
from lmi.shell.LMIExceptions import LMIUnknownPropertyError
from lmi.shell.LMIDecorators import lmi_class_fetch_lazy
-from lmi.shell.LMIDecorators import lmi_process_cim_exceptions
+from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions_rval
from lmi.shell.LMIDecorators import lmi_return_val_if_fail
from lmi.shell.LMIDecorators import lmi_return_if_fail
@@ -157,9 +157,7 @@ class LMIClass(LMIWrapperBaseObject):
return bool(self._cim_class) and \
(not full_fetch or self._cim_class_full_fetch)
- @lmi_process_cim_exceptions(
- lambda x, y: None,
- lambda x, y: None)
+ @lmi_wrap_cim_exceptions_rval(None)
def fetch(self, full_fetch=False):
"""
Manually fetches a wrapped :py:class:`wbem.CIMClass` object.
diff --git a/cli/lmi/shell/LMIDecorators.py b/cli/lmi/shell/LMIDecorators.py
index 8be5694..d99eb3d 100644
--- a/cli/lmi/shell/LMIDecorators.py
+++ b/cli/lmi/shell/LMIDecorators.py
@@ -283,27 +283,25 @@ class lmi_instance_name_fetch_lazy(object):
return fn(self_wr, *args, **kwargs)
return wrapped
-# Default lmi_process_cim_exceptions error handler
-def return_lmi_rval(rval, exc):
- errorstr = exc.args[1] if len(exc.args) > 1 else exc.args[0]
- return LMIReturnValue(rval=rval, errorstr=errorstr)
-
-class lmi_process_cim_exceptions(object):
+class lmi_wrap_cim_exceptions(object):
"""
- Decorator used for CIM-XML exception processing.
+ Decorator used for CIM-XML exception wrapping.
:param rval: rval passed to :py:meth:`.LMIReturnValue.__init__`
:param error_callable: callable used for processing
:py:exc:`wbem.CIMError` and :py:exc:`.ConnectionError`
+ :param str prefix: string prefix for wrapped exception's args
**NOTE:** callables need to take 2 arguments: return value and error
string.
"""
- def __init__(self, rval=None, error_callable=return_lmi_rval):
+ def __init__(self, rval=None, error_callable=None, prefix=""):
self._rval = rval
- self._error_callable = error_callable
+ self._error_callable = self.default_error_callable \
+ if error_callable is None else error_callable
+ self._prefix = prefix
def __call__(self, fn):
"""
@@ -317,72 +315,75 @@ class lmi_process_cim_exceptions(object):
try:
rval = fn(*args, **kwargs)
except wbem.CIMError, e:
- lmi_raise_or_dump_exception(CIMError(e))
- return self._error_callable(self._rval, e)
+ cim_error = self.make_cim_error(e)
+ lmi_raise_or_dump_exception(cim_error)
+ return self._error_callable(self._rval, cim_error)
except wbem.ConnectionError, e:
- lmi_raise_or_dump_exception(ConnectionError(e))
- return self._error_callable(self._rval, e)
+ conn_error = self.make_connection_error(e)
+ lmi_raise_or_dump_exception(conn_error)
+ return self._error_callable(self._rval, conn_error)
except wbem.AuthError, e:
# PyWBEM's AuthError does not have HTTP error code in the
# exception args. We add the code by hand.
- e = ConnectionError(401, "Unauthorized")
- lmi_raise_or_dump_exception(e)
- return self._error_callable(self._rval, e)
+ conn_error = ConnectionError(401, self.make_prefix() + "Unauthorized")
+ lmi_raise_or_dump_exception(conn_error)
+ return self._error_callable(self._rval, conn_error)
return rval
return wrapped
+ @staticmethod
+ def default_error_callable(rval, exc):
+ """
+ Default exception handler, which translates exception into
+ :py:class:`.LMIReturnValue`.
+ """
+ errorstr = exc.args[1] if len(exc.args) > 1 else exc.args[0]
+ return LMIReturnValue(rval=rval, errorstr=errorstr)
-class lmi_process_cim_exceptions_rval(lmi_process_cim_exceptions):
- """
- Decorator used for CIM-XML exception processing.
-
- :param rval: return value of a decorated method in case of exception
- """
- def __init__(self, rval=None):
- super(lmi_process_cim_exceptions_rval, self).__init__(
- rval, lambda r, e: r)
-
+ def make_prefix(self):
+ """
+ Returns prefix string for a CIM exception.
+ """
+ if not self._prefix:
+ return ""
+ return self._prefix + ": "
-class lmi_process_wsman_exceptions(object):
- """
- Decorator used for wsman exception processing.
+ def make_exception_args(self, exc, prefix):
+ """
+ Returns a list of exception arguments. String argument is prefixed by
+ :py:meth:`make_prefix`.
+ """
+ def prefix_arg(arg):
+ if isinstance(arg, basestring):
+ return self.make_prefix() + arg
+ else:
+ return arg
- :param rval: rval passed to :py:meth:`.LMIReturnValue.__init__`
- :param error_callable: callable used for processing
- :py:exc:`wbem.CIMError` and :py:exc:`.ConnectionError`
+ return [prefix_arg(arg) for arg in exc.args]
- **NOTE:** callables need to take 2 arguments: return value and error
- string.
- """
- def __init__(self, rval=None, error_callable=return_lmi_rval):
- self._rval = rval
- self._error_callable = error_callable
-
- def __call__(self, fn):
+ def make_cim_error(self, cim_error):
"""
- Execute a wrapped method.
+ Returns wrapped CIMError from wbem.CIMError.
+ """
+ return CIMError(
+ *self.make_exception_args(
+ cim_error, self.make_prefix()))
- :param instancemethod fn: decorated method
- :raises: :py:exc:`.CIMError`
+ def make_connection_error(self, conn_error):
"""
- @wraps(fn)
- def wrapped(*args, **kwargs):
- try:
- rval = fn(*args, **kwargs)
- except wbem.CIMError, e:
- x = CIMError(e)
- lmi_raise_or_dump_exception(CIMError(e))
- return self._error_callable(self._rval, e)
- return rval
- return wrapped
+ Returns wrapped ConnectionError from wbem.ConnectionError.
+ """
+ return ConnectionError(
+ *self.make_exception_args(
+ conn_error, self.make_prefix()))
-class lmi_process_wsman_exceptions_rval(lmi_process_wsman_exceptions):
+class lmi_wrap_cim_exceptions_rval(lmi_wrap_cim_exceptions):
"""
- Decorator used for wsman exception processing.
+ Decorator used for CIM-XML exception wrapping.
:param rval: return value of a decorated method in case of exception
"""
- def __init__(self, rval=None):
- super(lmi_process_wsman_exceptions_rval, self).__init__(
- rval, lambda r, e: r)
+ def __init__(self, rval=None, prefix=""):
+ super(lmi_wrap_cim_exceptions_rval, self).__init__(
+ rval, lambda r, e: r, prefix)
diff --git a/cli/lmi/shell/LMIWSMANClient.py b/cli/lmi/shell/LMIWSMANClient.py
index c506dd2..cfa794c 100644
--- a/cli/lmi/shell/LMIWSMANClient.py
+++ b/cli/lmi/shell/LMIWSMANClient.py
@@ -18,8 +18,8 @@ import types
from lmi.shell.compat import *
-from lmi.shell.LMIDecorators import lmi_process_wsman_exceptions
-from lmi.shell.LMIDecorators import lmi_process_wsman_exceptions_rval
+from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions
+from lmi.shell.LMIDecorators import lmi_wrap_cim_exceptions_rval
from lmi.shell.LMIExceptions import CIMError
from lmi.shell.LMIExceptions import LMINotSupported
@@ -622,7 +622,6 @@ class LMIWSMANClient(object):
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
- @lmi_process_wsman_exceptions()
def get_instance_names(self, classname, namespace=None, inst_filter=None,
limit=-1, **kwargs):
"""
@@ -647,14 +646,17 @@ class LMIWSMANClient(object):
appropriate error string
:raises: :py:exc:`.CIMError`
"""
- inst_names_list = self.enumerate(
- LMIWSMANClient.RES_INSTANCE_NAME, classname, namespace,
- inst_filter, limit, **kwargs)
- return LMIReturnValue(rval=inst_names_list)
+ @lmi_wrap_cim_exceptions(prefix="EnumerateInstanceNames " + classname)
+ def get_instance_names_core():
+ inst_names_list = self.enumerate(
+ LMIWSMANClient.RES_INSTANCE_NAME, classname, namespace,
+ inst_filter, limit, **kwargs)
+ return LMIReturnValue(rval=inst_names_list)
+ return get_instance_names_core()
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
- @lmi_process_wsman_exceptions()
+ @lmi_wrap_cim_exceptions(prefix="EnumerateInstances")
def get_instances(self, classname, namespace=None, inst_filter=None,
client_filtering=False, limit=-1, **kwargs):
"""
@@ -685,9 +687,10 @@ class LMIWSMANClient(object):
# We do not enumerate instances directly. First instance names are
# pulled from CIMOM. This is done due to lack of keybindings
# information in the pull response of the instance.
- inst_names_list = self.enumerate(
- LMIWSMANClient.RES_INSTANCE_NAME, classname, namespace,
- inst_filter, limit, **kwargs)
+ inst_names_list, _, errorstr = self.get_instance_names(
+ classname, namespace, inst_filter, limit, **kwargs)
+ if not inst_names_list:
+ return LMIReturnValue(rval=None, errorstr=errorstr)
# Get all the instances from instance names. Now we can construct
# LMIInstance also with object path information.
@@ -710,9 +713,8 @@ class LMIWSMANClient(object):
inst_list_filtered.append(inst)
inst_list = inst_list_filtered
- return LMIReturnValue(rval=inst_list)
+ return LMIReturnValue(rval=inst_list, errorstr=errorstr)
- @lmi_process_wsman_exceptions()
def get_instance(self, instance, LocalOnly=True, IncludeQualifiers=False,
IncludeClassOrigin=False, PropertyList=None):
"""
@@ -735,6 +737,16 @@ class LMIWSMANClient(object):
``errorstr`` is set to corresponding error string
:raises: :py:exc:`.CIMError`
"""
+ @lmi_wrap_cim_exceptions(prefix="GetInstance " + instance.classname)
+ def get_instance_core(path, options):
+ uri = self._cls_ns_to_uri(path.classname, path.namespace)
+ doc = self._cliconn.get(options, uri)
+ self._xml_check_response(doc)
+ inst = self._xml_to_wbem_instance(
+ doc.body().child(), path.namespace, self._cliconn.host())
+ inst.path = path
+ return LMIReturnValue(rval=inst)
+
path = lmi_instance_to_path(instance)
options = pywsman.ClientOptions()
@@ -744,16 +756,8 @@ class LMIWSMANClient(object):
else:
value = str(v)
options.add_selector(k, value)
- uri = self._cls_ns_to_uri(path.classname, path.namespace)
- doc = self._cliconn.get(options, uri)
- self._xml_check_response(doc)
-
- inst = self._xml_to_wbem_instance(
- doc.body().child(), path.namespace, self._cliconn.host())
- # Adjust CIM Object Path by hand
- inst.path = path
- return LMIReturnValue(rval=inst)
+ return get_instance_core(path, options)
def get_class_names(self, *args, **kwargs):
"""
@@ -777,7 +781,6 @@ class LMIWSMANClient(object):
return LMIReturnValue(
rval=None, errorstr="GetSuperClass() not supported")
- @lmi_process_wsman_exceptions(-1)
def call_method(self, instance, method, **params):
"""
Executes a method within a given instance.
@@ -798,26 +801,29 @@ class LMIWSMANClient(object):
and errorstr to appropriate error string
:raises: :py:exc:`.CIMError`
"""
+ @lmi_wrap_cim_exceptions(-1, prefix="InvokeMethod " + method)
+ def call_method_core(method, path, options):
+ uri = self._cls_ns_to_uri(path.classname, path.namespace)
+ doc = self._cliconn.invoke(options, uri, method)
+ self._xml_check_response(doc)
+ method_doc = doc.body().get(method + "_OUTPUT")
+ return self._xml_invoke_rval(
+ method_doc, path.namespace, self._cliconn.host())
+
path = lmi_instance_to_path(instance)
options = pywsman.ClientOptions()
for k, v in path.keybindings.iteritems():
options.add_selector(k, str(v))
- uri = self._cls_ns_to_uri(path.classname, path.namespace)
# Add method parameters
for k, v in params.iteritems():
options.add_property(k, str(v))
# Invoke the method
- doc = self._cliconn.invoke(options, uri, method)
- self._xml_check_response(doc)
-
- method_doc = doc.body().get(method + "_OUTPUT")
- return self._xml_invoke_rval(
- method_doc, path.namespace, self._cliconn.host())
+ return call_method_core(method, path, options)
- @lmi_process_wsman_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="AssociatorNames")
def get_associator_names(self, instance, AssocClass=None, ResultClass=None,
Role=None, ResultRole=None, limit=-1):
"""
@@ -868,7 +874,7 @@ class LMIWSMANClient(object):
LMIWSMANClient.RES_INSTANCE_NAME, AssocClass, ResultClass, Role,
ResultRole, limit)
- @lmi_process_wsman_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="Associators")
def get_associators(self, instance, AssocClass=None, ResultClass=None,
Role=None, ResultRole=None, IncludeQualifiers=False,
IncludeClassOrigin=False, PropertyList=None, limit=-1):
@@ -923,7 +929,7 @@ class LMIWSMANClient(object):
LMIWSMANClient.RES_INSTANCE, AssocClass,
ResultClass, Role, ResultRole, limit)
- @lmi_process_wsman_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="ReferenceNames")
def get_reference_names(self, instance, ResultClass=None, Role=None,
limit=-1):
"""
@@ -959,7 +965,7 @@ class LMIWSMANClient(object):
LMIWSMANClient.RES_INSTANCE_NAME, None,
ResultClass, Role, None, limit)
- @lmi_process_wsman_exceptions_rval([])
+ @lmi_wrap_cim_exceptions_rval([], prefix="References")
def get_references(self, instance, ResultClass=None, Role=None,
IncludeQualifiers=False, IncludeClassOrigin=False,
PropertyList=None, limit=-1):
@@ -1022,7 +1028,7 @@ class LMIWSMANClient(object):
return LMIReturnValue(
rval=False, errorstr="DeleteInstance() not supported")
- @lmi_process_wsman_exceptions()
+ @lmi_wrap_cim_exceptions(prefix="ExecQuery")
def exec_query(self, query_lang, query, namespace=wbem.DEFAULT_NAMESPACE):
"""
Executes a query and returns a list of :py:class:`wbem.CIMInstance`
9 years, 6 months
[cura-tools] master: scripts: added CONNECTION_TIMEOUT property (8f46896)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 8f4689671458964ca24c853014904a30112f0035
Author: Michal Minar <miminar(a)redhat.com>
Date: Wed Oct 8 13:57:38 2014 +0200
scripts: added CONNECTION_TIMEOUT property
Allow to override default connection timeout on particular commands.
>---------------------------------------------------------------
cli/lmi/scripts/common/command/meta.py | 19 ++++++++++++++++++-
cli/lmi/scripts/common/command/session.py | 17 +++++++++++++++++
doc/src/scripts/devel/command-properties.rst | 10 +++++++++-
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/scripts/common/command/meta.py b/cli/lmi/scripts/common/command/meta.py
index 3e9db7b..d34410c 100644
--- a/cli/lmi/scripts/common/command/meta.py
+++ b/cli/lmi/scripts/common/command/meta.py
@@ -125,6 +125,19 @@ def _handle_namespace(dcl):
return namespace
dcl['cim_namespace'] = classmethod(_new_cim_namespace)
+def _handle_connection_timeout(dcl):
+ """
+ Overrides ``connection_timeout()`` class method if ``CONNECTION_TIMEOUT``
+ property is given.
+
+ :param dictionary dcl: Class dictionary being modified by this method.
+ """
+ if 'CONNECTION_TIMEOUT' in dcl:
+ timeout = dcl.pop('CONNECTION_TIMEOUT')
+ def _new_connection_timeout(_cls):
+ return timeout
+ dcl['connection_timeout'] = classmethod(_new_connection_timeout)
+
def _handle_callable(name, bases, dcl):
"""
Process the ``CALLABLE`` property of end-point command. Create the
@@ -597,7 +610,7 @@ class EndPointCommandMetaClass(abc.ABCMeta):
class SessionCommandMetaClass(EndPointCommandMetaClass):
"""
Meta class for commands operating upon a session object.
- All associated functions take as first argument an namespace abstraction
+ All associated functions take as first argument a namespace abstraction
of type ``lmi.shell``.
Handles following class properties:
@@ -607,10 +620,14 @@ class SessionCommandMetaClass(EndPointCommandMetaClass):
function. Defaults to ``"root/cimv2"``. If ``False``, raw
:py:class:`lmi.shell.LMIConnection` object will be passed to
associated function.
+ ``CONNECTION_TIMEOUT`` : ``int``
+ Maximum number of seconds to wait for broker's response. If reached,
+ :py:class:`~lmi.shell.LMIExceptions.ConnectionError` will be raised.
"""
def __new__(mcs, name, bases, dcl):
_handle_usage(name, bases, dcl)
_handle_namespace(dcl)
+ _handle_connection_timeout(dcl)
_handle_callable(name, bases, dcl)
return EndPointCommandMetaClass.__new__(mcs, name, bases, dcl)
diff --git a/cli/lmi/scripts/common/command/session.py b/cli/lmi/scripts/common/command/session.py
index da22b4a..cbbf9fa 100644
--- a/cli/lmi/scripts/common/command/session.py
+++ b/cli/lmi/scripts/common/command/session.py
@@ -54,6 +54,16 @@ class LmiSessionCommand(LmiEndPointCommand):
return Configuration.get_instance().namespace
@classmethod
+ def connection_timeout(cls):
+ """
+ Returns maximum number of seconds the client shall wait for broker's
+ reply. Defaults to ``None`` which means that it's up to the connection
+ object itself to decide. It can be oveririden with
+ ``CONNECTION_TIMEOUT`` property in declaration of command.
+ """
+ return None
+
+ @classmethod
def dest_pos_args_count(cls):
"""
There is a namespace/connection object passed as the first positional
@@ -181,6 +191,13 @@ class LmiSessionCommand(LmiEndPointCommand):
raise TypeError("expected an instance of LMIConnection for"
" connection argument, not %s" % repr(connection))
namespace = self.cim_namespace()
+ timeout = self.connection_timeout()
+ if timeout is not None:
+ if hasattr(connection.connection, "timeout"):
+ LOG().debug("Set connection timeout to %d seconds.", timeout)
+ connection.timeout = timeout * 1000
+ else:
+ LOG().debug("Could not set connection timeout.")
if namespace is not None:
connection = LMIUtil.lmi_wrap_cim_namespace(
connection, namespace)
diff --git a/doc/src/scripts/devel/command-properties.rst b/doc/src/scripts/devel/command-properties.rst
index 1a6ab11..c7dfd3d 100644
--- a/doc/src/scripts/devel/command-properties.rst
+++ b/doc/src/scripts/devel/command-properties.rst
@@ -234,6 +234,7 @@ Function invocation
Influencing properties:
* ``NAMESPACE`` (namespace_)
+ * ``CONNECTION_TIMEOUT`` (timeout_)
Property descriptions
~~~~~~~~~~~~~~~~~~~~~
@@ -256,11 +257,17 @@ Property descriptions
This usually won't need any modification. Sometimes perhaps associated
function might want to access more than one namespace, in that case an
- instance of :py:class:`lmi.shell.LMIConnection.LMIConnection` might prove more useful.
+ instance of :py:class:`~lmi.shell.LMIConnection.LMIConnection` might prove more useful.
Namespace can also be overriden globally in a configuration file or with
an option on command line.
+.. _timeout:
+
+``CONNECTION_TIMEOUT`` : ``int`` (defaults to ``None``)
+ Specifies maximum number of seconds we should wait for broker's reply. If
+ reached, :py:class:`~lmi.shell.LMIExceptions.ConnectionError` will be
+ raised. The default value is provided by underlying library [#]_.
Output rendering
----------------
@@ -565,6 +572,7 @@ method.
have nothing to do with arguments.
.. [#] Application object is accessible through ``app`` property of each
command instance.
+.. [#] *lmiwbem*'s default timeout is 1 minute as of now.
.. ****************************************************************************
9 years, 6 months
[cura-tools] master: Added min_column_sizes param to the TableFormatter (86b2092)
by pschiffe@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 86b2092259d77a49b10a776f91601ba96f46c162
Author: Peter Schiffer <pschiffe(a)redhat.com>
Date: Tue Oct 7 17:44:34 2014 +0200
Added min_column_sizes param to the TableFormatter
With min_column_sizes it's possible to define minimal size of selected columns
in tabular output of scripts.
>---------------------------------------------------------------
cli/lmi/scripts/common/formatter/__init__.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/scripts/common/formatter/__init__.py b/cli/lmi/scripts/common/formatter/__init__.py
index d79ba58..e157bf0 100644
--- a/cli/lmi/scripts/common/formatter/__init__.py
+++ b/cli/lmi/scripts/common/formatter/__init__.py
@@ -246,10 +246,15 @@ class TableFormatter(ListFormatter):
The command must be provided as content of one row. This row is then not
printed and the command is executed.
+
+ :param dictionary min_column_sizes: Dictionary of minimal column sizes, where
+ keys are column numbers starting from 0, and values are minimal column
+ sizes.
"""
- def __init__(self, stream, padding=0, no_headings=False):
+ def __init__(self, stream, padding=0, no_headings=False, min_column_sizes=False):
super(TableFormatter, self).__init__(stream, padding, no_headings)
self.stash = []
+ self.min_column_sizes = min_column_sizes
def print_text_row(self, row, column_sizes):
for i in xrange(len(row)):
@@ -276,7 +281,11 @@ class TableFormatter(ListFormatter):
else:
row = self.column_names
for i in xrange(len(row)):
- column_sizes.append(len(row[i]))
+ if self.min_column_sizes and i in self.min_column_sizes \
+ and self.min_column_sizes[i] > len(row[i]):
+ column_sizes.append(self.min_column_sizes[i])
+ else:
+ column_sizes.append(len(row[i]))
except StopIteration:
pass # empty stash
9 years, 6 months
[cura-tools] master: doc: lmishell's documentation update (b8adab4)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit b8adab461155944c176ff6a6ea710cbbcdb2eb80
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Oct 8 13:17:50 2014 +0200
doc: lmishell's documentation update
There are several changes that popped out when Jan started working on the new OpenLMI docs. The patch reflects most of desired changes listed here: https://lists.fedorahosted.org/pipermail/openlmi-devel/2014-October/00238...
>---------------------------------------------------------------
doc/src/shell/associated_objects.rst | 12 ++++-
doc/src/shell/classes.rst | 22 ++++----
doc/src/shell/indications.rst | 98 ++++++++++++++++++++--------------
doc/src/shell/instance_names.rst | 2 +-
doc/src/shell/instances.rst | 19 +++++--
5 files changed, 92 insertions(+), 61 deletions(-)
diff --git a/doc/src/shell/associated_objects.rst b/doc/src/shell/associated_objects.rst
index 42f0e1f..3610aea 100644
--- a/doc/src/shell/associated_objects.rst
+++ b/doc/src/shell/associated_objects.rst
@@ -1,7 +1,15 @@
Associated Objects
==================
-CIM defines an association relationship between managed objects. Following text
-describes the means of retrieving associated objects within a given one.
+An association from CIM perspective is a type of class that contains two or
+more references. Associations represent relationships between two or more
+classes.
+
+Associations are classes which establish a relationship between classes without
+affecting any of the related classes. In other words, the addition of an
+association has no effect on any of the related classes.
+
+Following text describes the means of retrieving associated objects within
+a given one.
.. _associators_instances:
diff --git a/doc/src/shell/classes.rst b/doc/src/shell/classes.rst
index 3826e1e..8acaef0 100644
--- a/doc/src/shell/classes.rst
+++ b/doc/src/shell/classes.rst
@@ -1,9 +1,9 @@
Classes
=======
-Each class in LMIShell represents a class provided by a CIMOM. You can get a
-list of its properties, methods, instances, instance names and ValueMap
-properties. It is also possible to print a documentation string, create a new
-instance or new instance name.
+Each :py:class:`.LMIClass` in LMIShell represents a class implemented by a
+certain provider. You can get a list of its properties, methods, instances,
+instance names and ValueMap properties. It is also possible to print a
+documentation string, create a new instance or new instance name.
Getting a class object
----------------------
@@ -19,16 +19,16 @@ To get a class which is provided by a broker, you can do following:
Fetching a class
----------------
Objects of :py:class:`.LMIClass` use lazy fetching method, because some methods
-do not need the :py:class:`lmiwbem.CIMClass` object.
+do not need the :py:class:`wbem.CIMClass` object.
-To manually fetch the :py:class:`lmiwbem.CIMClass` object, call following:
+To manually fetch the :py:class:`wbem.CIMClass` object, call following:
.. code-block:: python
> cls.fetch()
>
-The methods, which need the :py:class:`lmiwbem.CIMClass` object to be fetched
+The methods, which need the :py:class:`wbem.CIMClass` object to be fetched
from CIMOM, do this action automatically, without the need of calling
:py:meth:`.LMIClass.fetch` method by hand.
@@ -87,8 +87,8 @@ To get :py:class:`.LMIInstance` object, execute the following example:
Get Instance Names
^^^^^^^^^^^^^^^^^^
-The :py:class:`lmiwbem.CIMInstanceName` objects clearly identify
-:py:class:`lmiwbem.CIMInstance` objects. LMIShell can retrieve
+The :py:class:`wbem.CIMInstanceName` objects clearly identify
+:py:class:`wbem.CIMInstance` objects. LMIShell can retrieve
:py:class:`.LMIInstanceName` objects, by calling following:
.. code-block:: python
@@ -116,7 +116,7 @@ following example:
New Instance Name
^^^^^^^^^^^^^^^^^
-LMIShell is able to create a new wrapped :py:class:`lmiwbem.CIMInstanceName`, if
+LMIShell is able to create a new wrapped :py:class:`wbem.CIMInstanceName`, if
you know all the primary keys of a remote object. This instance name object can
be then used to retrieve the whole instance object.
@@ -242,7 +242,7 @@ class (refer to :ref:`startup_connection`). See next example:
Wrapped Object
^^^^^^^^^^^^^^
-This property returns a wrapped :py:mod:`lmiwbem` object. See the example:
+This property returns a wrapped :py:mod:`wbem` object. See the example:
.. code-block:: python
diff --git a/doc/src/shell/indications.rst b/doc/src/shell/indications.rst
index a69de2e..b3f0af3 100644
--- a/doc/src/shell/indications.rst
+++ b/doc/src/shell/indications.rst
@@ -1,16 +1,28 @@
Indications
===========
-Indication is a reaction to some specific event that occurs in response to a
-particular change in data. LMIShell can perform an indication subscription, by
-which we can receive such event responses.
+From CIM point of view, an *indication* is the representation of the occurrence
+of an event. Indications are classes so they can have properties and methods.
+Instances of an indication are transient and can not be obtained by using CIM
+Operations, such as ``GetInstance()`` or ``EnumerateInstances()``. Indications
+can only be received by subscribing to them.
+An indication subscription is performed by the creation of an
+*CIM_IndicationSubscription* association instance that references an
+*CIM_IndicationFilter* (a filter) instance, and an *CIM_IndicationHandler*
+(a handler) instance. The filter contains the query that selects an *Indication*
+class or classes. The size and complexity of the result delivered to the
+destination is defined by the query.
+
+LMIShell can perform an indication subscription, by which we can receive such
+event responses. The shell also provides a mechanism for the indication
+reception.
Indication handler
------------------
-The first step is to set up an indication handler. This is a routine that will
-be triggered when the OpenLMI sends us an indication for which we have
-registered (see below). It is important to set up the handler first so that we
+When working with indications, the first step is to set up an indication handler. This is a routine that will
+be triggered when the CIMOM sends us an indication for which we have
+subscribed (see below). It is important to set up the handler first so that we
can generate a unique registration name and avoid conflicts with other clients
that may wish to register for the same indication. The indication handler may
be part of the same process that will initiate the provider registration or it
@@ -26,18 +38,18 @@ indication:
... """
... Indication handler.
...
- ... :param CIMInstance indication: exported lmiwbem.CIMInstance
+ ... :param wbem.CIMInstance indication: exported wbem.CIMInstance
... :param arg1: ...
... :param arg2: ...
... ...
... """
... do_something_with(indication)
- > listener = LMIIndicationListener()
+ > listener = LMIIndicationListener(listening_address, listening_port, certfile, keyfile, trust_store)
> unique_name = listener.add_handler("indication-name-XXXXXXXX", handler, arg1, arg2, **kwargs)
- > listener.start(listening_port, cert_file, key_file)
+ > listener.start()
>
-The first argument of the handler is a :py:class:`lmiwbem.CIMInstance` object;
+The first argument of the handler is a :py:class:`wbem.CIMInstance` object;
the exported indication. The other arguments are handler-specific; Any number of
arguments may be specified as necessary; those arguments must then be provided
to the :py:meth:`.LMIIndicationListener.add_handler` method of the listener. In
@@ -50,40 +62,37 @@ substituted name is returned as the result of the
:py:meth:`.LMIIndicationListener.add_handler` method so it can be used later.
When all necessary handlers are registered, the listener can be started by
-calling :py:meth:`.LMIIndicationListener.start`, which takes up to three
-arguments, one mandatory (port) and two optional when using SSL (cert_file and
-key_file; paths to X509 certificate and private key in PEM format).
+calling :py:meth:`.LMIIndicationListener.start`.
+
+When a secure connection is desired, :py:class:`.LMIIndicationListener` can be
+constructed with `keyfile`, `certfile` and `trust_store` (paths to X509
+certificate, private key in PEM format and trust store).
Subscribing to an indication
----------------------------
-The LMIShell is capable of creating an indication subscription with the filter and
-handler objects in one single step. This example is based upon `sblim-cmpi-base`
-provider.
+Now, when the indication listener is up and running, the indication
+subscription can be done. The LMIShell is capable of creating an indication
+subscription with the filter and handler objects in one single step.
-How to subscribe to an indication, please, follow the next example:
+Example of indication subscription with 3 mandatory arguments:
.. code-block:: python
- > c = connect("host", "privileged_user", "password")
- > c.subscribe_indication(
- ... QueryLanguage="WQL",
- ... Query='SELECT * FROM CIM_InstModification',
- ... Name=unique_name,
- ... 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
- ... Destination="http://192.168.122.1:%d" % listening_port
- ... )
- LMIReturnValue(rval=True, rparams={}, errorstr="")
- >
+ > c = connect("host", "privileged_user", "password")
+ > c.subscribe_indication(
+ ... Name=unique_name,
+ ... Query='SELECT * FROM CIM_InstModification',
+ ... Destination="http://192.168.122.1:%d" % listening_port
+ ... )
+ LMIReturnValue(rval=True, rparams={}, errorstr="")
+ >
+
+**NOTE:** Make sure, that you an account which has write privileges in the
+*root/interop* namespace.
-The previous code can be simplified by omitting some optional parameters:
+The indication subscription can created with an extensive list of arguments,
+where optional arguments can be specified:
* *QueryLanguage*: *DMTF:CQL*
* *CreationNamespace*: *root/interop*
@@ -94,24 +103,29 @@ The previous code can be simplified by omitting some optional parameters:
* *HandlerCreationClassName*: *CIM_IndicationHandlerCIMXML*
* *HandlerSystemCreationClassName*: *CIM_ComputerSystem*
-Simplified subscription:
-
.. code-block:: python
> c = connect("host", "privileged_user", "password")
> c.subscribe_indication(
- ... Name=unique_name,
+ ... QueryLanguage="WQL",
... Query='SELECT * FROM CIM_InstModification',
- ... Destination="http://192.168.122.1:5988"
+ ... Name=unique_name,
+ ... CreationNamespace="root/interop",
+ ... SubscriptionCreationClassName="CIM_IndicationSubscription",
+ ... FilterCreationClassName="CIM_IndicationFilter",
+ ... FilterSystemCreationClassName="CIM_ComputerSystem",
+ ... FilterSourceNamespace="root/cimv2",
+ ... HandlerCreationClassName="CIM_IndicationHandlerCIMXML",
+ ... HandlerSystemCreationClassName="CIM_ComputerSystem",
+ ... Destination="http://192.168.122.1:%d" % listening_port
... )
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
^^^^^^^^^^^^^^^^^^^^^^^^^
By default all subscriptions created by LMIShell will be **auto-deleted**, when
@@ -119,6 +133,7 @@ the shell quits. To change this behavior, you can pass :samp:`Permanent=True`
keyword parameter to :py:meth:`.LMIConnection.subscribe_indication` call, which
will prevent LMIShell from deleting the subscription.
+
Listing subscribed indications
------------------------------
To list all the subscribed indications, run following code:
@@ -130,6 +145,7 @@ To list all the subscribed indications, run following code:
> subscribed_ind_lst = c.subscribed_indications()
>
+
Unsubscribing from an indication
---------------------------------
By default, the subscriptions created by the shell are auto-deleted, when the
diff --git a/doc/src/shell/instance_names.rst b/doc/src/shell/instance_names.rst
index 4e9c68b..f1cc50e 100644
--- a/doc/src/shell/instance_names.rst
+++ b/doc/src/shell/instance_names.rst
@@ -104,7 +104,7 @@ instance name (refer to :ref:`startup_connection`). See next example:
Wrapped Object
^^^^^^^^^^^^^^
-This property returns a wrapped :py:mod:`lmiwbem` object. See the example:
+This property returns a wrapped :py:mod:`wbem` object. See the example:
.. code-block:: python
diff --git a/doc/src/shell/instances.rst b/doc/src/shell/instances.rst
index 7bc1599..c66f387 100644
--- a/doc/src/shell/instances.rst
+++ b/doc/src/shell/instances.rst
@@ -1,8 +1,9 @@
Instances
=========
-Each instance in LMIShell represents a CIM instance provided by a CIMOM.
+Each :py:class:`.LMIInstance` in LMIShell represents a CIM instance provided by
+a certain provider.
-Operations, that can be done within a :py:class:`.LMIInstance`:
+Operations that can be performed within a :py:class:`.LMIInstance`:
* get and set properties
* list/print/execute its methods
@@ -61,10 +62,16 @@ Synchronous methods
^^^^^^^^^^^^^^^^^^^
LMIShell can perform synchronous method call, which means, that the LMIShell is
able to synchronously wait for a Job object to change its state to `Finished`
-state and then return the job's return parameters. LMIShell can perform the
-synchronous method call, if the given method returns a object of following
-classes:
+state and then return the job's return parameters.
+Most of the implemented methods in OpenLMI providers are *asynchronous*
+methods, which means that user can execute such method and do other desired
+actions while waiting for the result(s).
+
+LMIShell can perform the synchronous method call, if the given method returns a
+object of following classes:
+
+* :py:class:`LMI_SELinuxJob`
* :py:class:`LMI_StorageJob`
* :py:class:`LMI_SoftwareInstallationJob`
* :py:class:`LMI_SoftwareVerificationJob`
@@ -317,7 +324,7 @@ instance (refer to :ref:`startup_connection`). See next example:
Wrapped Object
^^^^^^^^^^^^^^
-This property returns a wrapped :py:mod:`lmiwbem` object. See the example:
+This property returns a wrapped :py:mod:`wbem` object. See the example:
.. code-block:: python
9 years, 6 months
[cura-tools] master: doc: use readthedocs theme (37fe1da)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 37fe1da0548238afca38563335a3bc27c354b4e7
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Oct 6 10:53:35 2014 +0200
doc: use readthedocs theme
The theme has three levels of navigation menu on the left.
>---------------------------------------------------------------
Diff suppressed because of size. To see it, use:
git diff --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol ^37fe1da0548238afca38563335a3bc27c354b4e7~1 37fe1da0548238afca38563335a3bc27c354b4e7
9 years, 6 months
[cura-tools] master: doc: wrap text in one table (dd808f0)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit dd808f0b22cae7fac20e3e828bec500186a5d4f3
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Oct 6 16:45:35 2014 +0200
doc: wrap text in one table
Several rows in a dictionary table contain quite a long text. Without
being treated as a block, the text won't get wrapped causing the table
to be equipped with scrollbars.
>---------------------------------------------------------------
doc/src/scripts/development.txt | 67 +++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/doc/src/scripts/development.txt b/doc/src/scripts/development.txt
index 032f29d..c4cb836 100644
--- a/doc/src/scripts/development.txt
+++ b/doc/src/scripts/development.txt
@@ -14,40 +14,39 @@ metacommand* and a package (rpm/python egg) containing it. In this
documentation you'll encounter another words seemingly meaning the same.
Following dictionary tries to clear out any confusion:
- +-----------------------+----------------------------------------------------------------+
- | Term | Description |
- +=======================+================================================================+
- | *command* | Either a subcommand of *LMI metacommand* or a software |
- | | package containing a *script*. It may have several |
- | | *subcommands*. |
- +-----------------------+----------------------------------------------------------------+
- | *script* | Python library utilizing :ref:`lmi_shell` for instrumenting |
- | | CIM providers through a CIMOM broker comming with one |
- | | or more *commands* for *LMI metacommand*. |
- +-----------------------+----------------------------------------------------------------+
- | *subcommand* | Same as *command* used in relation to either |
- | | *metacommand* or another *command*. |
- +-----------------------+----------------------------------------------------------------+
- | *command wrapper* | Implementation of a *command* in a *script* as a subclass of |
- | | :py:class:`~lmi.scripts.common.command.base.LmiBaseCommand`. |
- +-----------------------+----------------------------------------------------------------+
- | *top-level command* | Direct *subcommand* of *LMI metacommand*. It appers in its |
- | | help message. |
- +-----------------------+----------------------------------------------------------------+
- | *end-point command* | *command* without any *subcommand*. It handles command-line |
- | | arguments and renders output. |
- +-----------------------+----------------------------------------------------------------+
- | *command multiplexer* | *command* with one or more *subcommands*. They do not handle |
- | | command line arguments. |
- +-----------------------+----------------------------------------------------------------+
- | *command name* | Is a single word denoting *command* on a command line. |
- +-----------------------+----------------------------------------------------------------+
- | *command's full name* | All *command names* leading up to the *command* optionally |
- | | including the ``lmi``. For example in statement |
- | | ``lmi -h myhost.example.org storage fs create ext4 /dev/vda5`` |
- | | the full name of *command* ``create`` is |
- | | ``lmi storage fs create``. |
- +-----------------------+----------------------------------------------------------------+
+ +-----------------------+------------------------------------------------------------------+
+ | Term | Description |
+ +=======================+==================================================================+
+ | *command* | | Either a subcommand of *LMI metacommand* or a software package |
+ | | containing a *script*. It may have several *subcommands*. |
+ +-----------------------+------------------------------------------------------------------+
+ | *script* | | Python library utilizing :ref:`lmi_shell` for instrumenting |
+ | | CIM providers through a CIMOM broker comming with one |
+ | | or more *commands* for *LMI metacommand*. |
+ +-----------------------+------------------------------------------------------------------+
+ | *subcommand* | | Same as *command* used in relation to either |
+ | | *metacommand* or another *command*. |
+ +-----------------------+------------------------------------------------------------------+
+ | *command wrapper* | | Implementation of a *command* in a *script* as a subclass of |
+ | | :py:class:`~lmi.scripts.common.command.base.LmiBaseCommand`. |
+ +-----------------------+------------------------------------------------------------------+
+ | *top-level command* | | Direct *subcommand* of *LMI metacommand*. It appers in its |
+ | | help message. |
+ +-----------------------+------------------------------------------------------------------+
+ | *end-point command* | | *command* without any *subcommand*. It handles command-line |
+ | | arguments and renders output. |
+ +-----------------------+------------------------------------------------------------------+
+ | *command multiplexer* | | *command* with one or more *subcommands*. They do not handle |
+ | | command line arguments. |
+ +-----------------------+------------------------------------------------------------------+
+ | *command name* | | Is a single word denoting *command* on a command line. |
+ +-----------------------+------------------------------------------------------------------+
+ | *command's full name* | | All *command names* leading up to the *command* optionally |
+ | | including the ``lmi``. For example in statement |
+ | | ``lmi -h myhost.example.org storage fs create ext4 /dev/vda5`` |
+ | | the full name of *command* ``create`` is |
+ | | ``lmi storage fs create``. |
+ +-----------------------+------------------------------------------------------------------+
.. only:: html
9 years, 6 months
[cura-tools] master: doc: place the metacommand before shell (88008c5)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 88008c5087e8d2d203d7af8335c573932daff04c
Author: Michal Minar <miminar(a)redhat.com>
Date: Mon Oct 6 10:38:02 2014 +0200
doc: place the metacommand before shell
metacommand is supposedly easier to digest for a newcomer
>---------------------------------------------------------------
doc/src/Makefile | 2 +-
doc/src/index-html.txt | 5 +++--
doc/src/index-other.txt | 2 +-
doc/src/index-rtd.txt | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/doc/src/Makefile b/doc/src/Makefile
index af9a8ee..35db676 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -46,8 +46,8 @@ index-%: subindexes-%
echo ".. toctree::"; \
echo " :maxdepth: $$DEPTH"; \
echo ""; \
- echo " shell-index"; \
echo " metacommand-index"; \
+ echo " shell-index"; \
if [ "$*" == html -o "$*" == rtd ]; then \
echo " api"; \
fi; \
diff --git a/doc/src/index-html.txt b/doc/src/index-html.txt
index dbb22d8..8281e91 100644
--- a/doc/src/index-html.txt
+++ b/doc/src/index-html.txt
@@ -6,11 +6,12 @@ OpenLMI Tools documentation
`OpenLMI Tools` is a part of `OpenLMI Project`_. It is a collection of
client-side utilities for interacting with OpenLMI Providers.
-It consists of LMIShell_ and `LMI metacommand`_.
+It consists of and `LMI metacommand`_ and LMIShell_.
+
+.. include:: metacommand-heading.txt
.. include:: shell-heading.txt
-.. include:: metacommand-heading.txt
Contents
--------
diff --git a/doc/src/index-other.txt b/doc/src/index-other.txt
index 7f73a68..4824ca6 100644
--- a/doc/src/index-other.txt
+++ b/doc/src/index-other.txt
@@ -6,7 +6,7 @@ OpenLMI Tools documentation
`OpenLMI Tools` is a part of `OpenLMI Project`_. It is a collection of
client-side utilities for interacting with OpenLMI Providers.
-It consists of :ref:`lmi_shell` and :ref:`lmi_metacommand`.
+It consists of :ref:`lmi_metacommand` and :ref:`lmi_shell`.
.. include:: toc.txt
diff --git a/doc/src/index-rtd.txt b/doc/src/index-rtd.txt
index cfd2bfa..0624f6c 100644
--- a/doc/src/index-rtd.txt
+++ b/doc/src/index-rtd.txt
@@ -6,7 +6,7 @@ OpenLMI client components
They consist of several client-side python utilities and libraries. We refer
to them as `OpenLMI Tools` and ship them under obvious name `openlmi-tools`.
-Currently they contain :ref:`lmi_shell` and :ref:`lmi_metacommand`.
+Currently they contain :ref:`lmi_metacommand` and :ref:`lmi_shell`.
.. include:: toc.txt
9 years, 6 months
[cura-tools] master: doc: Add link target to reference OpenLMI-scripts. (5d5416e)
by jsafrane@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 5d5416e928ccf2e62459ab7ca47f19d51f82d3f9
Author: Jan Safranek <jsafrane(a)redhat.com>
Date: Thu Oct 2 15:34:05 2014 +0200
doc: Add link target to reference OpenLMI-scripts.
>---------------------------------------------------------------
doc/src/genapi.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/doc/src/genapi.sh b/doc/src/genapi.sh
index f34ae9c..02e634a 100755
--- a/doc/src/genapi.sh
+++ b/doc/src/genapi.sh
@@ -80,6 +80,8 @@ Generated from version: $(get_version_string)
_EOF_
cat >$DOCDIR/api/scripts.rst <<_EOF_
+.. _openlmi-scripts-python:
+
LMI Scripts API reference
=========================
9 years, 6 months
[cura-tools] master: doc: rename the top-level heading for rtd build (206f677)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 206f67787c8c8e8fff865f3bdc324c9efeff7fb0
Author: Michal Minar <miminar(a)redhat.com>
Date: Thu Oct 2 14:44:45 2014 +0200
doc: rename the top-level heading for rtd build
*OpenLMI Tools* doesn't look good together with *OpenLMI server
components*. Let's give it similar and obvious name *OpenLMI client
components*.
This applies only to all-inclusive documentation hosted on
readthedocs.org.
>---------------------------------------------------------------
doc/README.md | 3 +++
doc/src/Makefile | 2 +-
doc/src/index-html.txt | 1 +
doc/src/index-other.txt | 1 +
doc/src/index-rtd.txt | 13 +++++++++++++
5 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/doc/README.md b/doc/README.md
index 3e98b88..72d612c 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -39,6 +39,9 @@ This build is the preferred one for Python Hosted site.
This build includes documentation of [OpenLMI Scripts][].
ln -sf path/to/local/copy/of/openlmi-scripts openlmi-scripts
+ pushd openlmi-scripts
+ make setup # make sure that setup scripts exist
+ popd
WITH_COMMANDS=1 make html
How to upload
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 69d6135..af9a8ee 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -52,7 +52,7 @@ index-%: subindexes-%
echo " api"; \
fi; \
) > toc.txt
- if [ "$*" == html ]; then \
+ if [[ "$*" =~ ^(html|rtd)$$ ]]; then \
ln -sf index-$*.txt index.rst; \
else \
ln -sf index-other.txt index.rst; \
diff --git a/doc/src/index-html.txt b/doc/src/index-html.txt
index 3b23e6f..dbb22d8 100644
--- a/doc/src/index-html.txt
+++ b/doc/src/index-html.txt
@@ -1,4 +1,5 @@
.. _openlmi-tools:
+.. _openlmi-client-components:
OpenLMI Tools documentation
===========================
diff --git a/doc/src/index-other.txt b/doc/src/index-other.txt
index 657ba45..7f73a68 100644
--- a/doc/src/index-other.txt
+++ b/doc/src/index-other.txt
@@ -1,4 +1,5 @@
.. _openlmi-tools:
+.. _openlmi-client-components:
OpenLMI Tools documentation
===========================
diff --git a/doc/src/index-rtd.txt b/doc/src/index-rtd.txt
new file mode 100644
index 0000000..cfd2bfa
--- /dev/null
+++ b/doc/src/index-rtd.txt
@@ -0,0 +1,13 @@
+.. _openlmi-tools:
+.. _openlmi-client-components:
+
+OpenLMI client components
+=========================
+They consist of several client-side python utilities and libraries. We refer
+to them as `OpenLMI Tools` and ship them under obvious name `openlmi-tools`.
+
+Currently they contain :ref:`lmi_shell` and :ref:`lmi_metacommand`.
+
+.. include:: toc.txt
+
+.. _OpenLMI Project: http://www.openlmi.org/
9 years, 6 months