commit
c29d405ab5
@ -0,0 +1 @@
|
||||
SOURCES/v0.11.0.tar.gz
|
@ -0,0 +1 @@
|
||||
38a67bfd1723c49b586576dd693e5e8422a4d645 SOURCES/v0.11.0.tar.gz
|
@ -0,0 +1,778 @@
|
||||
Index: pywbem-0.11.0/attic/twisted_client.py
|
||||
===================================================================
|
||||
--- pywbem-0.11.0.orig/attic/twisted_client.py
|
||||
+++ /dev/null
|
||||
@@ -1,773 +0,0 @@
|
||||
-#
|
||||
-# (C) Copyright 2005,2007 Hewlett-Packard Development Company, L.P.
|
||||
-#
|
||||
-# This library is free software; you can redistribute it and/or
|
||||
-# modify it under the terms of the GNU Lesser General Public
|
||||
-# License as published by the Free Software Foundation; either
|
||||
-# version 2.1 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
|
||||
-# Lesser General Public License for more details.
|
||||
-#
|
||||
-# You should have received a copy of the GNU Lesser General Public
|
||||
-# License along with this program; if not, write to the Free Software
|
||||
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
-#
|
||||
-# Author: Tim Potter <tpot@hp.com>
|
||||
-#
|
||||
-
|
||||
-"""pywbem.twisted - WBEM client bindings for Twisted Python.
|
||||
-
|
||||
-This module contains factory classes that produce WBEMClient instances
|
||||
-that perform WBEM requests over HTTP using the
|
||||
-twisted.protocols.http.HTTPClient base class.
|
||||
-"""
|
||||
-
|
||||
-import base64
|
||||
-from datetime import datetime, timedelta
|
||||
-try:
|
||||
- from elementtree.ElementTree import fromstring, tostring
|
||||
-except ImportError:
|
||||
- from xml.etree.ElementTree import fromstring, tostring
|
||||
-import six
|
||||
-from six.moves import urllib
|
||||
-
|
||||
-from twisted.internet import reactor, protocol, defer
|
||||
-from twisted.web import http #, client, error
|
||||
-
|
||||
-# TODO: Eww - we should get rid of the tupletree, tupleparse modules
|
||||
-# and replace with elementtree based code.
|
||||
-from . import cim_types, cim_xml, cim_obj, tupleparse, tupletree
|
||||
-from .cim_obj import CIMClass, CIMClassName, CIMInstance, CIMInstanceName
|
||||
-from .cim_operations import CIMError
|
||||
-from .cim_types import CIMDateTime
|
||||
-
|
||||
-__all__ = ['WBEMClient', 'WBEMClientFactory', 'EnumerateInstances',
|
||||
- 'EnumerateInstanceNames', 'GetInstance', 'DeleteInstance',
|
||||
- 'CreateInstance', 'ModifyInstance', 'EnumerateClassNames',
|
||||
- 'EnumerateClasses', 'GetClass', 'Associators', 'AssociatorNames',
|
||||
- 'References', 'ReferenceNames', 'InvokeMethod', 'ExecQuery']
|
||||
-
|
||||
-class WBEMClient(http.HTTPClient):
|
||||
- """A HTTPClient subclass that handles WBEM requests."""
|
||||
-
|
||||
- status = None
|
||||
-
|
||||
- def connectionMade(self):
|
||||
- """Send a HTTP POST command with the appropriate CIM over HTTP
|
||||
- headers and payload."""
|
||||
-
|
||||
- self.factory.request_xml = str(self.factory.payload)
|
||||
-
|
||||
- self.sendCommand('POST', '/cimom')
|
||||
-
|
||||
- self.sendHeader('Host', '%s:%d' %
|
||||
- (self.transport.addr[0], self.transport.addr[1]))
|
||||
- self.sendHeader('User-Agent', 'pywbem/twisted')
|
||||
- self.sendHeader('Content-length', len(self.factory.payload))
|
||||
- self.sendHeader('Content-type', 'application/xml')
|
||||
-
|
||||
- if self.factory.creds:
|
||||
- auth = base64.b64encode('%s:%s' % (self.factory.creds[0],
|
||||
- self.factory.creds[1]))
|
||||
-
|
||||
- self.sendHeader('Authorization', 'Basic %s' % auth)
|
||||
-
|
||||
- self.sendHeader('CIMOperation', str(self.factory.operation))
|
||||
- self.sendHeader('CIMMethod', str(self.factory.method))
|
||||
- self.sendHeader('CIMObject', str(self.factory.object))
|
||||
-
|
||||
- self.endHeaders()
|
||||
-
|
||||
- # TODO: Figure out why twisted doesn't support unicode. An
|
||||
- # exception should be thrown by the str() call if the payload
|
||||
- # can't be converted to the current codepage.
|
||||
-
|
||||
- self.transport.write(str(self.factory.payload))
|
||||
-
|
||||
- def handleResponse(self, data):
|
||||
- """Called when all response data has been received."""
|
||||
-
|
||||
- self.factory.response_xml = data
|
||||
-
|
||||
- if self.status == '200':
|
||||
- self.factory.parseErrorAndResponse(data)
|
||||
-
|
||||
- self.factory.deferred = None
|
||||
- self.transport.loseConnection()
|
||||
-
|
||||
- def handleStatus(self, version, status, message):
|
||||
- """Save the status code for processing when we get to the end
|
||||
- of the headers."""
|
||||
-
|
||||
- self.status = status
|
||||
- self.message = message
|
||||
-
|
||||
- def handleHeader(self, key, value):
|
||||
- """Handle header values."""
|
||||
-
|
||||
- if key == 'CIMError':
|
||||
- self.CIMError = urllib.parse.unquote(value)
|
||||
- if key == 'PGErrorDetail':
|
||||
- self.PGErrorDetail = urllib.parse.unquote(value)
|
||||
-
|
||||
- def handleEndHeaders(self):
|
||||
- """Check whether the status was OK and raise an error if not
|
||||
- using previously saved header information."""
|
||||
-
|
||||
- if self.status != '200':
|
||||
-
|
||||
- if not hasattr(self, 'cimerror') or \
|
||||
- not hasattr(self, 'errordetail'):
|
||||
-
|
||||
- self.factory.deferred.errback(
|
||||
- CIMError(0, 'HTTP error %s: %s' %
|
||||
- (self.status, self.message)))
|
||||
-
|
||||
- else:
|
||||
-
|
||||
- self.factory.deferred.errback(
|
||||
- CIMError(0, '%s: %s' % (cimerror, errordetail)))
|
||||
-
|
||||
-class WBEMClientFactory(protocol.ClientFactory):
|
||||
- """Create instances of the WBEMClient class."""
|
||||
-
|
||||
- request_xml = None
|
||||
- response_xml = None
|
||||
- xml_header = '<?xml version="1.0" encoding="utf-8" ?>'
|
||||
-
|
||||
- def __init__(self, creds, operation, method, object, payload):
|
||||
- self.creds = creds
|
||||
- self.operation = operation
|
||||
- self.method = method
|
||||
- self.object = object
|
||||
- self.payload = payload
|
||||
- self.protocol = lambda: WBEMClient()
|
||||
- self.deferred = defer.Deferred()
|
||||
-
|
||||
- def clientConnectionFailed(self, connector, reason):
|
||||
- if self.deferred is not None:
|
||||
- reactor.callLater(0, self.deferred.errback, reason)
|
||||
-
|
||||
- def clientConnectionLost(self, connector, reason):
|
||||
- if self.deferred is not None:
|
||||
- reactor.callLater(0, self.deferred.errback, reason)
|
||||
-
|
||||
- def imethodcallPayload(self, methodname, localnsp, **kwargs):
|
||||
- """Generate the XML payload for an intrinsic methodcall."""
|
||||
-
|
||||
- param_list = [pywbem.IPARAMVALUE(x[0], pywbem.tocimxml(x[1]))
|
||||
- for x in kwargs.items()]
|
||||
-
|
||||
- payload = cim_xml.CIM(
|
||||
- cim_xml.MESSAGE(
|
||||
- cim_xml.SIMPLEREQ(
|
||||
- cim_xml.IMETHODCALL(
|
||||
- methodname,
|
||||
- cim_xml.LOCALNAMESPACEPATH(
|
||||
- [cim_xml.NAMESPACE(ns)
|
||||
- for ns in localnsp.split('/')]),
|
||||
- param_list)),
|
||||
- '1001', '1.0'),
|
||||
- '2.0', '2.0')
|
||||
-
|
||||
- return self.xml_header + payload.toxml()
|
||||
-
|
||||
- def methodcallPayload(self, methodname, obj, namespace, **kwargs):
|
||||
- """Generate the XML payload for an extrinsic methodcall."""
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName):
|
||||
-
|
||||
- path = obj.copy()
|
||||
-
|
||||
- path.host = None
|
||||
- path.namespace = None
|
||||
-
|
||||
- localpath = cim_xml.LOCALINSTANCEPATH(
|
||||
- cim_xml.LOCALNAMESPACEPATH(
|
||||
- [cim_xml.NAMESPACE(ns)
|
||||
- for ns in namespace.split('/')]),
|
||||
- path.tocimxml())
|
||||
- else:
|
||||
- localpath = cim_xml.LOCALCLASSPATH(
|
||||
- cim_xml.LOCALNAMESPACEPATH(
|
||||
- [cim_xml.NAMESPACE(ns)
|
||||
- for ns in namespace.split('/')]),
|
||||
- obj)
|
||||
-
|
||||
- def paramtype(obj):
|
||||
- """Return a string to be used as the CIMTYPE for a parameter."""
|
||||
- if isinstance(obj, cim_types.CIMType):
|
||||
- return obj.cimtype
|
||||
- elif type(obj) == bool:
|
||||
- return 'boolean'
|
||||
- elif isinstance(obj, six.string_types):
|
||||
- return 'string'
|
||||
- elif isinstance(obj, (datetime, timedelta)):
|
||||
- return 'datetime'
|
||||
- elif isinstance(obj, (CIMClassName, CIMInstanceName)):
|
||||
- return 'reference'
|
||||
- elif isinstance(obj, (CIMClass, CIMInstance)):
|
||||
- return 'string'
|
||||
- elif isinstance(obj, list):
|
||||
- return paramtype(obj[0])
|
||||
- raise TypeError('Unsupported parameter type "%s"' % type(obj))
|
||||
-
|
||||
- def paramvalue(obj):
|
||||
- """Return a cim_xml node to be used as the value for a
|
||||
- parameter."""
|
||||
- if isinstance(obj, (datetime, timedelta)):
|
||||
- obj = CIMDateTime(obj)
|
||||
- if isinstance(obj, (cim_types.CIMType, bool, six.string_types)):
|
||||
- return cim_xml.VALUE(cim_types.atomic_to_cim_xml(obj))
|
||||
- if isinstance(obj, (CIMClassName, CIMInstanceName)):
|
||||
- return cim_xml.VALUE_REFERENCE(obj.tocimxml())
|
||||
- if isinstance(obj, (CIMClass, CIMInstance)):
|
||||
- return cim_xml.VALUE(obj.tocimxml().toxml())
|
||||
- if isinstance(obj, list):
|
||||
- if isinstance(obj[0], (CIMClassName, CIMInstanceName)):
|
||||
- return cim_xml.VALUE_REFARRAY([paramvalue(x) for x in obj])
|
||||
- return cim_xml.VALUE_ARRAY([paramvalue(x) for x in obj])
|
||||
- raise TypeError('Unsupported parameter type "%s"' % type(obj))
|
||||
-
|
||||
- param_list = [cim_xml.PARAMVALUE(x[0],
|
||||
- paramvalue(x[1]),
|
||||
- paramtype(x[1]))
|
||||
- for x in kwargs.items()]
|
||||
-
|
||||
- payload = cim_xml.CIM(
|
||||
- cim_xml.MESSAGE(
|
||||
- cim_xml.SIMPLEREQ(
|
||||
- cim_xml.METHODCALL(methodname,
|
||||
- localpath,
|
||||
- param_list)),
|
||||
- '1001', '1.0'),
|
||||
- '2.0', '2.0')
|
||||
-
|
||||
- return self.xml_header + payload.toxml()
|
||||
-
|
||||
- def parseErrorAndResponse(self, data):
|
||||
- """Parse returned XML for errors, then convert into
|
||||
- appropriate Python objects."""
|
||||
-
|
||||
- xml = fromstring(data)
|
||||
- error = xml.find('.//ERROR')
|
||||
-
|
||||
- if error is None:
|
||||
- self.deferred.callback(self.parseResponse(xml))
|
||||
- return
|
||||
-
|
||||
- try:
|
||||
- code = int(error.attrib['CODE'])
|
||||
- except ValueError:
|
||||
- code = 0
|
||||
-
|
||||
- self.deferred.errback(CIMError(code, error.attrib['DESCRIPTION']))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
- """Parse returned XML and convert into appropriate Python
|
||||
- objects. Override in subclass"""
|
||||
-
|
||||
- pass
|
||||
-
|
||||
-class EnumerateInstances(WBEMClientFactory):
|
||||
- """Factory to produce EnumerateInstances WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, classname, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.classname = classname
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'EnumerateInstances',
|
||||
- namespace,
|
||||
- ClassName=CIMClassName(classname),
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='EnumerateInstances',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.classname, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//VALUE.NAMEDINSTANCE')]
|
||||
-
|
||||
- return [tupleparse.parse_value_namedinstance(x) for x in tt]
|
||||
-
|
||||
-class EnumerateInstanceNames(WBEMClientFactory):
|
||||
- """Factory to produce EnumerateInstanceNames WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, classname, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.classname = classname
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'EnumerateInstanceNames',
|
||||
- namespace,
|
||||
- ClassName=CIMClassName(classname),
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='EnumerateInstanceNames',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.classname, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//INSTANCENAME')]
|
||||
-
|
||||
- names = [tupleparse.parse_instancename(x) for x in tt]
|
||||
-
|
||||
- [setattr(n, 'namespace', self.namespace) for n in names]
|
||||
-
|
||||
- return names
|
||||
-
|
||||
-class GetInstance(WBEMClientFactory):
|
||||
- """Factory to produce GetInstance WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, instancename, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.instancename = instancename
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'GetInstance',
|
||||
- namespace,
|
||||
- InstanceName=instancename,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='GetInstance',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.instancename, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = tupletree.xml_to_tupletree(
|
||||
- tostring(xml.find('.//INSTANCE')))
|
||||
-
|
||||
- return tupleparse.parse_instance(tt)
|
||||
-
|
||||
-class DeleteInstance(WBEMClientFactory):
|
||||
- """Factory to produce DeleteInstance WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, instancename, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.instancename = instancename
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'DeleteInstance',
|
||||
- namespace,
|
||||
- InstanceName=instancename,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='DeleteInstance',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.instancename, id(self))
|
||||
-
|
||||
-class CreateInstance(WBEMClientFactory):
|
||||
- """Factory to produce CreateInstance WBEM clients."""
|
||||
-
|
||||
- # TODO: Implement __repr__ method
|
||||
-
|
||||
- def __init__(self, creds, instance, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'CreateInstance',
|
||||
- namespace,
|
||||
- NewInstance=instance,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='CreateInstance',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = tupletree.xml_to_tupletree(
|
||||
- tostring(xml.find('.//INSTANCENAME')))
|
||||
-
|
||||
- return tupleparse.parse_instancename(tt)
|
||||
-
|
||||
-class ModifyInstance(WBEMClientFactory):
|
||||
- """Factory to produce ModifyInstance WBEM clients."""
|
||||
-
|
||||
- # TODO: Implement __repr__ method
|
||||
-
|
||||
- def __init__(self, creds, instancename, instance, namespace='root/cimv2',
|
||||
- **kwargs):
|
||||
-
|
||||
- wrapped_instance = CIMInstanceName(instancename, instance)
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'ModifyInstance',
|
||||
- namespace,
|
||||
- ModifiedInstance=wrapped_instance,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='ModifyInstance',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
-class EnumerateClassNames(WBEMClientFactory):
|
||||
- """Factory to produce EnumerateClassNames WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.localnsp = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'EnumerateClassNames',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='EnumerateClassNames',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//CLASSNAME')]
|
||||
-
|
||||
- return [tupleparse.parse_classname(x) for x in tt]
|
||||
-
|
||||
-class EnumerateClasses(WBEMClientFactory):
|
||||
- """Factory to produce EnumerateClasses WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.localnsp = namespace
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'EnumerateClasses',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='EnumerateClasses',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//CLASS')]
|
||||
-
|
||||
- return [tupleparse.parse_class(x) for x in tt]
|
||||
-
|
||||
-class GetClass(WBEMClientFactory):
|
||||
- """Factory to produce GetClass WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, classname, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- self.classname = classname
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'GetClass',
|
||||
- namespace,
|
||||
- ClassName=CIMClassName(classname),
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='GetClass',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.classname, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- tt = tupletree.xml_to_tupletree(
|
||||
- tostring(xml.find('.//CLASS')))
|
||||
-
|
||||
- return tupleparse.parse_class(tt)
|
||||
-
|
||||
-class Associators(WBEMClientFactory):
|
||||
- """Factory to produce Associators WBEM clients."""
|
||||
-
|
||||
- # TODO: Implement __repr__ method
|
||||
-
|
||||
- def __init__(self, creds, obj, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName):
|
||||
- kwargs['ObjectName'] = obj
|
||||
- else:
|
||||
- kwargs['ObjectName'] = CIMClassName(obj)
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'Associators',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='Associators',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
-class AssociatorNames(WBEMClientFactory):
|
||||
- """Factory to produce AssociatorNames WBEM clients."""
|
||||
-
|
||||
- # TODO: Implement __repr__ method
|
||||
-
|
||||
- def __init__(self, creds, obj, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName):
|
||||
- kwargs['ObjectName'] = obj
|
||||
- else:
|
||||
- kwargs['ObjectName'] = CIMClassName(obj)
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'AssociatorNames',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='AssociatorNames',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- if len(xml.findall('.//INSTANCENAME')) > 0:
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//INSTANCENAME')]
|
||||
-
|
||||
- return [tupleparse.parse_instancename(x) for x in tt]
|
||||
-
|
||||
- else:
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//OBJECTPATH')]
|
||||
-
|
||||
- return [tupleparse.parse_objectpath(x)[2] for x in tt]
|
||||
-
|
||||
-class References(WBEMClientFactory):
|
||||
- """Factory to produce References WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, obj, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName):
|
||||
- kwargs['ObjectName'] = obj
|
||||
- else:
|
||||
- kwargs['ObjectName'] = CIMClassName(obj)
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'References',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='References',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
-class ReferenceNames(WBEMClientFactory):
|
||||
- """Factory to produce ReferenceNames WBEM clients."""
|
||||
-
|
||||
- # TODO: Implement __repr__ method
|
||||
-
|
||||
- def __init__(self, creds, obj, namespace='root/cimv2', **kwargs):
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName):
|
||||
- kwargs['ObjectName'] = obj
|
||||
- else:
|
||||
- kwargs['ObjectName'] = CIMClassName(obj)
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'ReferenceNames',
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='ReferenceNames',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- if len(xml.findall('.//INSTANCENAME')) > 0:
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//INSTANCENAME')]
|
||||
-
|
||||
- return [tupleparse.parse_instancename(x) for x in tt]
|
||||
-
|
||||
- else:
|
||||
-
|
||||
- tt = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//OBJECTPATH')]
|
||||
-
|
||||
- return [tupleparse.parse_objectpath(x)[2] for x in tt]
|
||||
-
|
||||
-class InvokeMethod(WBEMClientFactory):
|
||||
- """Factory to produce InvokeMethod WBEM clients."""
|
||||
-
|
||||
- def __init__(self, creds, MethodName, ObjectName, namespace='root/cimv2',
|
||||
- **kwargs):
|
||||
-
|
||||
- # Convert string to CIMClassName
|
||||
-
|
||||
- obj = ObjectName
|
||||
-
|
||||
- if isinstance(obj, six.string_types):
|
||||
- obj = CIMClassName(obj, namespace=namespace)
|
||||
-
|
||||
- if isinstance(obj, CIMInstanceName) and obj.namespace is None:
|
||||
- obj = ObjectName.copy()
|
||||
- obj.namespace = namespace
|
||||
-
|
||||
- # Make the method call
|
||||
-
|
||||
- payload = self.methodcallPayload(
|
||||
- MethodName,
|
||||
- obj,
|
||||
- namespace,
|
||||
- **kwargs)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method=MethodName,
|
||||
- object=obj,
|
||||
- payload=payload)
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
-
|
||||
- # Return value of method
|
||||
-
|
||||
- result_xml = tupletree.xml_to_tupletree(
|
||||
- tostring(xml.find('.//RETURNVALUE')))
|
||||
-
|
||||
- result_tt = tupleparse.parse_any(result_xml)
|
||||
-
|
||||
- result = cim_obj.tocimobj(result_tt[1]['PARAMTYPE'],
|
||||
- result_tt[2])
|
||||
-
|
||||
- # Output parameters
|
||||
-
|
||||
- params_xml = [tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//PARAMVALUE')]
|
||||
-
|
||||
- params_tt = [tupleparse.parse_any(x) for x in params_xml]
|
||||
-
|
||||
- params = {}
|
||||
-
|
||||
- for p in params_tt:
|
||||
- if p[1] == 'reference':
|
||||
- params[p[0]] = p[2]
|
||||
- else:
|
||||
- params[p[0]] = cim_obj.tocimobj(p[1], p[2])
|
||||
-
|
||||
- return (result, params)
|
||||
-
|
||||
-class ExecQuery(WBEMClientFactory):
|
||||
-
|
||||
- def __init__(self, creds, QueryLanguage, Query, namespace='root/cimv2'):
|
||||
-
|
||||
- self.QueryLanguage = QueryLanguage
|
||||
- self.Query = Query
|
||||
- self.namespace = namespace
|
||||
-
|
||||
- payload = self.imethodcallPayload(
|
||||
- 'ExecQuery',
|
||||
- namespace,
|
||||
- QueryLanguage=QueryLanguage,
|
||||
- Query=Query)
|
||||
-
|
||||
- WBEMClientFactory.__init__(
|
||||
- self,
|
||||
- creds,
|
||||
- operation='MethodCall',
|
||||
- method='ExecQuery',
|
||||
- object=namespace,
|
||||
- payload=payload)
|
||||
-
|
||||
- def __repr__(self):
|
||||
- return '<%s(/%s:%s) at 0x%x>' % \
|
||||
- (self.__class__, self.namespace, self.Query, id(self))
|
||||
-
|
||||
- def parseResponse(self, xml):
|
||||
- tt = [pywbem.tupletree.xml_to_tupletree(tostring(x))
|
||||
- for x in xml.findall('.//INSTANCE')]
|
||||
- return [pywbem.tupleparse.parse_instance(x) for x in tt]
|
@ -0,0 +1,216 @@
|
||||
Name: pywbem
|
||||
Version: 0.11.0
|
||||
Release: 8%{?dist}
|
||||
Summary: Python WBEM Client and Provider Interface
|
||||
Group: Development/Libraries
|
||||
License: LGPLv2
|
||||
URL: https://github.com/pywbem/pywbem
|
||||
Source0: https://github.com/pywbem/pywbem/archive/v%{version}.tar.gz
|
||||
|
||||
BuildRequires: python3-pip python3-PyYAML python3-ply python3-devel
|
||||
BuildArch: noarch
|
||||
|
||||
# Remove python-twisted module, we don't want twisted in RHEL
|
||||
Patch1: pywbem-remove-twisted.patch
|
||||
|
||||
%global _description\
|
||||
A Python library for making CIM (Common Information Model) operations over HTTP\
|
||||
using the WBEM CIM-XML protocol. It is based on the idea that a good WBEM\
|
||||
client should be easy to use and not necessarily require a large amount of\
|
||||
programming knowledge. It is suitable for a large range of tasks from simply\
|
||||
poking around to writing web and GUI applications.\
|
||||
\
|
||||
WBEM, or Web Based Enterprise Management is a manageability protocol, like\
|
||||
SNMP, standardized by the Distributed Management Task Force (DMTF) available\
|
||||
at http://www.dmtf.org/standards/wbem.\
|
||||
\
|
||||
It also provides a Python provider interface, and is the fastest and\
|
||||
easiest way to write providers on the planet.
|
||||
|
||||
%description %_description
|
||||
|
||||
%package -n python3-pywbem
|
||||
Group: Development/Libraries
|
||||
Summary: Python3 WBEM Client and Provider Interface
|
||||
BuildArch: noarch
|
||||
Requires: python3-PyYAML python3-six python3-ply
|
||||
|
||||
%description -n python3-pywbem
|
||||
A WBEM client allows issuing operations to a WBEM server, using the CIM
|
||||
operations over HTTP (CIM-XML) protocol defined in the DMTF standards DSP0200
|
||||
and DSP0201. The CIM/WBEM infrastructure is used for a wide variety of systems
|
||||
management tasks supported by systems running WBEM servers. See WBEM Standards
|
||||
for more information about WBEM.
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
%if 0%{?rhel}
|
||||
%patch1 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
CFLAGS="%{optflags}" %{__python3} setup.py build
|
||||
|
||||
%install
|
||||
|
||||
env PYTHONPATH=%{buildroot}/%{python3_sitelib} %{__python3} setup.py install -O1 --skip-build --root %{buildroot}
|
||||
rm -rf %{buildroot}/usr/bin/*.bat
|
||||
# wbemcli are conflicting with sblim-wbemcli
|
||||
mv -v %{buildroot}/%{_bindir}/wbemcli %{buildroot}/%{_bindir}/pywbemcli
|
||||
sed -i -e 's/wbemcli/pywbemcli/' %{buildroot}/%{_bindir}/pywbemcli
|
||||
mv -v %{buildroot}/%{_bindir}/wbemcli.py %{buildroot}/%{_bindir}/pywbemcli.py
|
||||
|
||||
%files -n python3-pywbem
|
||||
%{python3_sitelib}/*.egg-info
|
||||
%{python3_sitelib}/pywbem/
|
||||
%{_bindir}/mof_compiler
|
||||
%{_bindir}/pywbemcli
|
||||
%{_bindir}/pywbemcli.py
|
||||
%doc README.rst
|
||||
|
||||
%changelog
|
||||
* Wed Nov 6 2019 Tony Asleson <tasleson@redhat.com> - 0.11.0-8
|
||||
- Fix the conflict with sblim-wbemcli: RHBZ #1757855
|
||||
- Corrected warning about multiple file inclusion
|
||||
|
||||
* Wed Jun 13 2018 Petr Viktorin <pviktori@redhat.com> - 0.11.0-7
|
||||
- Drop the python2 subpackage
|
||||
|
||||
* Tue May 22 2018 Josh Boyer <jwboyer@redhat.coml - 0.11.0-6
|
||||
- Remove python-twisted dependency (RHBZ 1561647)
|
||||
|
||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.11.0-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
||||
|
||||
* Thu Jan 04 2018 Lumír Balhar <lbalhar@redhat.com> - 0.11.0-4
|
||||
- Fix directory ownership
|
||||
|
||||
* Thu Oct 19 2017 Gris Ge <fge@redhat.com> - 0.11.0-3
|
||||
- Fedora 25 does not have python2-pip, use python-pip instead.
|
||||
|
||||
* Thu Oct 19 2017 Gris Ge <fge@redhat.com> - 0.11.0-2
|
||||
- Add missing runtime dependency python2-ply and python3-ply
|
||||
|
||||
* Wed Oct 11 2017 Gris Ge <fge@redhat.com> - 0.11.0-1
|
||||
- Upgrade to 0.11.0
|
||||
|
||||
* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.10.0-3
|
||||
- Python 2 binary package renamed to python2-pywbem
|
||||
See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
|
||||
|
||||
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
|
||||
|
||||
* Thu Feb 23 2017 Gris Ge <fge@redhat.com> - 0.10.0-1
|
||||
- Upgrade to 0.10.0
|
||||
|
||||
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.1-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
|
||||
|
||||
* Thu Dec 22 2016 Miro Hrončok <mhroncok@redhat.com> - 0.9.1-2
|
||||
- Rebuild for Python 3.6
|
||||
|
||||
* Thu Dec 08 2016 Gris Ge <fge@redhat.com> 0.9.1-1
|
||||
- Upgrade to 0.9.1
|
||||
|
||||
* Wed Oct 19 2016 Gris Ge <fge@redhat.com> 0.9.0-3
|
||||
- Add missing runtime dependency python3-six and python-six
|
||||
|
||||
* Tue Sep 27 2016 Gris Ge <fge@redhat.com> 0.9.0-2
|
||||
- Add missing runtime dependency python3-PyYAML and PyYAML.
|
||||
|
||||
* Wed Sep 14 2016 Gris Ge <fge@redhat.com> - 0.9.0-1
|
||||
- Upgrade to 0.9.0 and add python3 pacakge -- python3-pywbem.
|
||||
|
||||
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-30.20131121svn626
|
||||
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
|
||||
|
||||
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-29.20131121svn626
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
|
||||
|
||||
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-28.20131121svn626
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
|
||||
|
||||
* Mon Jun 30 2014 Toshio Kuratomi <toshio@fedoraproject.org> - 0.7.0-27.svn
|
||||
- Replace python-setuptools-devel BR with python-setuptools
|
||||
|
||||
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-26.20131121svn626
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
|
||||
|
||||
* Mon Feb 24 2014 Michal Minar <miminar@redhat.com> 0.7.0-25.20131121svn656
|
||||
- Fixed local authentication under root.
|
||||
|
||||
* Thu Jan 23 2014 Michal Minar <miminar@redhat.com> 0.7.0-24.20131121svn656
|
||||
- Added support for non-ascii strings.
|
||||
|
||||
* Fri Jan 03 2014 Michal Minar <miminar@redhat.com> 0.7.0-23.20131121svn656
|
||||
- Skip hostname check when no verification is desired.
|
||||
|
||||
* Fri Dec 27 2013 Michal Minar <miminar@redhat.com> 0.7.0-22.20131121svn656
|
||||
- Work around M2Crypto's inability to handle unicode strings.
|
||||
|
||||
* Wed Dec 18 2013 Michal Minar <miminar@redhat.com> 0.7.0-21.20131121svn656
|
||||
- Adjusted default certificates paths searched for cert validation.
|
||||
|
||||
* Tue Dec 17 2013 Michal Minar <miminar@redhat.com> 0.7.0-20.20131121svn656
|
||||
- Tweaked the ssl_verify_host patch.
|
||||
|
||||
* Mon Dec 16 2013 Michal Minar <miminar@redhat.com> 0.7.0-18.20131121svn656
|
||||
- Fixes TOCTOU vulnerability in certificate validation.
|
||||
- Resolves: rhbz#1026891
|
||||
|
||||
* Thu Nov 21 2013 Jan Safranek <jsafrane@redhat.com> 0.7.0-17.20131121svn626
|
||||
- Added '-d' option to /usr/bin/mofcomp to just check mof files and their
|
||||
includes.
|
||||
|
||||
* Tue Aug 27 2013 Jan Safranek <jsafrane@redhat.com> 0.7.0-16.20130827svn625
|
||||
- Fixed parsing of IPv6 addresses.
|
||||
|
||||
* Fri Aug 09 2013 Michal Minar <miminar@redhat.com> 0.7.0-15.20130723svn623
|
||||
- Fixed certificate verification issue.
|
||||
|
||||
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-14.20130723svn623
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
|
||||
|
||||
* Wed Jul 24 2013 <jsafrane@redhat.com> 0.7.0-13.20130702svn623
|
||||
- Added subpackage with Twisted module to reduce dependencies of the main package.
|
||||
|
||||
* Tue Jul 23 2013 <jsafrane@redhat.com> 0.7.0-12.20130702svn623
|
||||
- Fixed checking of CIMVERSION in CIM-XML.
|
||||
|
||||
* Tue Jul 2 2013 Jan Safranek <jsafrane@redhat.com> 0.7.0-11.20130702svn622
|
||||
- New upstream version.
|
||||
- Method parameters are now case-insensitive.
|
||||
|
||||
* Fri May 24 2013 Tomas Bzatek <tbzatek@redhat.com> 0.7.0-10.20130411svn619
|
||||
- Fix module imports in /usr/bin/mofcomp
|
||||
|
||||
* Thu Apr 11 2013 Jan Safranek <jsafrane@redhat.com> 0.7.0-9.20130411svn619
|
||||
- New upstream version.
|
||||
- Removed debug 'print' statements.
|
||||
|
||||
* Mon Jan 28 2013 Michal Minar <miminar@redhat.com> 0.7.0-8.20130128svn613
|
||||
- New upstream version.
|
||||
- Added post-release snapshot version info.
|
||||
- Removed obsoleted BuildRoot,
|
||||
|
||||
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
|
||||
|
||||
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
|
||||
|
||||
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.0-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||
|
||||
* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 0.7.0-4
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
|
||||
|
||||
* Fri Jan 01 2010 David Nalley <david@gnsa.us> 0.7.0-3
|
||||
- refined requires for epel compat
|
||||
* Sun Jun 28 2009 David Nalley <david@gnsa.us> 0.7.0-2
|
||||
- Added some verbiage regarding what WBEM is and expanding WBEM and CIM acronyms
|
||||
- Added python-twisted as a dependency
|
||||
* Thu Jun 25 2009 David Nalley <david@gnsa.us> 0.7.0-1
|
||||
- Initial packaging
|
||||
|
Loading…
Reference in new issue