Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
List overview
Download
cura-tools-devel
June 2013
----- 2024 -----
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
cura-tools-devel@lists.fedorahosted.org
1 participants
13 discussions
Start a n
N
ew thread
[cura-tools] master: introduce dictionary-based filtering (04d89ce)
by phatina@fedoraproject.org
25 Jun '13
25 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 04d89ce5b2080d1b5c0e6db269e003da7bc1c6eb Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Jun 25 13:56:26 2013 +0200 introduce dictionary-based filtering using key=something, value=something is deprecated >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 41 +++++++++++++++++++++++++++++++----- cli-tools/lmi/lmi_client_shell.py | 32 +++++++++++++++++----------- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index 7707098..5e5f790 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -100,9 +100,13 @@ class LmiBaseClient(object): self._cliconn = pywbem.WBEMConnection(self._hostname, (self._username, password)) - def _get_instance_names(self, class_name, namespace = None, **kwargs): + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict + def _get_instance_names(self, class_name, namespace = None, inst_filter = None, **kwargs): filter_value = "" filter_key = "Name" + if inst_filter is None: + inst_filter = {} if "key" in kwargs: filter_key = kwargs["key"] kwargs.pop("key") @@ -115,10 +119,21 @@ class LmiBaseClient(object): if "Value" in kwargs: filter_value = kwargs["Value"] kwargs.pop("Value") + if filter_value: + inst_filter[filter_key] = filter_value try: inst_name_list = self._cliconn.EnumerateInstanceNames(class_name, namespace, **kwargs) - if filter_value: - inst_name_list = filter(lambda n: n[filter_key] == filter_value, inst_name_list) + if inst_filter: + inst_name_list_filtered = [] + for inst_name in inst_name_list: + append = True + for (filter_key, filter_value) in inst_filter.iteritems(): + if inst_name[filter_key] != filter_value: + append = False + break + if append: + inst_name_list_filtered.append(inst_name) + inst_name_list = inst_name_list_filtered except KeyError, e: errorstr = "Can not filter by '%s'" % filter_key raise_or_dump_exception(LmiFilterError(errorstr)) @@ -142,9 +157,13 @@ class LmiBaseClient(object): return LmiReturnValue(rval = None, errorstr = e.args[0]) return LmiReturnValue(rval = inst) - def _get_instances(self, class_name, namespace = None, **kwargs): + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict + def _get_instances(self, class_name, namespace = None, inst_filter = None, **kwargs): filter_value = "" filter_key = "Name" + if inst_filter is None: + inst_filter = {} if "key" in kwargs: filter_key = kwargs["key"] kwargs.pop("key") @@ -157,9 +176,19 @@ class LmiBaseClient(object): if "Value" in kwargs: filter_value = kwargs["Value"] kwargs.pop("Value") - query = "select * from %s" % class_name if filter_value: - query += " where %s = \"%s\"" % (filter_key, filter_value) + inst_filter[filter_key] = filter_value + query = "select * from %s" % class_name + if inst_filter: + more = False + query += " where" + for (filter_key, filter_value) in inst_filter.iteritems(): + if more: + query += " and" + quotes = isinstance(filter_value, basestring) + query += " %s =" % filter_key + query += " \"%s\"" % filter_value if quotes else " %s" % filter_value + more = True (inst_list, _, errorstr) = self._exec_query(LmiBaseClient.QUERY_LANG_WQL, query, namespace) if not inst_list: return LmiReturnValue(rval = None, errorstr = errorstr) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 48a93df..8c7321d 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -520,10 +520,12 @@ class _LmiClass(BaseObject): def doc(self): _LmiXmlFormatter(self._cim_class.tocimxml()).fancy_format(self._client.interactive) + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict @lmi_return_val_if_fail("_namespace", []) - def instance_names(self, **kwargs): + def instance_names(self, inst_filter = None, **kwargs): (inst_name_list, _, errorstr) = self._client._get_instance_names( - self._cim_classname, namespace = self._namespace.name, **kwargs) + self._cim_classname, self._namespace.name, inst_filter, **kwargs) if not inst_name_list: return [] result = [] @@ -531,33 +533,37 @@ class _LmiClass(BaseObject): result.append(_LmiInstanceName(self._client, i)) return result - def first_instance_name(self, **kwargs): - inst_name_list = self.instance_names(**kwargs) + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict + def first_instance_name(self, inst_filter = None, **kwargs): + inst_name_list = self.instance_names(inst_filter, **kwargs) if not inst_name_list: return None return inst_name_list[0] + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict @lmi_return_val_if_fail("_namespace", []) - def instances(self, **kwargs): + def instances(self, inst_filter = None, **kwargs): (instance_list, _, errorstr) = self._client._get_instances( - self._cim_classname, self._namespace.name, **kwargs) + self._cim_classname, self._namespace.name, inst_filter, **kwargs) if not instance_list: return [] return map(lambda inst: _LmiInstance(self._client, self, inst), instance_list) - def first_instance(self, **kwargs): + # NOTE: usage with Key=something, Value=something is deprecated + # NOTE: inst_filter is either None or dict + def first_instance(self, inst_filter = None, **kwargs): result = None - keys = [k.lower() for k in kwargs.keys()] - if "value" in keys: + filter_value = "value" in [k.lower() for k in kwargs.keys()] + if inst_filter or filter_value: (instance_list, _, errorstr) = self._client._get_instances( - self._cim_classname, self._namespace.name, **kwargs) + self._cim_classname, self._namespace.name, inst_filter, **kwargs) if instance_list: result = _LmiInstance(self._client, self, instance_list[0]) else: - inst_name = self.first_instance_name(**kwargs) + inst_name = self.first_instance_name(inst_filter, **kwargs) result = inst_name.to_instance() if inst_name else None - if not result and LmiBaseClient._get_use_exceptions(): - raise return result @lmi_class_fetch_lazy
1
0
0
0
[cura-tools] master: fix LmiClientBase::_get_instances() filter language constant (8292a02)
by phatina@fedoraproject.org
25 Jun '13
25 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 8292a02f376c8445e78b8f225fdf880b82410189 Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 14:40:34 2013 +0200 fix LmiClientBase::_get_instances() filter language constant >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index f90a46a..7707098 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -160,7 +160,7 @@ class LmiBaseClient(object): query = "select * from %s" % class_name if filter_value: query += " where %s = \"%s\"" % (filter_key, filter_value) - (inst_list, _, errorstr) = self._exec_query("WQL", query, namespace) + (inst_list, _, errorstr) = self._exec_query(LmiBaseClient.QUERY_LANG_WQL, query, namespace) if not inst_list: return LmiReturnValue(rval = None, errorstr = errorstr) return LmiReturnValue(rval = inst_list)
1
0
0
0
[cura-tools] master: use query language for _LmiClass::first_instance() filtering (4cc66dc)
by phatina@fedoraproject.org
25 Jun '13
25 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 4cc66dc157b9bcffa4591e25124ae979ce81298b Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 14:39:21 2013 +0200 use query language for _LmiClass::first_instance() filtering >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 6de7273..48a93df 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -545,14 +545,20 @@ class _LmiClass(BaseObject): return [] return map(lambda inst: _LmiInstance(self._client, self, inst), instance_list) - # NOTE: filtering is done only by key properties def first_instance(self, **kwargs): - inst_name = self.first_instance_name(**kwargs) - if not inst_name: - if LmiBaseClient._get_use_exceptions(): - raise - return None - return inst_name.to_instance() + result = None + keys = [k.lower() for k in kwargs.keys()] + if "value" in keys: + (instance_list, _, errorstr) = self._client._get_instances( + self._cim_classname, self._namespace.name, **kwargs) + if instance_list: + result = _LmiInstance(self._client, self, instance_list[0]) + else: + inst_name = self.first_instance_name(**kwargs) + result = inst_name.to_instance() if inst_name else None + if not result and LmiBaseClient._get_use_exceptions(): + raise + return result @lmi_class_fetch_lazy @lmi_return_val_if_fail("_namespace", [])
1
0
0
0
[cura-tools] master: introduce use_exceptions config item (03a5614)
by phatina@fedoraproject.org
25 Jun '13
25 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 03a5614b042ee1b2f348e8ff2ac151b45a2ba38e Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 13:45:01 2013 +0200 introduce use_exceptions config item >--------------------------------------------------------------- cli-tools/lmishell | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 1d7009e..a12233e 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -186,6 +186,7 @@ class LmiInteractiveShellConfig(object): DEFAULT_HISTORY_FILE = "~/.lmi_shell_history" DEFAULT_HISTORY_LENGTH = -1 DEFAULT_USE_CACHE = True + DEFAULT_USE_EXCEPTIONS = False def __init__(self): try: @@ -197,12 +198,15 @@ class LmiInteractiveShellConfig(object): LmiInteractiveShellConfig.DEFAULT_HISTORY_LENGTH) self._use_cache = get_item_or_default(conf, "use_cache", LmiInteractiveShellConfig.DEFAULT_USE_CACHE) + self._use_exceptions = get_item_or_default(conf, "use_exceptions", + LmiInteractiveShellConfig.DEFAULT_USE_EXCEPTIONS) except (SyntaxError, IOError), e: if isinstance(e, SyntaxError): sys.stderr.write("Error: %s\n" % e) self._history_file = os.path.expanduser(LmiInteractiveShellConfig.DEFAULT_HISTORY_FILE) self._history_length = LmiInteractiveShellConfig.DEFAULT_HISTORY_LENGTH self._use_cache = LmiInteractiveShellConfig.DEFAULT_USE_CACHE + self._use_exceptions = LmiInteractiveShellConfig.DEFAULT_USE_EXCEPTIONS @property def history_file(self): @@ -216,6 +220,10 @@ class LmiInteractiveShellConfig(object): def use_cache(self): return self._use_cache + @property + def use_exceptions(self): + return self._use_exceptions + class LmiInteractiveShell(code.InteractiveConsole): DEFAULT_LOCALS = { "LmiConnection" : LmiConnection, @@ -247,6 +255,7 @@ class LmiInteractiveShell(code.InteractiveConsole): locals["connect"] = lambda h, u = "", p = "": _connect(h, u, p, True, self._use_cache) readline.set_completer(self._completer.complete) readline.parse_and_bind('tab: complete') + LmiBaseClient._set_use_exceptions(config.use_exceptions) def interact(self): self.load_history()
1
0
0
0
[cura-tools] master: introduce _LmiInstanceName::key_properties(), ::print_key_properties(), ::key_properties_dict(), ::key_property_value() (8466b12)
by phatina@fedoraproject.org
24 Jun '13
24 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 8466b121a4f32077a1278e2fbe67828d7cd1ab16 Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 11:04:24 2013 +0200 introduce _LmiInstanceName::key_properties(), ::print_key_properties(), ::key_properties_dict(), ::key_property_value() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 21 +++++++++++++++++++++ cli-tools/lmishell | 4 ++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 1583a97..6de7273 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -589,6 +589,14 @@ class _LmiInstanceName(BaseObject): self._client = client self._cim_instance_name = cim_instance_name + def __getattr__(self, name): + if name in self.__dict__: + return self.__dict__[name] + key_props = self.key_properties() + if key_props and name in key_props: + return self._cim_instance_name[name] + raise AttributeError(name) + def __repr__(self): return "%s(...)" % self.__class__.__name__ @@ -602,6 +610,19 @@ class _LmiInstanceName(BaseObject): lmi_class = _LmiClass(self._client, lmi_namespace, cim_classname) return _LmiInstance(self._client, lmi_class, cim_instance) + def key_properties(self): + return self._cim_instance_name.keys() + + def print_key_properties(self): + for name in self._cim_instance_name.keys(): + sys.stdout.write("%s\n" % name) + + def key_properties_dict(self): + return dict(self._cim_instance_name.items()) + + def key_property_value(self, prop_name): + return getattr(self, prop_name) + @property def path(self): return self._cim_instance_name diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 74f4728..1d7009e 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -168,6 +168,10 @@ class _LmiCompleter(rlcompleter.Completer): for p in expr.properties(): if p.lower().startswith(to_complete.lower()): self._last_complete.append(cmd + "." + p) + elif isinstance(expr, _LmiInstanceName): + for p in expr.key_properties(): + if p.lower().startswith(to_complete.lower()): + self._last_complete.append(cmd + "." + p) elif isinstance(expr, LmiReturnValue): for p in expr.properties(): if p.lower().startswith(to_complete.lower()):
1
0
0
0
[cura-tools] master: fix return value from LmiBaseClient::_get_instance_name() when filtering with non-key property (9941a6c)
by phatina@fedoraproject.org
24 Jun '13
24 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 9941a6c1a264ce80ff8bd6e4fff0d832cad21402 Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 10:33:29 2013 +0200 fix return value from LmiBaseClient::_get_instance_name() when filtering with non-key property >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 18 ++++++++++++++---- cli-tools/lmi/lmi_client_shell.py | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index 89e0206..f90a46a 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -22,11 +22,17 @@ _RValue = collections.namedtuple('RValue', ["rval", "rparams", "errorstr"]) class LmiReturnValueError(Exception): """Raised, when there is a mandatory argument missing""" -def raise_or_dump_exception(e): +class LmiFilterError(Exception): + """Raised, when there is a filter error present""" + +def raise_or_dump_exception(e = None): if not LmiBaseClient._get_use_exceptions(): return (et, ei, tb) = sys.exc_info() - raise et, ei, tb + if e is None: + raise et, ei, tb + else: + raise type(e), e, tb class LmiReturnValue(_RValue): def __getattr__(self, name): @@ -111,14 +117,18 @@ class LmiBaseClient(object): kwargs.pop("Value") try: inst_name_list = self._cliconn.EnumerateInstanceNames(class_name, namespace, **kwargs) + if filter_value: + inst_name_list = filter(lambda n: n[filter_key] == filter_value, inst_name_list) + except KeyError, e: + errorstr = "Can not filter by '%s'" % filter_key + raise_or_dump_exception(LmiFilterError(errorstr)) + return LmiReturnValue(rval = None, errorstr = errorstr) except pywbem.cim_operations.CIMError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[1]) except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[0]) - if filter_value: - inst_name_list = filter(lambda n: not filter_key in n or n[filter_key] == filter_value, inst_name_list) return LmiReturnValue(rval = inst_name_list) def _get_instance(self, path, **kwargs): diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index a9fffc6..1583a97 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -545,6 +545,7 @@ class _LmiClass(BaseObject): return [] return map(lambda inst: _LmiInstance(self._client, self, inst), instance_list) + # NOTE: filtering is done only by key properties def first_instance(self, **kwargs): inst_name = self.first_instance_name(**kwargs) if not inst_name:
1
0
0
0
[cura-tools] master: fix cql/wql query _LmiClass lazy fetch (64f3a19)
by phatina@fedoraproject.org
24 Jun '13
24 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 64f3a19c9fcd2a0eaad0e6dc760960d83cefe708 Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Jun 24 09:49:56 2013 +0200 fix cql/wql query _LmiClass lazy fetch >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 66c6667..a9fffc6 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -418,9 +418,7 @@ class _LmiNamespace(BaseObject): for cim_inst in cim_inst_list: if isinstance(cim_inst, pywbem.cim_obj.CIMInstance): lmi_namespace = _LmiNamespace(self._client, cim_inst.path.namespace) - (cim_class, _, errorstr) = self._client._get_class(cim_inst.classname, - cim_inst.path.namespace, LocalOnly = False) - lmi_class = _LmiClass(self._client, lmi_namespace, cim_class) + lmi_class = _LmiClass(self._client, lmi_namespace, cim_inst.classname) if not lmi_class: return [] lmi_inst_list.append(_LmiInstance(self._client, lmi_class, cim_inst))
1
0
0
0
[cura-tools] master: introduce _LmiInstance::refresh() (5190db1)
by phatina@fedoraproject.org
24 Jun '13
24 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 5190db138ead4c31748bee424994c8d51eb793a2 Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Jun 19 13:53:28 2013 +0200 introduce _LmiInstance::refresh() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index ffb1168..66c6667 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -689,15 +689,12 @@ class _LmiInstanceMethod(BaseObject): if LmiBaseClient._get_use_exceptions(): raise LmiMethodCallError("Could not perform CIM -> LMI object transformation") return LmiReturnValue(rval = rval, errorstr = errorstr) - (new_inst, _, _) = self._client._get_instance( - self._lmi_instance.path, LocalOnly = False) - if not new_inst: + if not self._lmi_instance.refresh(): # NOTE: this is wrong! What should we do? errorstr = "Could not update an LMI object after a method call" if LmiBaseClient._get_use_exceptions(): raise LmiMethodCallError(errorstr) return LmiReturnValue(rval = rval, errorstr = errorstr) - self._lmi_instance._cim_instance = new_inst return LmiReturnValue( hostname = self._client.hostname, instance = self._lmi_instance, @@ -778,6 +775,14 @@ class _LmiInstance(BaseObject): _LmiMofFormatter(self._cim_instance.tomof()).fancy_format(self._client.interactive) @possibly_deleted + def refresh(self): + (new_cim_instance, _, _) = self._client._get_instance(self.path, LocalOnly = False) + if not new_cim_instance: + return False + self._cim_instance = new_cim_instance + return True + + @possibly_deleted @lmi_return_val_if_fail("_cim_instance.path", []) def associator_names(self, AssocClass = None, ResultClass = None, Role = None,\ ResultRole = None):
1
0
0
0
[cura-tools] master: fix qualifier formating in _LmiXmlFormatter (7d4b2fe)
by phatina@fedoraproject.org
24 Jun '13
24 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 7d4b2feede96eaa87348deba5e4265997dd537dc Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Jun 19 10:58:40 2013 +0200 fix qualifier formating in _LmiXmlFormatter >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 1f81ec8..ffb1168 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -227,7 +227,8 @@ class _LmiXmlFormatter(_LmiFormatter): if values and isinstance(values[0], pywbem.cim_xml.VALUE_ARRAY): val += ": { " + ", ".join(["'" + v.firstChild.nodeValue + "'" for v in values[0].childNodes]) + " }\n" else: - val += ": '%s'\n" % values[0].firstChild.nodeValue + if values: + val += ": '%s'\n" % values[0].firstChild.nodeValue _LmiTextFormatter(val).format(indent, sub_indent + 4, width, f, separator = True) def __format_class_property(self, node, indent = 0, sub_indent = 0, width = 80, f = sys.stdout):
1
0
0
0
[cura-tools] master: fix cast assigned value to _LmiInstance property (a06ba71)
by phatina@fedoraproject.org
19 Jun '13
19 Jun '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit a06ba7196e93d1e97a4feb43c7eba4b057745384 Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Jun 18 15:35:00 2013 +0200 fix cast assigned value to _LmiInstance property >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 1886dd4..1f81ec8 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -743,7 +743,8 @@ class _LmiInstance(BaseObject): @possibly_deleted def __setattr__(self, name, value): if name in self._cim_instance: - self._cim_instance[name] = value + t = self._cim_instance.properties[name].type + self._cim_instance[name] = cast_lmi_to_cim(t, value) else: self.__dict__[name] = value
1
0
0
0
← Newer
1
2
Older →
Jump to page:
1
2
Results per page:
10
25
50
100
200