[cura-tools] master: add missing LMIJob module (4e49ca1)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 4e49ca1dc39421d976e329c010258dc29ec4be0c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 08:49:33 2013 +0200
add missing LMIJob module
>---------------------------------------------------------------
cli/lmi/shell/LMIJob.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 94 insertions(+), 0 deletions(-)
diff --git a/cli/lmi/shell/LMIJob.py b/cli/lmi/shell/LMIJob.py
new file mode 100644
index 0000000..c89cc58
--- /dev/null
+++ b/cli/lmi/shell/LMIJob.py
@@ -0,0 +1,94 @@
+# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+import pywbem
+from LMIObjectFactory import LMIObjectFactory
+
+# NOTE: the enumeration comes from DMTF standard.
+JOB_STATE_COMPLETED, \
+JOB_STATE_TERMINATED, \
+JOB_STATE_KILLED, \
+JOB_STATE_EXCEPTION = range(7, 11)
+
+# Job finish states -- used in LMIMethod.__handle_synchro_method_call_indication()
+# JOB_FINISH_DELAYED -- a job has completed its action later,
+# an indication or polling method was used
+# JOB_FINISHED_EARLY -- no waiting method was used
+JOB_NOT_FINISHED, \
+JOB_FINISH_DELAYED, \
+JOB_FINISH_EARLY = range(3)
+
+def _lmi_get_job_state(job):
+ """
+ Helper function, which returns a numeric Job state value.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ if isinstance(job, LMIObjectFactory().LMIInstance):
+ return job.JobState
+ elif isinstance(job, pywbem.CIMInstance):
+ return job["JobState"]
+ raise TypeError("'job' object needs to be instance of either LMIInstance or CIMInstance")
+
+def lmi_is_job_finished(job):
+ """
+ Helper function, which returns bool flag, if the job is in finished state.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ return _lmi_get_job_state(job) in ( \
+ JOB_STATE_COMPLETED, \
+ JOB_STATE_TERMINATED, \
+ JOB_STATE_KILLED, \
+ JOB_STATE_EXCEPTION
+ )
+
+def lmi_is_job_completed(job):
+ """
+ Helper function, which returns bool flag, if the job is in completed state.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ return _lmi_get_job_state(job) == JOB_STATE_COMPLETED
+
+def lmi_is_job_terminated(job):
+ """
+ Helper function, which returns bool flag, if the job is in terminated state.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ return _lmi_get_job_state(job) == JOB_STATE_TERMINATED
+
+def lmi_is_job_killed(job):
+ """
+ Helper function, which returns bool flag, if the job is killed.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ return _lmi_get_job_state(job) == JOB_STATE_KILLED
+
+def lmi_is_job_exception(job):
+ """
+ Helper function, which returns bool flag, if the job is in the exception state.
+
+ Arguments:
+ job -- LMIInstance or CIMInstance representing a job
+ """
+ return _lmi_get_job_state(job) == JOB_STATE_EXCEPTION
10 years, 9 months
[cura-tools] master: code cleanup, rename valuemap list (6f950b0)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 6f950b095d6e76a73fde5d512db0029f686ce5bf
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Aug 5 15:08:06 2013 +0200
code cleanup, rename valuemap list
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 614ded4..7760706 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -97,11 +97,11 @@ class LMIMethod(LMIBaseObject):
self._method = lmi_instance._lmi_class._cim_class.methods[method]
self._sync_method = sync_method
# Store the constant values as a list. This can consume some time, if computed on demand.
- self._valuemap_parameters = [k for (k, v) in self._method.parameters.iteritems() \
+ self._valuemap_parameters_list = [k for (k, v) in self._method.parameters.iteritems() \
if "ValueMap" in v.qualifiers]
# For simplicity, we add return value constans to the same list
if "ValueMap" in self._method.qualifiers:
- self._valuemap_parameters.append(self._method.name)
+ self._valuemap_parameters_list.append(self._method.name)
def __return_synchro_method_call(self, job_inst, job_refresh=True):
"""
@@ -483,13 +483,13 @@ class LMIMethod(LMIBaseObject):
"""
Returns a list of strings of the constant names.
"""
- return self._valuemap_parameters
+ return self._valuemap_parameters_list
def print_valuemap_parameters(self):
"""
Prints out the list of strings of constant names.
"""
- for i in self._valuemap_parameters:
+ for i in self._valuemap_parameters_list:
sys.stdout.write("%s\n" % i)
def parameters(self):
10 years, 9 months
[cura-tools] master: introduce LMIMethod::print_valuemap_parameters() (14a1a24)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 14a1a24412c62f1fa0faea3b4db9c1bf2c136b8d
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Aug 5 15:05:56 2013 +0200
introduce LMIMethod::print_valuemap_parameters()
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 9a93c92..614ded4 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -485,6 +485,13 @@ class LMIMethod(LMIBaseObject):
"""
return self._valuemap_parameters
+ def print_valuemap_parameters(self):
+ """
+ Prints out the list of strings of constant names.
+ """
+ for i in self._valuemap_parameters:
+ sys.stdout.write("%s\n" % i)
+
def parameters(self):
"""
Returns a list of strings of CIMMethod's parameters.
10 years, 9 months
[cura-tools] master: introduce reversed constant values (88b2311)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 88b2311c9eba4b234c5b7a3ad2bfbc00b8a50a41
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Aug 5 14:07:57 2013 +0200
introduce reversed constant values
>---------------------------------------------------------------
cli/lmi/shell/LMIConstantValues.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIConstantValues.py b/cli/lmi/shell/LMIConstantValues.py
index 79449e4..6e564ac 100644
--- a/cli/lmi/shell/LMIConstantValues.py
+++ b/cli/lmi/shell/LMIConstantValues.py
@@ -41,9 +41,14 @@ class LMIConstantValues(LMIBaseObject):
cim_obj.qualifiers["Values"].value)
values = cim_obj.qualifiers["ValueMap"].value
self._value_map = {}
+ self._value_map_inv = {}
+ # Fill two dictionaries for bidirectional access to constant values.
for i in range(0, len(keys)):
try:
- self._value_map[keys[i]] = lmi_cast_to_cim(self._cast_type, values[i])
+ key = keys[i]
+ val = lmi_cast_to_cim(self._cast_type, values[i])
+ self._value_map[key] = val
+ self._value_map_inv[val] = key
except ValueError, e:
# Can not cast such value as interval. Can be found in
# DMTFReserved, VendorReserved values.
@@ -102,6 +107,15 @@ class LMIConstantValues(LMIBaseObject):
"""
return getattr(self, value_name)
+ def value_name(self, value):
+ """
+ Returns string representing constant value.
+
+ Arguments:
+ value -- numeric constant value
+ """
+ return self._value_map_inv[value]
+
class LMIConstantValuesParamProp(LMIConstantValues):
"""
Derived class used for constant values of CIMProperty and CIMParameter.
10 years, 9 months
[cura-tools] master: fix synchro method calls' return values (10b90c3)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 10b90c3185a32d4e10cc105bd579b29b778b0dc7
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Aug 5 10:09:07 2013 +0200
fix synchro method calls' return values
>---------------------------------------------------------------
cli/lmi/shell/LMIMethod.py | 98 ++++++++++++++++++++++++++++----------------
1 files changed, 63 insertions(+), 35 deletions(-)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 6b60462..9a93c92 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -29,10 +29,20 @@ from LMIConstantValues import LMIConstantValuesParamProp
from LMIConstantValues import LMIConstantValuesMethodReturnType
from LMIIndicationListener import LMIIndicationListener
+from LMIJob import lmi_is_job_finished
+from LMIJob import lmi_is_job_completed
+from LMIJob import lmi_is_job_terminated
+from LMIJob import lmi_is_job_killed
+from LMIJob import lmi_is_job_exception
+from LMIJob import JOB_NOT_FINISHED
+from LMIJob import JOB_FINISH_DELAYED
+from LMIJob import JOB_FINISH_EARLY
+
from LMIUtil import LMIPassByRef
from LMIUtil import lmi_raise_or_dump_exception
from LMIUtil import lmi_cast_to_cim
from LMIUtil import lmi_transform_to_lmi
+from LMIUtil import lmi_get_item_or_default
from LMIExceptions import LMIIndicationListenerError
from LMIExceptions import LMIMethodCallError
@@ -93,16 +103,40 @@ class LMIMethod(LMIBaseObject):
if "ValueMap" in self._method.qualifiers:
self._valuemap_parameters.append(self._method.name)
- @staticmethod
- def _is_job_finished(job):
+ def __return_synchro_method_call(self, job_inst, job_refresh=True):
"""
- Checks if a job object is in finished state. The range comes from the standard.
- Returns True, if the job is in the finished state.
+ Returns a LMIReturnValue with Job output parameters set.
Arguments:
- job -- LMIInstance
+ job_inst -- LMIInstance object of the job returned from a synchronous
+ method call
+ job_refresh -- bool flag, which indicates, if the job_inst
+ needs to be refreshed
"""
- return job.JobState in range(7, 11)
+ # Adjust return value from the job object
+ if job_refresh:
+ job_inst.refresh()
+ rparams = dict(zip(job_inst.JobOutParameters.properties.keys(),
+ [x.value for x in job_inst.JobOutParameters.properties.values()]))
+ rval = rparams.pop("__ReturnValue")
+ errorstr = ""
+
+ # Is job in exception state? If so, adjust corresponding error string
+ # from job.GetError() instance
+ if lmi_is_job_exception(job_inst):
+ (refreshed, _, errorstr) = job_inst.refresh()
+ if not refreshed:
+ raise LMISynchroMethodCallError(errorstr)
+ (exc_rval, exc_rparams, exc_errorstr) = job_inst.GetError()
+ error_inst = lmi_get_item_or_default(exc_rparams, "error", None)
+ if not error_inst:
+ raise LMISynchroMethodCallError("Could not get Job error message")
+ errorstr = error_inst.Message
+ return LMIReturnValue(
+ rval=rval,
+ rparams=rparams,
+ errorstr=errorstr
+ )
def __handle_synchro_method_call_indication(self, job_inst):
"""
@@ -123,29 +157,28 @@ class LMIMethod(LMIBaseObject):
job_inst -- LMIInstance object of the job returned from a synchronous
method call
"""
- def handle_job(ind, cond, cond_variable, job_out_params, job_exception):
+ def handle_job(ind, cond, job_finished, job_exception):
"""
LMIListener handler for synchronous method call, which uses indication means
of waiting for the job. This function is called, when a job changes its state.
Arguments:
cond -- threading.Condition object used for thread synchronization
- cond_variable -- LMIPassByRef object used for indication, whether the
+ job_finished -- LMIPassByRef object used for indication, whether the
job has finished
- job_out_params -- job output parameters (passed by ref)
- job_exception -- exception object, if any (passed by ref)
+ job_exception -- LMIPassByRef object, which contains an exception object,
+ if any exception was raised
"""
cond.acquire()
try:
exp_obj = ind.exported_objects()[0]
src_inst = exp_obj["SourceInstance"]
- if src_inst["JobState"] in (7, 8, 9, 10):
- job_out_params.value = src_inst["JobOutParameters"]
+ if lmi_is_job_finished(src_inst):
# Job has just finished
- cond_variable.value = True
+ job_finished.value = JOB_FINISH_DELAYED
except Exception, e:
# Notify main thread, we are not able to work with such objects
- cond_variable.value = True
+ job_finished.value = JOB_FINISH_DELAYED
job_exception.value = e
finally:
# XXX: Let's be defensive, always notify+release main thread
@@ -154,14 +187,13 @@ class LMIMethod(LMIBaseObject):
# Start indication listener
cond = threading.Condition()
- job_finished = LMIPassByRef(False)
- job_out_params = LMIPassByRef(None)
+ job_finished = LMIPassByRef(JOB_NOT_FINISHED)
job_exception = LMIPassByRef(None)
# There needs to be a pattern of at least 8 "X" in a row at the end of the indication_name
indication_name = "synchro-method-call-XXXXXXXX"
listener = LMIIndicationListener("0.0.0.0", LMIMethod._INDICATION_DESTINATION_PORT)
indication_name = listener.add_handler(indication_name, handle_job, cond, job_finished,
- job_out_params, job_exception)
+ job_exception)
if not listener.start():
raise LMIIndicationListenerError("Can not start indication listener")
@@ -223,9 +255,8 @@ class LMIMethod(LMIBaseObject):
# Check, if the job is not already in finished state,
# while we were subscribing for the indications
job_inst.refresh()
- job_finished.value = LMIMethod._is_job_finished(job_inst)
- if job_finished.value:
- job_out_params.value = job_inst.JobOutParameters
+ if lmi_is_job_finished(job_inst):
+ job_finished.value = JOB_FINISH_EARLY
# Wait for the job to finish
interrupt = False
@@ -251,8 +282,7 @@ class LMIMethod(LMIBaseObject):
if not refreshed:
job_exception.value = LMISynchroMethodCallError(errorstr)
break
- if LMIMethod._is_job_finished(job_inst):
- job_out_params.value = job_inst.JobOutParameters
+ if lmi_is_job_finished(job_inst):
listener.stop()
break
except KeyboardInterrupt:
@@ -266,11 +296,10 @@ class LMIMethod(LMIBaseObject):
self._client._delete_instance(cim_handler.path)
if job_exception.value:
raise job_exception.value
- # TODO: adjust return value from the job object
- return LMIReturnValue(
- rval=0,
- rparams={"out" : job_out_params.value}
- )
+
+ # Return the job return values, refresh the job_inst object, if we got notified
+ # about the job finish state by indication.
+ return self.__return_synchro_method_call(job_inst, job_finished.value == JOB_FINISH_DELAYED)
def __handle_synchro_method_call_polling(self, job_inst):
"""
@@ -287,7 +316,7 @@ class LMIMethod(LMIBaseObject):
"""
try:
sleep_time = 1
- while not LMIMethod._is_job_finished(job_inst):
+ while not lmi_is_job_finished(job_inst):
# Sleep, a bit longer in every iteration
time.sleep(sleep_time)
if sleep_time < LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME:
@@ -297,11 +326,10 @@ class LMIMethod(LMIBaseObject):
raise LMISynchroMethodCallError(errorstr)
except pywbem.cim_operations.CIMError, e:
raise LMISynchroMethodCallError(e.message)
- # TODO: adjust return value from the job object
- return LMIReturnValue(
- rval=0,
- rparams={"out" : job_inst.JobOutParameters}
- )
+
+ # Return the job return values. No need to refresh the job instance, we already
+ # have a "fresh" one.
+ return self.__return_synchro_method_call(job_inst, False)
def __call__(self, *args, **kwargs):
"""
@@ -365,7 +393,7 @@ class LMIMethod(LMIBaseObject):
handled_by_indication = False
if not synchro_method_polling:
try:
- (rval, call_rparams, _) = self.__handle_synchro_method_call_indication(job_inst)
+ (rval, call_rparams, call_errorstr) = self.__handle_synchro_method_call_indication(job_inst)
handled_by_indication = True
except pywbem.CIMError, e:
lmi_raise_or_dump_exception(e)
@@ -393,7 +421,7 @@ class LMIMethod(LMIBaseObject):
if not handled_by_indication:
# Executed, when LMIListener can not be started
try:
- (rval, call_rparams, _) = self.__handle_synchro_method_call_polling(job_inst)
+ (rval, call_rparams, call_errorstr) = self.__handle_synchro_method_call_polling(job_inst)
except LMISynchroMethodCallError, e:
lmi_raise_or_dump_exception(e)
return LMIReturnValue(
10 years, 9 months
[cura-tools] master: update man page (657dab1)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 657dab142a2f3ad2e3037f053304a7369d8bcddd
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Aug 2 15:56:37 2013 +0200
update man page
>---------------------------------------------------------------
man/lmishell.1 | 129 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 104 insertions(+), 25 deletions(-)
diff --git a/man/lmishell.1 b/man/lmishell.1
index 3f83e7a..4eb5502 100644
--- a/man/lmishell.1
+++ b/man/lmishell.1
@@ -37,7 +37,6 @@ Do not print any log messages to stderr.
By default, LMIShell prints out log messages with Error severity. Options
\fB\-v\fR, \fB\-m\fR and \fB\-q\fR are mutually exclusive and
can not be used together.
-
.SH HOW TO USE THE SHELL
The following text covers basic use-cases.
@@ -77,10 +76,9 @@ LMIShell can connect directly to the CIMOM using unix socket. For this type of
connection, the shell needs to be run under root user and the destination
machine has to be either "localhost", "127.0.0.1" or "::1". This type of
connection is supported by Tog-Pegasus and there needs to be a unix socket
-file present at /var/run/tog-pegasus/cimxml.socket. If the condition is not
+file present at `/var/run/tog-pegasus/cimxml.socket`. If the condition is not
met, classic username/password method will be used. See following example:
- # lmishell
> c = connect("localhost")
>
.TP 4
@@ -90,10 +88,12 @@ are OK, otherwise `None` is returned:
> # correct username or password
> c = connect("host", "username", "password"}
- > type(c) == lmi.lmi_client_shell.LmiConnection
- > # bad login username or password
- > c = connect("host", "bad_username", "bad_password")
- > type(c) == None
+ > isinstance(c, LMIConnection)
+ True
+ > # wrong login username or password
+ > c = connect("host", "wrong_username", "wrong_password")
+ > c is None
+ True
>
.SH NAMESPACES
Namespaces in CIM and LMIShell provide a natural way, how to organize all
@@ -260,12 +260,14 @@ To get a list of methods, run following:
> instance.print_methods()
...
- > method_lst = sshd.methods()
+ > method_lst = instance.methods()
>
To execute a method within an object, run this:
- > instance.Method(Param1=value1, Param2=value2, ...)
+ > instance.Method(
+ ... Param1=value1,
+ ... Param2=value2, ...)
https://host: ok (0)
>
@@ -276,7 +278,9 @@ includes a return value in the parenthesis).
To get the result from a method call, see following:
- > (rval, rparams, errorstr) = instance.Method(Param1=value1, Param2=value2, ...)
+ > (rval, rparams, errorstr) = instance.Method(
+ ... Param1=value1,
+ ... Param2=value2, ...)
>
The tuple in the previous example will contain retun value of the method call
@@ -298,8 +302,9 @@ fails, 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, ...)
- ...
+ > (rval, rparams, errorstr) = instance.SyncMethod(
+ ... Param1=value1,
+ ... Param2=value2, ...)
>
\fBNOTE:\fR See the prefix `Sync` in front of a `Method` name.
@@ -396,34 +401,108 @@ be converted into the instance, see next example:
> instance = instance_name.to_instance()
>
.SH ASSOCIATED OBJECTS
-In CIMOM broker, there is a association relationship defined, in case, you
-want to get list of associated objects with a given object, run following:
+CIM defines an association relationship between managed objects. Following
+text describes the means of retrieving associated objects within a given one.
+.SS ASSOCIATED INSTANCES
+To get list of associated objects with a given object, run following:
+
+ > associated_objects = instance.associators(
+ ... AssocClass=cls,
+ ... ResultClass=cls,
+ ... ResultRole=role,
+ ... IncludeQualifiers=include_qualifiers,
+ ... IncludeClassOrigin=include_class_origin,
+ ... PropertyList=property_lst)
+ > first_associated_object = instance.first_associator(
+ ... AssocClass=cls,
+ ... ResultClass=cls,
+ ... ResultRole=role,
+ ... IncludeQualifiers=include_qualifiers,
+ ... IncludeClassOrigin=include_class_origin,
+ ... PropertyList=property_lst))
+ >
+
+The list of returned associated objects can be filtered by:
+
+ * `AssocClass` -- Each returned object shall be associated to the source object through an instance of this class or one of its subclasses. Default value is None.
+ * `ResultClass` -- Each returned object shall be either an instance of this class (or one of its subclasses) or be this class (or one of its subclasses). Default value is None.
+ * `Role` -- Each returned object shall be associated with the source object through an association in which the source object plays the specified role. That is, the name of the property in the association class that refers to the source object shall match the value of this parameter. Default value is None.
+ * `ResultRole` -- Each returned object shall be associated to the source object through an association in which the returned object plays the specified role. That is, the name of the property in the association class that refers to the returned object shall match the value of this parameter. Default value is None.
+
+Other parameters reffer to:
+
+ * `IncludeQualifiers` -- Bool flag indicating, if all qualifiers for each object (including qualifiers on the object and on any returned properties) shall be included as <QUALIFIER> elements in the response. Default value is False.
+ * `IncludeClassOrigin` -- Bool flag indicating, if the CLASSORIGIN attribute shall be present on all appropriate elements in each returned object. Default value is False.
+ * `PropertyList` -- The members of the array define one or more property names. Each returned object shall not include elements for any properties missing from this list. If PropertyList? is an empty list, no properties are included in each returned object. If it is None, no additional filtering is defined. Default value is None.
+.SS ASSOCIATED INSTANCE NAMES
+You can also get AssociatorNames:
- > associated_objects = instance.associators()
- > first_associated_object = instance.first_associator()
+ > associated_object_names = instance.associator_names(
+ ... AssocClass=cls,
+ ... ResultClass=cls,
+ ... Role=role,
+ ... ResultRole=result_role)
+ > first_associated_object_name = instance.first_associator_name(
+ ... AssocClass=cls,
+ ... ResultClass=cls,
+ ... Role=role,
+ ... ResultRole=result_role)
>
-You can also get AssociatorNames:
+The list of returned associated instance names can be filtered by:
- > associated_object_names = instance.associator_names()
- > first_associated_object_name = instance.first_associator_name()
- >
+ * `AssocClass` -- Each returned name identify an object that shall be associated to the source object through an instance of this class or one of its subclasses. Default value is None.
+ * `ResultClass` -- Each returned name identify an object that shall be either an instance of this class (or one of its subclasses) or be this class (or one of its subclasses). Default value is None.
+ * `Role` -- Each returned name identify an object that shall be associated to the source object through an association in which the source object plays the specified role. That is, the name of the property in the association class that refers to the source object shall match the value of this parameter. Default value is None.
+ * `ResultRole` -- Each returned name identify an object that shall be associated to the source object through an association in which the named returned object plays the specified role. That is, the name of the property in the association class that refers to the returned object shall match the value of this parameter. Default value is None.
.SH ASSOCIATION OBJECTS
+CIM defines an association relationship between managed objects. Following
+text describes the means of retrieving association objects within a given one.
An association object is the object, which defines the relationship between
two other objects.
-
+.SS ASSOCIATION INSTANCES
To get association objects that refer to a particular target object, run
following:
- > association_objects = instance.references()
- > first_association_object = instance.first_reference()
+ > association_objects = instance.references(
+ ... ResultClass=cls,
+ ... Role=role,
+ ... IncludeQualifiers=include_qualifiers,
+ ... IncludeClassOrigin=include_class_origin,
+ ... PropertyList=property_lst)
+ > first_association_object = instance.first_reference(
+ ... ResultClass=cls,
+ ... Role=role,
+ ... IncludeQualifiers=include_qualifiers,
+ ... IncludeClassOrigin=include_class_origin,
+ ... PropertyList=property_lst)
>
+The list of returned association objects can be filtered by:
+
+ * `ResultClass` -- Each returned object shall be an instance of this class (or one of its subclasses) or this class (or one of its subclasses). Default value is None.
+ * `Role` -- Each returned object shall refer to the target object through a property with a name that matches the value of this parameter. Default value is None.
+
+Other parameters reffer to:
+
+ * `IncludeQualifiers` -- Each object (including qualifiers on the object and on any returned properties) shall be included as <QUALIFIER> elements in the response. Default value is False.
+ * `IncludeClassOrigin` -- Flag indicating, if the CLASSORIGIN attribute shall be present on all appropriate elements in each returned object. Default value is False.
+ * `PropertyList` -- The members of the list define one or more property names. Each returned object shall not include elements for any properties missing from this list. If PropertyList? is an empty list, no properties are included in each returned object. If PropertyList? is None, no additional filtering is defined. Default value is None.
+.SS ASSOCIATION INSTANCE NAMES
To get association instance names, run following:
- > association_object_names = instance.reference_names()
- > first_association_object_name = instance.first_reference_name()
+ > association_object_names = instance.reference_names(
+ ... ResultClass=cls,
+ ... Role=role)
+ > first_association_object_name = instance.first_reference_name(
+ ... ResultClass=cls,
+ ... Role=role)
>
+
+The list of returned association instance names can be filtered by:
+
+ * `ResultClass` -- Each returned Object Name identify an instance of this class (or one of its subclasses) or this class (or one of its subclasses). Default value is None.
+ * `Role` -- Each returned object name shall identify an object that refers to the target instance through a property with a name that matches the value of this parameter. Default value is None.
.SH INDICATIONS
Indication is a reaction to some specific event that occurs in response to a
change to a particular change in data. LMIShell can perform a indication
10 years, 9 months
[cura-tools] master: fix remove blank line after man page header (2644490)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 2644490c69ef130b96ab16962e4c2baf097eb695
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Aug 2 15:41:43 2013 +0200
fix remove blank line after man page header
>---------------------------------------------------------------
util/man-page-generator/generate-man-page | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/util/man-page-generator/generate-man-page b/util/man-page-generator/generate-man-page
index 043af64..96f300c 100755
--- a/util/man-page-generator/generate-man-page
+++ b/util/man-page-generator/generate-man-page
@@ -91,8 +91,7 @@ Do not print any log messages to stderr.
.P
By default, LMIShell prints out log messages with Error severity. Options
\\fB\\-v\\fR, \\fB\\-m\\fR and \\fB\\-q\\fR are mutually exclusive and
-can not be used together.
-"""
+can not be used together."""
# The man page static footer containing Authors section.
man_page_footer = \
""".SH "AUTHORS"
10 years, 9 months
[cura-tools] master: fix default values in doc strings in LMIInstance::associators(), ::first_associatr(), ::references(), ::first_reference() (027a086)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 027a086f91163cff4294ea199e1a71b7eb02ed85
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Aug 2 15:16:57 2013 +0200
fix default values in doc strings in LMIInstance::associators(), ::first_associatr(), ::references(), ::first_reference()
>---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index 80218dd..364f129 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -182,23 +182,23 @@ class LMIInstance(LMIBaseObject):
AssocClass -- valid CIM association class name. It acts as a filter on the
returned set of names by mandating that each returned name identify an object
that shall be associated to the source object through an instance of this
- class or one of its subclasses.
+ class or one of its subclasses. Default value is None.
ResultClass -- valid CIM class name. It acts as a filter on the returned set
of names by mandating that each returned name identify an object that shall be
either an instance of this class (or one of its subclasses) or be this class
- (or one of its subclasses).
+ (or one of its subclasses). Default value is None.
Role -- valid property name. It acts as a filter on the returned set of names
by mandating that each returned name identify an object that shall be
associated to the source object through an association in which the source
object plays the specified role. That is, the name of the property in the
association class that refers to the source object shall match the value of
- this parameter.
+ this parameter. Default value is None.
ResultRole -- valid property name. It acts as a filter on the returned set of
names by mandating that each returned name identify an object that shall be
associated to the source object through an association in which the named
returned object plays the specified role. That is, the name of the property
in the association class that refers to the returned object shall match the
- value of this parameter.
+ value of this parameter. Default value is None.
"""
assoc_names_list = self._client._get_associator_names(self._cim_instance, **kwargs)
return map(lambda assoc_name: lmi_wrap_cim_instance_name(self._client, assoc_name), assoc_names_list)
@@ -215,23 +215,23 @@ class LMIInstance(LMIBaseObject):
AssocClass -- valid CIM association class name. It acts as a filter on the
returned set of names by mandating that each returned name identify an object
that shall be associated to the source object through an instance of this
- class or one of its subclasses.
+ class or one of its subclasses. Default value is None.
ResultClass -- valid CIM class name. It acts as a filter on the returned set
of names by mandating that each returned name identify an object that shall be
either an instance of this class (or one of its subclasses) or be this class
- (or one of its subclasses).
+ (or one of its subclasses). Default value is None.
Role -- valid property name. It acts as a filter on the returned set of names
by mandating that each returned name identify an object that shall be
associated to the source object through an association in which the source
object plays the specified role. That is, the name of the property in the
association class that refers to the source object shall match the value of
- this parameter.
+ this parameter. Default value is None.
ResultRole -- valid property name. It acts as a filter on the returned set of
names by mandating that each returned name identify an object that shall be
associated to the source object through an association in which the named
returned object plays the specified role. That is, the name of the property
in the association class that refers to the returned object shall match the
- value of this parameter.
+ value of this parameter. Default value is None.
"""
result = self.associator_names(**kwargs)
if not result:
@@ -345,11 +345,11 @@ class LMIInstance(LMIBaseObject):
ResultClass -- valid CIM class name. It acts as a filter on the returned set
of object names by mandating that each returned Object Name identify an
instance of this class (or one of its subclasses) or this class (or one of its
- subclasses).
+ subclasses). Default value is None.
Role -- valid property name. It acts as a filter on the returned set of object
names by mandating that each returned object name shall identify an object
that refers to the target instance through a property with a name that matches
- the value of this parameter.
+ the value of this parameter. Default value is None.
"""
reference_names_list = self._client._get_reference_names(self._cim_instance, **kwargs)
return map(lambda ref_name: lmi_wrap_cim_instance_name(self._client, ref_name), reference_names_list)
@@ -366,11 +366,11 @@ class LMIInstance(LMIBaseObject):
ResultClass -- valid CIM class name. It acts as a filter on the returned set
of object names by mandating that each returned Object Name identify an
instance of this class (or one of its subclasses) or this class (or one of its
- subclasses).
+ subclasses). Default value is None.
Role -- valid property name. It acts as a filter on the returned set of object
names by mandating that each returned object name shall identify an object
that refers to the target instance through a property with a name that matches
- the value of this parameter.
+ the value of this parameter. Default value is None.
"""
result = self.reference_names(**kwargs)
if not result:
@@ -423,15 +423,22 @@ class LMIInstance(LMIBaseObject):
ResultClass -- valid CIM class name. It acts as a filter on the returned set
of objects by mandating that each returned object shall be an instance of this
class (or one of its subclasses) or this class (or one of its subclasses).
+ Default value is None.
Role -- valid property name. It acts as a filter on the returned set of
objects by mandating that each returned object shall refer to the target
object through a property with a name that matches the value of this
- parameter.
+ parameter. Default value is None.
+ IncludeQualifiers -- bool flag indicating, if all qualifiers for each object
+ (including qualifiers on the object and on any returned properties) shall be
+ included as <QUALIFIER> elements in the response. Default value is False.
+ IncludeClassOrigin -- bool flag indicating, if the CLASSORIGIN attribute shall
+ be present on all appropriate elements in each returned object. Default
+ value is False.
PropertyList -- if not None, the members of the list define one or more property
names. Each returned object shall not include elements for any properties
missing from this list. If PropertyList is an empty list, no properties
are included in each returned object. If PropertyList is None, no
- additional filtering is defined.
+ additional filtering is defined. Default value is None.
"""
result = self.references(**kwargs)
if not result:
10 years, 9 months
[cura-tools] master: fix connect() does not ask for username and password in noninteractive mode (a56dcb8)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit a56dcb887a5484287b8709f3a497047fd610d180
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Aug 2 12:21:30 2013 +0200
fix connect() does not ask for username and password in noninteractive mode
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 31e4513..43666d0 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -89,14 +89,15 @@ def connect(hostname, username="", password="", interactive=False, use_cache=Tru
if not connection.verify_credentials():
connection = None
if connection is None:
- try:
- if not username:
- username = __lmi_raw_input("username: ", True)
- if not password:
- password = __lmi_raw_input("password: ", False)
- except KeyboardInterrupt, e:
- sys.stdout.write("\n")
- return None
+ if interactive:
+ try:
+ if not username:
+ username = __lmi_raw_input("username: ", True)
+ if not password:
+ password = __lmi_raw_input("password: ", False)
+ except KeyboardInterrupt, e:
+ sys.stdout.write("\n")
+ return None
connection = LMIConnection(hostname, username, password, interactive,
use_cache, LMIBaseClient.CONN_TYPE_WBEM)
if not connection.verify_credentials():
10 years, 9 months
[cura-tools] master: fix doc strings for (non)interactive connect (70441c7)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 70441c7512def4f6661983d671b0f22b9a889a8c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Aug 2 12:18:16 2013 +0200
fix doc strings for (non)interactive connect
>---------------------------------------------------------------
cli/lmi/shell/LMIConsole.py | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index cb9f1cd..37058da 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -33,7 +33,7 @@ from LMIShellConfig import LMIShellConfig
from LMIReturnValue import LMIReturnValue
from LMIObjectFactory import LMIObjectFactory
-from LMIConnection import connect
+from LMIConnection import connect as connect_internal
from LMIUtil import lmi_set_use_exceptions
from LMIUtil import lmi_get_use_exceptions
@@ -133,6 +133,17 @@ class LMIConsole(code.InteractiveConsole):
Arguments:
locals -- dictionary with locals
"""
+ def connect(hostname, username="", password=""):
+ """
+ Returns LMIConnection object with provided hostname and credentials.
+
+ Arguments:
+ hostname -- uri of the CIMOM
+ username -- account, under which, the CIM calls will be performed
+ password -- user's password
+ """
+ return connect_internal(hostname, username, password, True, self._use_cache)
+
# Initialize the interpreter
if locals is None:
locals = {}
@@ -142,7 +153,7 @@ class LMIConsole(code.InteractiveConsole):
locals[k]._client.interactive = True
locals["clear_history"] = self.clear_history
locals["use_display_sugar"] = _use_display_sugar
- locals["connect"] = lambda h, u="", p="": connect(h, u, p, True, self._use_cache)
+ locals["connect"] = connect
self.locals = dict(self.locals.items() + locals.items())
self.setup_completer()
self.load_history()
@@ -199,6 +210,17 @@ class LMIConsole(code.InteractiveConsole):
script_argv -- script CLI arguments
locals -- dictionary with locals
"""
+ # Helper function for non-interactive connect
+ def connect(hostname, username="", password=""):
+ """
+ Returns LMIConnection object with provided hostname and credentials.
+
+ Arguments:
+ hostname -- uri of the CIMOM
+ username -- account, under which, the CIM calls will be performed
+ password -- user's password
+ """
+ return connect_internal(hostname, username, password, False, self._use_cache)
# Initialize locals
if locals is None:
locals = {}
@@ -206,7 +228,7 @@ class LMIConsole(code.InteractiveConsole):
for (k, v) in locals.iteritems():
if isinstance(v, LMIConnection):
locals[k]._client.interactive = False
- locals["connect"] = lambda h, u="", p="": connect(h, u, p, False, self._use_cache)
+ locals["connect"] = connect
self.locals = dict(self.locals.items() + locals.items())
# Execute the script
10 years, 9 months