Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (62 sloc) 2.95 KB
# Copyright (C) 2012 Javi Roman <>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <>.
# This simple CIM client invokes the Widget CIM Provider. In particular
# the add() method.
# -> SFCB CIMON -> /usr/lib/cmpi/
import sys
import pywbem
if len(sys.argv) < 3:
print """Usage: %s operand-1 operand-2
Example: %s 10 20""" % (sys.argv[0], sys.argv[0])
url = ""
username = None
password = None
# The first thing to do for any CIM transaction is to open a PyWBEM connection.
# A connection is represented as an instance of a WBEMConnection class.
# The first parameter to WBEMConnection is a URL to the CIM Server.
# The second parameter is a two-tuple containing the username and password.
# The URL will probably start with "http", or "https".
# Or, you can also supply an absolute path to a Unix Domain Socket:
# cliconn = pywbem.WBEMConnection('/var/run/tog-pegasus/cimxml.socket')
cliconn = pywbem.WBEMConnection(url, (username, password))
cliconn.debug = True
# The ExecQuery operations executes a query against target namespace:
# ExecQuery <objec>.ExecQuery([IN] string QueryyLanguage, [IN]string Query)
# The QueryLanguage input parameter defines the query language in which the query parameter
# is expressed. CIM and WBEM support a query mechanism that is used to select sets of
# properties from CIM object instances. The CIM Server (CIMON) implements a Query Engine
# to parse the query and evalute its results. The CIM Query Language used in the queries
# is based on concepts of SQL-92, and W3C XML Query.
# The CIM Query Language (CQL) is specified in "CIM Operations over HTTP Specification - DSP0200".
# The support of queries with the semantics Select-From-Where is called WQL - WBEM Query Language.
insts = cliconn.ExecQuery('WQL', 'select * from KC_Widget')
# The invocation of CIM method (an extrinsic method) with the following method parameters:
# string Method_Name - The name of the method that will be invoked.
# pywbem.CIMInstanceName Object_Name - A reference to a CIM instance. The InstanceName or
# ClassName of the object on which the method is invoked.
ret = cliconn.InvokeMethod('Add',
print "result: %s" % ret[0]
print "error: %s" % ret[1]