Skip to content

Instantly share code, notes, and snippets.

@alapidas
Created July 7, 2015 16:56
Show Gist options
  • Save alapidas/d8c18b546e1162a9aece to your computer and use it in GitHub Desktop.
Save alapidas/d8c18b546e1162a9aece to your computer and use it in GitHub Desktop.
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/__init__.py svn/ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/__init__.py
--- ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/__init__.py 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/__init__.py 2015-07-07 11:48:05.000000000 -0500
@@ -25,8 +25,8 @@ class ZenPack(ZenPackBase):
"""WBEM ZenPack."""
packZProperties = [
- ('zWBEMPort', '5988', 'integer'),
+ ('zWBEMPort', '5989', 'integer'),
('zWBEMUsername', '', 'string'),
('zWBEMPassword', '', 'password'),
- ('zWBEMUseSSL', False, 'boolean'),
+ ('zWBEMUseSSL', True, 'boolean'),
]
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/datasources/WBEMDataSource.py svn/ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/datasources/WBEMDataSource.py
--- ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/datasources/WBEMDataSource.py 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/ZenPacks/zenoss/WBEM/datasources/WBEMDataSource.py 2015-07-07 11:48:05.000000000 -0500
@@ -12,7 +12,7 @@ log = logging.getLogger('zen.WBEM')
import calendar
-from twisted.internet import threads
+from twisted.internet import reactor, ssl
from zope.component import adapts
from zope.interface import implements
@@ -31,7 +31,7 @@ from ZenPacks.zenoss.WBEM.utils import a
addLocalLibPath()
-from pywbem.cim_operations import WBEMConnection
+from pywbem.twisted_client import ExecQuery
def string_to_lines(string):
@@ -105,11 +105,18 @@ class WBEMDataSourceInfo(RRDDataSourceIn
cycletime = ProxyProperty('cycletime')
namespace = ProxyProperty('namespace')
- query = ProxyProperty('query')
result_component_key = ProxyProperty('result_component_key')
result_component_value = ProxyProperty('result_component_value')
result_timestamp_key = ProxyProperty('result_timestamp_key')
+ @property
+ def query(self):
+ return "\n".join(self._object.query)
+
+ @query.setter
+ def query(self, val):
+ self._object.query = string_to_lines(val)
+
class WBEMDataSourcePlugin(PythonDataSourcePlugin):
proxy_attributes = (
@@ -158,17 +165,25 @@ class WBEMDataSourcePlugin(PythonDataSou
credentials = (ds0.zWBEMUsername, ds0.zWBEMPassword)
- url = '{0}://{1}:{2}'.format(
- 'https' if ds0.zWBEMUseSSL else 'http',
- ds0.manageIp, ds0.zWBEMPort
- )
+ factory = ExecQuery(
+ credentials,
+ ds0.params['query_language'],
+ ds0.params['query'],
+ namespace=ds0.params['namespace'])
+
+ if ds0.zWBEMUseSSL:
+ reactor.connectSSL(
+ host=ds0.manageIp,
+ port=int(ds0.zWBEMPort),
+ factory=factory,
+ contextFactory=ssl.ClientContextFactory())
+ else:
+ reactor.connectTCP(
+ host=ds0.manageIp,
+ port=int(ds0.zWBEMPort),
+ factory=factory)
- def _inner():
- return WBEMConnection(url, credentials).ExecQuery(
- ds0.params['query_language'],
- ds0.params['query'],
- namespace=ds0.params['namespace'])
- return threads.deferToThread(_inner)
+ return factory.deferred
def onSuccess(self, results, config):
data = self.new_data()
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/dita/.gitignore svn/ZenPacks.zenoss.WBEM/dita/.gitignore
--- ZenPacks.zenoss.WBEM/dita/.gitignore 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/dita/.gitignore 1969-12-31 18:00:00.000000000 -0600
@@ -1,5 +0,0 @@
-#################
-## Oxygen
-#################
-out/
-temp/
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/dita/WBEM.ditamap svn/ZenPacks.zenoss.WBEM/dita/WBEM.ditamap
--- ZenPacks.zenoss.WBEM/dita/WBEM.ditamap 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/dita/WBEM.ditamap 1969-12-31 18:00:00.000000000 -0600
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE map
- PUBLIC "urn:pubid:zenoss.com:doctypes:dita:dtd:map" "map.dtd">
-<map>
- <title>ZenPacks.zenoss.WBEM</title>
- <topicref href="topics/WBEM.dita">
- </topicref>
-</map>
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/dita/topics/WBEM.dita svn/ZenPacks.zenoss.WBEM/dita/topics/WBEM.dita
--- ZenPacks.zenoss.WBEM/dita/topics/WBEM.dita 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/dita/topics/WBEM.dita 1969-12-31 18:00:00.000000000 -0600
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE reference PUBLIC "urn:pubid:zenoss.com:doctypes:dita:dtd:reference" "reference.dtd">
-<reference id="referenceid">
- <title>ZenPacks.zenoss.WBEM</title>
- <shortdesc>This ZenPack adds a WBEM data source type and a WBEMPlugin base modeler plugin.</shortdesc>
- <refbody>
- <section>
- <p>The WBEM data source type simplifies collecting metrics from WBEM providers with CQL queries.
- The WBEMPlugin modeler plugin class simplifies modeling devices and applications that support WBEM.</p>
- </section>
- </refbody>
-</reference>
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/dita/topics/data-source.dita svn/ZenPacks.zenoss.WBEM/dita/topics/data-source.dita
--- ZenPacks.zenoss.WBEM/dita/topics/data-source.dita 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/dita/topics/data-source.dita 1969-12-31 18:00:00.000000000 -0600
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE reference PUBLIC "urn:pubid:zenoss.com:doctypes:dita:dtd:reference" "reference.dtd">
-<reference id="referenceid">
- <title>WBEM Data Source Type</title>
- <refbody>
- <section>
- <p>The WBEM data source type supports the following properties.</p>
- <dl>
- <dlentry>
- <dt>Namespace</dt>
- <dd>The WBEM namespace. This property is required and there is no default value. A common example is <codeph>root/cimv2</codeph>. </dd>
- </dlentry>
- <dlentry>
- <dt>CQL Query</dt>
- <dd>The CQL query to execute. This property is required and there is no default value. </dd>
- </dlentry>
- <dlentry>
- <dt>Result Component Key</dt>
- <dd>(Optional) Use this property when the WBEM data source is part of a monitoring
- template that is bound to components. Set the value to the attribute or column name in
- the CQL result set that contains the component identifier.</dd>
- </dlentry>
- <dlentry>
- <dt>Result Component Value</dt>
- <dd>(Optional) Use this property when the WBEM data source is part of a monitoring
- template that is bound to components. Set the value to the Result Component Key column
- of the CQL result set. Typically, this value is a
- TALES expression, such as <codeph>&#36;&#123;here/id&#125;</codeph> or
- <codeph>&#36;&#123;here/wbemInstanceId&#125;</codeph>.</dd>
- </dlentry>
- <dlentry>
- <dt>Result Timestamp Key</dt>
- <dd>(Optional) Use this property in either device-bound or component-bound templates when the CQL result set includes a column
- noting the time at which the data was originally collected. Like the Result Component Key property, set the value to
- the attribute or column name in the CQL result set. The default value is NOW.</dd>
- </dlentry>
- </dl>
- </section>
- </refbody>
-</reference>
diff '--exclude=.git' '--exclude=.svn' -Nurp ZenPacks.zenoss.WBEM/setup.py svn/ZenPacks.zenoss.WBEM/setup.py
--- ZenPacks.zenoss.WBEM/setup.py 2015-07-07 11:48:54.000000000 -0500
+++ svn/ZenPacks.zenoss.WBEM/setup.py 2015-07-07 11:48:05.000000000 -0500
@@ -3,7 +3,7 @@
# or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = "ZenPacks.zenoss.WBEM"
-VERSION = "1.0.0"
+VERSION = "1.0.1"
AUTHOR = "Zenoss"
LICENSE = "All Rights Reserved"
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.zenoss']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment