Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 7340573b21fe92e11fedbeba818e327650b595ea
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 11:19:45 2013 +0200
code cleanup, update doc strings for LMIInstance methods
---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 152 +++++++++++++++++++++++++++++++++++-------
1 files changed, 127 insertions(+), 25 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index e52d0b4..af83f64 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -59,7 +59,11 @@ class LMIInstance(LMIBaseObject):
property.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
name -- string containing the class member, the method name, or the property
@@ -86,7 +90,11 @@ class LMIInstance(LMIBaseObject):
Modifies a CIMInstance property.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
name -- string containing a name of the CIMInstance's member
@@ -104,7 +112,11 @@ class LMIInstance(LMIBaseObject):
Returns a pretty string for the object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return "%s(classname='%s', ...)" % (self.__class__.__name__,
self.classname)
@@ -115,7 +127,11 @@ class LMIInstance(LMIBaseObject):
Property returning a string of a class name.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.classname
@@ -126,7 +142,11 @@ class LMIInstance(LMIBaseObject):
Property retuning a string of a namespace name.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.namespace
@@ -137,7 +157,11 @@ class LMIInstance(LMIBaseObject):
Property returning a string of a CIMInstance path.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._cim_instance.path
@@ -151,7 +175,11 @@ class LMIInstance(LMIBaseObject):
as a fallback.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
LMIXmlFormatter(self._cim_instance.tocimxml()).fancy_format(self._client.interactive)
@@ -165,7 +193,11 @@ class LMIInstance(LMIBaseObject):
as a fallback.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
LMIMofFormatter(self._cim_instance.tomof()).fancy_format(self._client.interactive)
@@ -176,7 +208,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of associated LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -209,7 +245,11 @@ class LMIInstance(LMIBaseObject):
Returns the first associated LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -245,7 +285,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of associated LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -291,7 +335,11 @@ class LMIInstance(LMIBaseObject):
Returns the first associated LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -339,7 +387,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of association LMIInstanceName objects with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -360,7 +412,11 @@ class LMIInstance(LMIBaseObject):
Returns the first association LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keywords Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -384,7 +440,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of association LMIInstance objects with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -417,7 +477,11 @@ class LMIInstance(LMIBaseObject):
Returns the first association LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -452,7 +516,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of CIMInstance properties.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._cim_instance.properties.keys()
@@ -463,7 +531,11 @@ class LMIInstance(LMIBaseObject):
Prints out the list of CIMInstance properties.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
for (name, prop) in self._cim_instance.properties.iteritems():
sys.stdout.write("%s\n" % name)
@@ -476,7 +548,11 @@ class LMIInstance(LMIBaseObject):
This method may consume significant memory amount when called.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty dictionary. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return dict(zip(self._cim_instance.properties.keys(),
map(lambda x: x.value, self._cim_instance.properties.values())))
@@ -487,7 +563,11 @@ class LMIInstance(LMIBaseObject):
Returns a CIMInstance property value.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
prop_name -- string containing the CIMInstance property name
@@ -500,7 +580,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of CIMInstance methods' names.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.methods()
@@ -510,7 +594,11 @@ class LMIInstance(LMIBaseObject):
Prints out the list of CIMInstance methods' names.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
self._lmi_class.print_methods()
@@ -528,7 +616,12 @@ class LMIInstance(LMIBaseObject):
was refreshed; otherwise rval is set to False.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return LMIReturnValue containing False as a return value with
+ proper error string set. If the shell uses exceptions, LMIDeletedObjectError
will
+ be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
(new_cim_instance, _, errorstr) = self._client._get_instance(self.path,
LocalOnly=False)
if not new_cim_instance:
@@ -550,7 +643,12 @@ class LMIInstance(LMIBaseObject):
is set to -1.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return LMIReturnValue containing False as a return value with
+ proper error string set. If the shell uses exceptions, LMIDeletedObjectError
will
+ be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
(rval, rparams, errorstr) = self._client._modify_instance(self._cim_instance)
return LMIReturnValue(rval=rval, rparams=rparams, errorstr=errorstr)
@@ -562,7 +660,11 @@ class LMIInstance(LMIBaseObject):
Deletes this instance from the CIMOM.
Note: If the method LMIInstance.delete() was called, this method will not
execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions,
LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
rval = self._client._delete_instance(self.path)
self._deleted = rval.rval == 0