[openlmi-tools] simplify indication subscription
Peter Hatina
phatina at fedoraproject.org
Mon Dec 9 16:17:06 UTC 2013
commit 37df4f3e120381ece41f569beb86ee855c611c95
Author: Peter Hatina <phatina at redhat.com>
Date: Mon Dec 9 15:40:37 2013 +0100
simplify indication subscription
...tools-12-simplify-indication-subscription.patch | 159 ++++++++++++++++++++
openlmi-tools.spec | 7 +-
2 files changed, 165 insertions(+), 1 deletions(-)
---
diff --git a/openlmi-tools-12-simplify-indication-subscription.patch b/openlmi-tools-12-simplify-indication-subscription.patch
new file mode 100644
index 0000000..5c51ef3
--- /dev/null
+++ b/openlmi-tools-12-simplify-indication-subscription.patch
@@ -0,0 +1,159 @@
+diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
+index 7c693c7..af9379b 100644
+--- a/cli/lmi/shell/LMIConnection.py
++++ b/cli/lmi/shell/LMIConnection.py
+@@ -332,27 +332,32 @@ class LMIConnection(object):
+
+ * **Filter** (*LMIInstance*) -- if provided, the
+ :py:class:`LMIInstance` object will be used instead of creating a new one;
+- optional
++ **optional**
+ * **Handler** (*LMIInstance*) -- if provided, the :py:class:`LMIInstance`
+- object will be used instead of creating a new one; optional
++ object will be used instead of creating a new one; **optional**
+ * **Query** (*string*) -- string containing a query for the indications filtering
+- * **QueryLanguage** (*string*) -- query language; eg. `WQL`, or `DMTF:CQL`
++ * **QueryLanguage** (*string*) -- query language; eg. *WQL*, or *DMTF:CQL*.
++ This parameter is optional, default value is *DMTF:CQL*.
+ * **Name** (*string*) -- indication name
+- * **CreationNamespace** (*string*) -- creation namespace
++ * **CreationNamespace** (*string*) -- creation namespace. This parameter is
++ optional, default value is *root/interop*.
+ * **SubscriptionCreationClassName** (*string*) -- subscription object class
+- name
++ name. This parameter is optional, default value is *CIM_IndicationSubscription*.
+ * **Permanent** (*bool*) -- whether to preserve the created subscription on
+ LMIShell's quit. Default value is False.
+ * **FilterCreationClassName** (*string*) -- creation class name of the filter
+- object
++ object. This parameter is options, default value is *CIM_IndicationFilter*.
+ * **FilterSystemCreationClassName** (*string*) -- system creation class name
+- of the filter object
++ of the filter object. This parameter is optional, default value is
++ *CIM_ComputerSystem*.
+ * **FilterSourceNamespace** (*string*) -- local namespace where the
+- indications originate
++ indications originate. This parameter is optional, default value is
++ *root/cimv2*.
+ * **HandlerCreationClassName** (*string*) -- creation class name of the
+- handler object
++ handler object. This parameter is optional, default value is
++ *CIM_IndicationHandlerCIMXML*.
+ * **HandlerSystemCreationClassName** (*string*) -- system creation name of the
+- handler object
++ handler object. This parameter is optional, default value is *CIM_ComputerSystem*.
+ * **Destination** (*string*) -- destination URI, where the indications should
+ be delivered
+
+@@ -361,6 +366,7 @@ class LMIConnection(object):
+ set to appropriate error string.
+ """
+ try:
++ indication_namespace = kwargs.get("CreationNamespace", "root/interop")
+ cim_filter_provided = "Filter" in kwargs
+ if cim_filter_provided:
+ filt = kwargs["Filter"]
+@@ -375,17 +381,27 @@ class LMIConnection(object):
+ return LMIReturnValue(rval=False, errorstr=errorstr)
+ else:
+ cim_filter_props = {
+- "CreationClassName" : kwargs["FilterCreationClassName"],
+- "SystemCreationClassName" : kwargs["FilterSystemCreationClassName"],
+- "SourceNamespace" : kwargs["FilterSourceNamespace"],
++ "CreationClassName" : kwargs.get(
++ "FilterCreationClassName",
++ "CIM_IndicationFilter"),
++ "SystemCreationClassName" : kwargs.get(
++ "FilterSystemCreationClassName",
++ "CIM_ComputerSystem"),
++ "SourceNamespace" : kwargs.get(
++ "FilterSourceNamespace",
++ "root/cimv2"),
+ "SystemName" : self._client.uri,
+ "Query" : kwargs["Query"],
+- "QueryLanguage" : kwargs["QueryLanguage"],
++ "QueryLanguage" : kwargs.get(
++ "QueryLanguage",
++ LMIBaseClient.QUERY_LANG_CQL),
+ "Name" : kwargs["Name"] + "-filter"
+ }
+ (cim_filter, _, errorstr) = self._client._create_instance(
+- kwargs["FilterCreationClassName"], kwargs["CreationNamespace"],
+- cim_filter_props)
++ cim_filter_props["CreationClassName"],
++ indication_namespace,
++ cim_filter_props
++ )
+ if not cim_filter:
+ lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
+ return LMIReturnValue(rval=False, errorstr=errorstr)
+@@ -394,14 +410,19 @@ class LMIConnection(object):
+ cim_handler = kwargs["Handler"]._cim_instance
+ else:
+ cim_handler_props = {
+- "CreationClassName" : kwargs["HandlerCreationClassName"],
+- "SystemCreationClassName" : kwargs["HandlerSystemCreationClassName"],
++ "CreationClassName" : kwargs.get(
++ "HandlerCreationClassName",
++ "CIM_IndicationHandlerCIMXML"),
++ "SystemCreationClassName" : kwargs.get(
++ "HandlerSystemCreationClassName",
++ "CIM_ComputerSystem"),
+ "SystemName" : self._client.uri,
+ "Destination" : kwargs["Destination"] + "/" + kwargs["Name"],
+ "Name" : kwargs["Name"] + "-handler"
+ }
+ (cim_handler, _, errorstr) = self._client._create_instance(
+- kwargs["HandlerCreationClassName"], kwargs["CreationNamespace"],
++ cim_handler_props["CreationClassName"],
++ indication_namespace,
+ cim_handler_props)
+ if not cim_handler:
+ if not "Filter" in kwargs:
+@@ -413,7 +434,10 @@ class LMIConnection(object):
+ "Handler" : cim_handler.path
+ }
+ (cim_subscription, _, errorstr) = self._client._create_instance(
+- kwargs["SubscriptionCreationClassName"], kwargs["CreationNamespace"],
++ kwargs.get(
++ "SubscriptionCreationClassName",
++ "CIM_IndicationSubscription"),
++ indication_namespace,
+ cim_subscription_props)
+ if not cim_subscription:
+ if not "Filter" in kwargs:
+diff --git a/doc/src/indications.rst b/doc/src/indications.rst
+index 585f82e..f0765ff 100644
+--- a/doc/src/indications.rst
++++ b/doc/src/indications.rst
+@@ -32,6 +32,30 @@ How to subscribe to an indication, please, follow the next example:
+ LMIReturnValue(rval=True, rparams={}, errorstr="")
+ >
+
++The previous code can be simplified by omitting some optional parameters:
++
++* *QueryLanguage*: *DMTF:CQL*
++* *CreationNamespace*: *root/interop*
++* *SubscriptionCreationClassName*: *CIM_IndicationSubscription*
++* *FilterCreationClassName*: *CIM_IndicationFilter*
++* *FilterSystemCreationClassName*: *CIM_ComputerSystem*
++* *FilterSourceNamespace*: *root/cimv2*
++* *HandlerCreationClassName*: *CIM_IndicationHandlerCIMXML*
++* *HandlerSystemCreationClassName*: *CIM_ComputerSystem*
++
++Simplified subscription:
++
++.. code-block:: python
++
++ > c = connect("host", "privileged_user", "password")
++ > c.subscribe_indication(
++ ... Name="cpu",
++ ... Query='SELECT * FROM CIM_InstModification',
++ ... Destination="http://192.168.122.1:5988"
++ ... )
++ 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.
+
diff --git a/openlmi-tools.spec b/openlmi-tools.spec
index 92eff46..2595ade 100644
--- a/openlmi-tools.spec
+++ b/openlmi-tools.spec
@@ -1,6 +1,6 @@
Name: openlmi-tools
Version: 0.9
-Release: 13%{?dist}
+Release: 14%{?dist}
Summary: Set of CLI tools for Openlmi providers
License: GPLv2+
@@ -17,6 +17,7 @@ Patch7: openlmi-tools-08-fix-compulsory-call-order-listener.patch
Patch8: openlmi-tools-09-fix-blocking-when-receiving-indication.patch
Patch9: openlmi-tools-10-fix-indication-unique-name.patch
Patch10: openlmi-tools-11-update-documentation.patch
+Patch11: openlmi-tools-12-simplify-indication-subscription.patch
BuildArch: noarch
BuildRequires: automake
@@ -55,6 +56,7 @@ Summary: Documentation for %{name}
%patch8 -p1
%patch9 -p1
%patch10 -p1
+%patch11 -p1
%build
pushd cli
@@ -106,6 +108,9 @@ install -m 644 cli/completion/_lmishell $zsh_comp_dir
%{_docdir}/%{name}-%{version}/html
%changelog
+* Mon Dec 9 2013 Peter Hatina <phatina at redhat.com> - 0.9-14
+- simplify indication subscription
+
* Mon Dec 9 2013 Peter Hatina <phatina at redhat.com> - 0.9-13
- fix documentation version
More information about the scm-commits
mailing list