[PATCH] fix spec file for sblim-sfcb and systemctl
by Daniel Veillard
Right now the spec file is completely tied to tog-pegasus,
this should allow the spec file to be compatible with sblim-sfcb
too. This also switches to systemctl which is now used in Fedora.
I would actually like some feedback on the patch if someone
has an environment to test with sblim-sfcb
Also I noted that if I built the package with sblim-sfcb installed
it failed in the make install phase with the following error:
----------------------------------------------------------
/bin/sh /u/veillard/rpms/BUILD/libvirt-cim-0.6.1/install-sh -c -m 644 -t
"/u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim"
./schema/RegisteredProfile.registration
./schema/ElementConformsToProfile.registration
./schema/ReferencedProfile.registration
if [[ sfcb != pegasus ]]; then \
sed -i '/^# --/,/^# --!/d'
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/RegisteredProfile.registration
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/ElementConformsToProfile.registration
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/ReferencedProfile.registration;
\
fi
sed: can't read
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/RegisteredProfile.registration:
No such file or directory
sed: can't read
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/ElementConformsToProfile.registration:
No such file or directory
sed: can't read
.//u/veillard/rpms/BUILDROOT/libvirt-cim-0.6.1-2.fc18.x86_64/usr/share/libvirt-cim/ReferencedProfile.registration:
No such file or directory
make[2]: *** [install-data-local] Error 2
make[2]: Leaving directory `/home/veillard/rpms/BUILD/libvirt-cim-0.6.1'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/veillard/rpms/BUILD/libvirt-cim-0.6.1'
make: *** [install-recursive] Error 1
----------------------------------------------------------
Any idea ?
thanks,
Daniel
--- libvirt-cim.spec 2012-02-10 13:49:31.679905149 +0800
+++ libvirt-cim.spec 2012-03-09 14:41:45.617781910 +0800
@@ -12,7 +12,8 @@
Requires: libxml2 >= 2.6.0
Requires: libvirt >= 0.9.0
Requires: unzip
-Requires: tog-pegasus
+# either tog-pegasus or sblim-sfcb should provide cim-server
+Requires: cim-server
BuildRequires: libcmpiutil >= 0.5.4
BuildRequires: tog-pegasus-devel
BuildRequires: libvirt-devel >= 0.9.0
@@ -85,8 +86,18 @@
%{_datadir}/%{name}/install_base_schema.sh %{_datadir}/%{name}
-/etc/init.d/tog-pegasus condrestart
+if [ "`systemctl is-active tog-pegasus.service`" = "active" ]
+then
+ systemctl restart tog-pegasus.service
+fi
+
+if [ "`systemctl is-active sblim-sfcb.service`" = "active" ]
+then
+ systemctl restart sblim-sfcb.service
+fi
+if [ -x /usr/sbin/cimserver ]
+then
%{_datadir}/%{name}/provider-register.sh -t pegasus \
-n root/virt \
-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
@@ -102,8 +113,29 @@
%{_datadir}/%{name}/provider-register.sh -t pegasus \
-n root/cimv2\
-r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
+fi
+if [ -x /usr/sbin/sfcbd ]
+then
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/interop \
+ -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/PG_InterOp \
+ -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/cimv2\
+ -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
+fi
%preun
+if [ -x /usr/sbin/cimserver ]
+then
%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
-n root/virt \
-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
@@ -116,6 +148,22 @@
%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
-n root/cimv2 \
-r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
+fi
+if [ -x /usr/sbin/sfcbd ]
+then
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/interop \
+ -r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/PG_InterOp \
+ -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/cimv2 \
+ -r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
+fi
%postun -p /sbin/ldconfig
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 2 months
[PATCHv2 0/3] Make Shutdown and Reboot state changes jobs
by Eduardo Lima (Etrunko)
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
This code is based on the VSMigrationService for the job creation and on
ComputerSystemIndication for the job thread, which will listen for the
respective domain event to mark the job as finished.
I am still not able to test this feature in my environment, every call to
CBGetInstance fails with code error 100. This is happening in other places of
the codebase, not only the ComputerSystem provider, but also ElementConfors,
for instance. Please use the test case send in previous email for reference.
Differences from v1:
- Fix conditional causing Reqstate not being set
- Fix domain event id for shutdown
- Now instead of using the domain events for both shutdown and reboot, there is
an intermediate patch, that will deal with the shutdown case by polling for
the domain state until it reflects the desired state.
This workaround won't work for the reboot case, because is is not possible to
monitor the reboot event if not using the domain event callbacks. The third
patch of the series contains the complete solution for both cases.
Eduardo Lima (Etrunko) (3):
VSMigrationService: Move job state definitions to svpc_types.h
ComputerSystem: Make Shutdown state change a job
ComputerSystem: Reboot state change also a job
schema/ComputerSystem.mof | 9 ++
src/Virt_ComputerSystem.c | 304 +++++++++++++++++++++++++++++++++++++++--
src/Virt_VSMigrationService.c | 14 +--
src/svpc_types.h | 13 ++
4 files changed, 321 insertions(+), 19 deletions(-)
--
1.7.7.6
12 years, 2 months
cimtest - add SSL support to indication_tester.py
by Dave Heller
In the XenKvmLib directory in cimtest, there is a "indication_tester.py"
module that is both a command-line program and a component of cimtest. Here
is a proposed patch that adds new functionality to the cmdline interface
while preserving compatibility with cimtest.
The most significant new feature is support for SSL indications. There is
also a new --trigger mode to generate a test indication using the SFCB
Test_Indication provider. This allows the script to act as a completely
stand-alone test tool (for SFCB) without the user having to rely on the
"xmltest" files and wbemcat.
Below is a complete list of the new features. I am looking for feedback and
potentially, the correct process to check into "cimtest".
Best regards,
Dave Heller
New features:
- Supports https indications. Adds new options --certFile and --keyFile to
specify server certificate and private key for the SSL enabled indication
listener.
- Supports verification of indication sender (i.e. CIMOM) SSL certificate.
New option --trustStore is used to specify the CA certificate file;
alternately the --noverify option may be used to disable peer certificate
checking.
- Adds new option --dest to specify handler destination. This same URL is
used to register the subscription (at the CIMOM) and start the indication
listener (locally). Via --dest one can specify scheme (http or https), IP or
hostname, listener port, and optionally userid:password, all in a single
parameter.
- New option --interop can be used to override the default interop namespace
(i.e root/interop vs. root/PG_InterOp) allowing easy support for both
openpegasus and sfcb.
- Modifies the default value of existing --ns option (indication namespace);
if not specified the indication namespace will default to the same value as
the interop namespace.
- New option --verbose can be used to display debugging info, such as
details (subject, issuer) of the indication sender cert (when peer
verification enabled).
- Improved error handling (i.e. catch exceptions) for the following
operations: starting listener locally, receiving incoming indications, POST
operations (i.e. subscribe, unsubscribe) to CIMOM.
- New option --trigger can be used to send a request to CIMOM to trigger an
indication via the SFCB Test_Indication provider.
Limitations:
- Not tested on IPv6.
- The --trigger option currently only supports the sfcb Test_Indication
provider. (It could be made more general by allowing the XML send to
support an arbitrary namespace, classname and method call. Open to
suggestions here.)
--- indication_tester.orig.py 2012-03-05 23:12:08.000000000 -0500
+++ indication_tester.py 2012-03-19 13:12:55.000000000 -0400
@@ -1,18 +1,25 @@
#!/usr/bin/python
-# Copyright IBM Corp. 2007
+# Copyright IBM Corp. 2007-2012
#
# indication_tester.py - Tool for testing indication subscription and
# delivery against a CIMOM
# Author: Dan Smith <danms(a)us.ibm.com>
+# SSL support added by Dave Heller <hellerda(a)us.ibm.com>
import sys
from optparse import OptionParser
-import BaseHTTPServer
+from urlparse import urlparse, urlunparse
+from xml.dom.minidom import parse, parseString
import httplib
import base64
-from xml.dom.minidom import parse, parseString
+import errno, os, re
+import socket
+from SocketServer import BaseServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
+from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
+from OpenSSL import SSL
-def filter_xml(name, type, ns, sysname):
+def filter_xml(name, type, ns, sysname, interopNS):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -20,8 +27,8 @@
<SIMPLEREQ>
<IMETHODCALL NAME="CreateInstance">
<LOCALNAMESPACEPATH>
- <NAMESPACE NAME="root"/>
- <NAMESPACE NAME="PG_InterOp"/>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
</LOCALNAMESPACEPATH>
<IPARAMVALUE NAME="NewInstance">
<INSTANCE CLASSNAME="CIM_IndicationFilter">
@@ -53,9 +60,9 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>
- """ % (sysname, name, type, ns)
+ """ % (interopNS[0], interopNS[1], sysname, name, type, ns)
-def handler_xml(name, port, sysname):
+def handler_xml(name, destUrl, sysname, interopNS):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -63,8 +70,8 @@
<SIMPLEREQ>
<IMETHODCALL NAME="CreateInstance">
<LOCALNAMESPACEPATH>
- <NAMESPACE NAME="root"/>
- <NAMESPACE NAME="PG_InterOp"/>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
</LOCALNAMESPACEPATH>
<IPARAMVALUE NAME="NewInstance">
<INSTANCE CLASSNAME="CIM_IndicationHandlerCIMXML">
@@ -81,7 +88,7 @@
<VALUE>%sHandler</VALUE>
</PROPERTY>
<PROPERTY NAME="Destination" TYPE="string">
- <VALUE>http://localhost:%i</VALUE>
+ <VALUE>%s</VALUE>
</PROPERTY>
</INSTANCE>
</IPARAMVALUE>
@@ -89,9 +96,9 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>
- """ % (sysname, name, port)
+ """ % (interopNS[0], interopNS[1], sysname, name, destUrl)
-def subscription_xml(name, sysname):
+def subscription_xml(name, sysname, interopNS):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -99,8 +106,8 @@
<SIMPLEREQ>
<IMETHODCALL NAME="CreateInstance">
<LOCALNAMESPACEPATH>
- <NAMESPACE NAME="root"/>
- <NAMESPACE NAME="PG_InterOp"/>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
</LOCALNAMESPACEPATH>
<IPARAMVALUE NAME="NewInstance">
<INSTANCE CLASSNAME="CIM_IndicationSubscription">
@@ -167,9 +174,9 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>
- """ % (sysname, name, sysname, name)
+ """ % (interopNS[0], interopNS[1], sysname, name, sysname, name)
-def delete_inst_xml(name, type, sysname, inst_name):
+def delete_inst_xml(name, type, sysname, inst_name, interopNS):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -177,8 +184,8 @@
<SIMPLEREQ>
<IMETHODCALL NAME="DeleteInstance">
<LOCALNAMESPACEPATH>
- <NAMESPACE NAME="root"/>
- <NAMESPACE NAME="PG_InterOp"/>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
</LOCALNAMESPACEPATH>
<IPARAMVALUE NAME="InstanceName">
<INSTANCENAME CLASSNAME="CIM_Indication%s">
@@ -200,9 +207,9 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>;
- """ % (type, sysname, type, inst_name);
+ """ % (interopNS[0], interopNS[1], type, sysname, type, inst_name);
-def delete_sub_xml(name, sysname):
+def delete_sub_xml(name, sysname, interopNS):
return """
<?xml version="1.0" encoding="utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
@@ -210,8 +217,8 @@
<SIMPLEREQ>
<IMETHODCALL NAME="DeleteInstance">
<LOCALNAMESPACEPATH>
- <NAMESPACE NAME="root"/>
- <NAMESPACE NAME="PG_InterOp"/>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
</LOCALNAMESPACEPATH>
<IPARAMVALUE NAME="InstanceName">
<INSTANCENAME CLASSNAME="CIM_IndicationSubscription">
@@ -273,7 +280,45 @@
</SIMPLEREQ>
</MESSAGE>
</CIM>;
- """ % (sysname, name, sysname, name)
+ """ % (interopNS[0], interopNS[1], sysname, name, sysname, name)
+
+def trigger_xml(type, interopNS):
+ return """
+ <?xml version="1.0" encoding="utf-8"?>
+ <CIM CIMVERSION="2.0" DTDVERSION="2.0">
+ <MESSAGE ID="4711" PROTOCOLVERSION="1.0">
+ <SIMPLEREQ>
+ <METHODCALL NAME="SendTestIndication">
+ <LOCALCLASSPATH>
+ <LOCALNAMESPACEPATH>
+ <NAMESPACE NAME="%s"/>
+ <NAMESPACE NAME="%s"/>
+ </LOCALNAMESPACEPATH>
+ <CLASSNAME NAME="%s"/>
+ </LOCALCLASSPATH>
+ </METHODCALL>
+ </SIMPLEREQ>
+ </MESSAGE>
+ </CIM>
+ """ % (interopNS[0], interopNS[1], type)
+ # FIXME: this should really use indication NS, not interop NS.
+
+def update_url_port(parsedUrl, port):
+ # Must manually reconstruct netloc to update the port value.
+ if isinstance(parsedUrl.username, basestring):
+ if isinstance(parsedUrl.password, basestring):
+ netloc = "%s:%s@%s:%s" % (parsedUrl.username, parsedUrl.password,
+ parsedUrl.hostname, port)
+ else:
+ netloc = "%s@%s:%s" % (parsedUrl.username,
+ parsedUrl.hostname, port)
+ else:
+ netloc = "%s:%s" % (parsedUrl.hostname, port)
+
+ # Reassemble url with the updated netloc. return a string.
+ return urlunparse((parsedUrl.scheme, netloc,
+ parsedUrl.path, parsedUrl.params,
+ parsedUrl.query, parsedUrl.fragment))
class CIMIndication:
def __init__(self, xmldata):
@@ -286,50 +331,135 @@
def __str__(self):
return self.name
-class CIMSocketHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+def socket_handler_wrapper(*parms):
+ try:
+ CIMSocketHandler(*parms)
+ except Exception as e:
+ print "SSL error: %s" % str(e)
+
+class CIMSocketHandler(SimpleHTTPRequestHandler):
+ def setup(self):
+ self.connection = self.request
+ self.rfile = socket._fileobject(self.request, "rb", self.rbufsize)
+ self.wfile = socket._fileobject(self.request, "wb", self.wbufsize)
+
def do_POST(self):
length = self.headers.getheader('content-length')
data = self.rfile.read(int(length))
indication = CIMIndication(data)
- print "Got indication: %s" % indication
+ print "Got indication: %s from %s" % (indication,
self.client_address)
if self.server.print_ind:
- print "%s\n\n" % data
+ print "%s\n" % data
self.server.indications.append(indication)
+ # Silence the unwanted log output from send_response()
+ realStderr = sys.stderr
+ sys.stderr = open(os.devnull,'a')
+ self.send_response(200)
+ sys.stderr = realStderr
+
+class SecureHTTPServer(HTTPServer):
+ def __init__(self, server_address, HandlerClass):
+ BaseServer.__init__(self, server_address, HandlerClass)
+
+ def verify_cb(conn, cert, errnum, depth, ok):
+ if options.verbose:
+ print('Verify peer certificate chain: level %d:' % depth)
+ print('subject=%s' % cert.get_subject())
+ print('issuer =%s' % cert.get_issuer())
+ return ok
+
+ ctx = SSL.Context(SSL.SSLv23_METHOD)
+ #ctx.use_certificate_file(options.certFile)
+ ctx.use_certificate_chain_file(options.certFile)
+ ctx.use_privatekey_file(options.keyFile)
+
+ if options.noverify:
+ ctx.set_verify(SSL.VERIFY_NONE, verify_cb)
+ else:
+ #ctx.set_verify(SSL.VERIFY_PEER, verify_cb)
+ ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
+ verify_cb)
+ ctx.load_verify_locations(options.trustStore)
+
+ self.socket = SSL.Connection(ctx,
socket.socket(self.address_family,
+ self.socket_type))
+ self.server_bind()
+ self.server_activate()
+# The param defaults allow new options from main() w/o losing compat w/
cimtest.
class CIMIndicationSubscription:
- def __init__(self, name, typ, ns, print_ind, sysname, port=0):
+ def __init__(self, name, typ, ns, print_ind, sysname, port=0,
+ interopNS=('root','PG_InterOp'),
destUrl="http://localhost:8000",
+ triggermode=False):
self.name = name
self.type = typ
self.ns = ns
self.sysname = sysname
+ self.interopNS = interopNS
+ self.print_ind = print_ind
+
+ # We do not want to open a listener socket in trigger mode.
+ if triggermode:
+ self.trigger_xml = trigger_xml(typ, interopNS)
+ return
+
+ parsedUrl = urlparse(destUrl)
+
+ # Increment the listener port by the offset value.
+ if isinstance(parsedUrl.port, int):
+ listenerPort = parsedUrl.port + port
+ else:
+ listenerPort = 8000 + port
+
+ destUrl = update_url_port(parsedUrl, listenerPort)
+
+ try:
+ if parsedUrl.scheme == "http":
+ self.server = HTTPServer((parsedUrl.hostname,
+ listenerPort),
+ CIMSocketHandler)
+ elif parsedUrl.scheme == "https":
+ self.server = SecureHTTPServer((parsedUrl.hostname,
+ listenerPort),
+ socket_handler_wrapper)
+ except IOError as e:
+ print "Error creating listener socket: %s" % str(e)
+ exit(e.errno)
- self.port = 8000 + port
- self.server = BaseHTTPServer.HTTPServer(('', self.port),
- CIMSocketHandler)
self.server.print_ind = print_ind
self.server.indications = []
- self.filter_xml = filter_xml(name, typ, ns, sysname)
- self.handler_xml = handler_xml(name, self.port, sysname)
- self.subscription_xml = subscription_xml(name, sysname)
+ self.filter_xml = filter_xml(name, typ, ns, sysname, interopNS)
+ self.handler_xml = handler_xml(name, destUrl, sysname, interopNS)
+ self.subscription_xml = subscription_xml(name, sysname, interopNS)
def __do_cimpost(self, conn, body, method, auth_hdr=None):
headers = {"CIMOperation" : "MethodCall",
"CIMMethod" : method,
- "CIMObject" : "root/PG_Interop",
+ #"CIMObject" : "root/PG_Interop",
+ "CIMObject" : "%s/%s" % self.interopNS,
"Content-Type" : 'application/xml; charset="utf-8"'}
if auth_hdr:
headers["Authorization"] = "Basic %s" % auth_hdr
- conn.request("POST", "/cimom", body, headers)
- resp = conn.getresponse()
- if not resp.getheader("content-length"):
- raise Exception("Request Failed: %d %s" %
- (resp.status, resp.reason))
-
- resp.read()
+ try:
+ conn.request("POST", "/cimom", body, headers)
+ resp = conn.getresponse()
+ if not resp.getheader("content-length"):
+ raise Exception("Request Failed: %d %s" %
+ (resp.status, resp.reason))
+ except IOError as e:
+ print "Error connecting to CIMOM: %s" % str(e)
+ exit(e.errno)
+
+ if self.print_ind:
+ print "Reply from CIMOM:"
+ #print resp.msg
+ print resp.read()
+ else:
+ resp.read()
def subscribe(self, url, cred=None):
self.conn = httplib.HTTPConnection(url)
@@ -353,26 +483,39 @@
else:
auth_hdr = None
- xml = delete_sub_xml(self.name, self.sysname)
+ xml = delete_sub_xml(self.name, self.sysname, self.interopNS)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
xml = delete_inst_xml(self.name, "HandlerCIMXML", self.sysname,
- "%sHandler" % self.name)
+ "%sHandler" % self.name, self.interopNS)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
xml = delete_inst_xml(self.name, "Filter", self.sysname,
- "%sFilter" % self.name)
+ "%sFilter" % self.name, self.interopNS)
self.__do_cimpost(self.conn, xml,
"DeleteInstance", auth_hdr)
-def dump_xml(name, typ, ns, sysname):
- filter_str = filter_xml(name, typ, ns, sysname)
- handler_str = handler_xml(name, 8000, sysname)
- subscript_str = subscription_xml(name, sysname)
- del_filter_str = delete_inst_xml(name, "Filter", sysname, "%sFilter" %
name)
+ def trigger(self, url, cred=None):
+ self.conn = httplib.HTTPConnection(url)
+ if cred:
+ (u, p) = cred
+ auth_hdr = base64.b64encode("%s:%s" % (u, p))
+ else:
+ auth_hdr = None
+
+ self.__do_cimpost(self.conn, self.trigger_xml,
+ "SendTestIndication", auth_hdr)
+
+def dump_xml(name, typ, ns, sysname, interopNS, destUrl):
+ filter_str = filter_xml(name, typ, ns, sysname, interopNS)
+ handler_str = handler_xml(name, destUrl, sysname, interopNS)
+ subscript_str = subscription_xml(name, sysname, interopNS)
+ del_filter_str = delete_inst_xml(name, "Filter", sysname, "%sFilter" %
name,
+ interopNS)
del_handler_str = delete_inst_xml(name, "HandlerCIMXML", sysname,
- "%sHandler" % name)
- del_subscript_str = delete_sub_xml(name, sysname)
+ "%sHandler" % name, interopNS)
+ del_subscript_str = delete_sub_xml(name, sysname, interopNS)
+ trigger_str = trigger_xml(typ, interopNS)
print "CreateFilter:\n%s\n" % filter_str
print "DeleteFilter:\n%s\n" % del_filter_str
@@ -380,15 +523,20 @@
print "DeleteHandler:\n%s\n" % del_handler_str
print "CreateSubscription:\n%s\n" % subscript_str
print "DeleteSubscription:\n%s\n" % del_subscript_str
+ print "Indication trigger:\n%s\n" % trigger_str
def main():
usage = "usage: %prog [options] provider\nex: %prog
CIM_InstModification"
parser = OptionParser(usage)
+ # FIXME: SecureHTTPServer still relies on this, need a better way.
+ global options
+
parser.add_option("-u", "--url", dest="url", default="localhost:5988",
help="URL of CIMOM to connect to (host:port)")
- parser.add_option("-N", "--ns", dest="ns", default="root/virt",
- help="Namespace (default is root/virt)")
+ parser.add_option("-N", "--ns", dest="ns",
+ help="Namespace in which the register the indication
\
+ (default is the same value as the interop
namespace)")
parser.add_option("-n", "--name", dest="name", default="Test",
help="Name for filter, handler, subscription \
(default: Test)")
@@ -398,16 +546,41 @@
parser.add_option("-p", "--print-ind", dest="print_ind", default=False,
action="store_true",
help="Print received indications to stdout.")
+ parser.add_option("-v", "--verbose", dest="verbose", default=False,
+ action="store_true",
+ help="Print addtional debug info.")
parser.add_option("-U", "--user", dest="username", default=None,
- help="HTTP Auth username")
+ help="HTTP Auth username (CIMOM)")
parser.add_option("-P", "--pass", dest="password", default=None,
- help="HTTP Auth password")
+ help="HTTP Auth password (CIMOM)")
parser.add_option("--port", dest="port", default=0, type=int,
help="Port increment value (server default: 8000)")
+ parser.add_option("--dest", dest="destUrl", default="localhost:8000",
+ help="URL of destination handler \
+ (default: http://localhost:8000)")
+ parser.add_option("--certFile", dest="certFile", default=None,
+ help="File containing the local certificate to use")
+ parser.add_option("--keyFile", dest="keyFile", default=None,
+ help="File containing private key for local cert \
+ (if none provided, assume key is in the certFile)")
+ parser.add_option("--trustStore", dest="trustStore", default=None,
+ help="File containing trusted certificates for \
+ remote endpoint verification")
+ parser.add_option("--noverify", dest="noverify", default=False,
+ action="store_true",
+ help="Skip verification of remote endpoint
certificate \
+ for incoming https indications")
+ parser.add_option("-i", "--interop", dest="interop",
+ default="root/interop",
+ help="Interop namespace name (default:
root/interop)")
+ parser.add_option("-t", "--trigger", dest="trigger", default=False,
+ action="store_true",
+ help="Trigger mode: send a request to CIMOM to
trigger \
+ an indication via a method call ")
(options, args) = parser.parse_args()
- if len(args) == 0:
+ if not options.trigger and len(args)==0:
print "Fatal: no indication type provided."
sys.exit(1)
@@ -421,20 +594,75 @@
else:
sysname = options.url
+ if "/" in options.interop:
+ options.interopNS = tuple(options.interop.split("/"))
+ else:
+ options.interopNS = ("root", options.interop)
+
+ # If no value provided for indication NS, default is same as interopNS.
+ if not options.ns:
+ options.ns = "%s/%s" % options.interopNS
+
+ if options.verbose:
+ print "Interop namespace = %s/%s" % options.interopNS
+ print "Indication namespace = %s" % options.ns
+
+ # If url does not begin with http or https, assume http.
+ parsedUrl = urlparse(options.destUrl)
+ if not re.search(parsedUrl.scheme, "https"):
+ destUrl = "http://" + options.destUrl
+ else:
+ destUrl = options.destUrl
+
+ if parsedUrl.scheme == "https":
+ if not options.trustStore and not options.noverify:
+ print "Error: must provide --trustStore or --noverify with
https."
+ sys.exit(1)
+ elif options.trustStore and options.noverify:
+ print "Error: options --trustStore and --noverify are
exclusive."
+ sys.exit(1)
+ if not options.certFile:
+ print "Error: no certificate file provided."
+ sys.exit(1)
+ elif not options.keyFile:
+ print "No keyFile provided; assuming private key \
+ contained in certFile."
+ options.keyFile = options.certFile
+
if options.dump:
- dump_xml(options.name, args[0], options.ns, sysname)
+ if isinstance(parsedUrl.port, int):
+ listenerPort = parsedUrl.port + options.port
+ else:
+ listenerPort = 8000 + options.port
+
+ destUrl = update_url_port(parsedUrl, listenerPort)
+ dump_xml(options.name, args[0], options.ns, sysname,
options.interopNS,
+ destUrl)
+ sys.exit(0)
+
+ # Trigger mode: currently only supports SFCB Test_Indication provider.
+ if options.trigger:
+ classname = "Test_Indication"
+ sub = CIMIndicationSubscription(options.name, classname,
options.ns,
+ options.print_ind, sysname,
options.port,
+ options.interopNS, destUrl, True)
+ print "Triggering indication for %s" % classname
+ sub.trigger(options.url, auth)
sys.exit(0)
sub = CIMIndicationSubscription(options.name, args[0], options.ns,
- options.print_ind, sysname,
options.port)
+ options.print_ind, sysname,
options.port,
+ options.interopNS, destUrl)
+
+ print "Creating subscription for %s" % args[0]
sub.subscribe(options.url, auth)
print "Watching for %s" % args[0]
try:
sub.server.serve_forever()
- except KeyboardInterrupt,e:
- sub.unsubscribe(auth)
+ except KeyboardInterrupt as e:
print "Cancelling subscription for %s" % args[0]
+ sub.unsubscribe(auth)
if __name__=="__main__":
sys.exit(main())
12 years, 5 months
[PATCH v2] Improve support with sblim-sfcb
by Daniel Veillard
add schemas (de)registration with sfcb if found
in v2:
- rebased
- fixed patch to apply to libvirt-cim.spec.in
- remove spurious changes coming from Fedora
Signed-off-by: Daniel Veillard <veillard(a)redhat.com>
diff --git a/libvirt-cim.spec.in b/libvirt-cim.spec.in
index d78eee7..571ee91 100644
--- a/libvirt-cim.spec.in
+++ b/libvirt-cim.spec.in
@@ -87,6 +87,8 @@ rm -fr $RPM_BUILD_ROOT
/etc/init.d/tog-pegasus condrestart
+if [ -x /usr/sbin/cimserver ]
+then
%{_datadir}/%{name}/provider-register.sh -t pegasus \
-n @CIM_VIRT_NS@ \
-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
@@ -102,8 +104,29 @@ rm -fr $RPM_BUILD_ROOT
%{_datadir}/%{name}/provider-register.sh -t pegasus \
-n root/cimv2\
-r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
+fi
+if [ -x /usr/sbin/sfcbd ]
+then
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/interop \
+ -r %{INTEROP_REG} -m %{INTEROP_MOF} -v >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/PG_InterOp \
+ -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} -v >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -t sfcb \
+ -n root/cimv2\
+ -r %{CIMV2_REG} -m %{CIMV2_MOF} -v >/dev/null 2>&1 || true
+fi
%preun
+if [ -x /usr/sbin/cimserver ]
+then
%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
-n @CIM_VIRT_NS@ \
-r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
@@ -116,6 +139,22 @@ rm -fr $RPM_BUILD_ROOT
%{_datadir}/%{name}/provider-register.sh -d -t pegasus \
-n root/cimv2 \
-r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
+fi
+if [ -x /usr/sbin/sfcbd ]
+then
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/virt \
+ -r %{REGISTRATION} -m %{SCHEMA} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/interop \
+ -r %{INTEROP_REG} -m %{INTEROP_MOF} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/PG_InterOp \
+ -r %{PGINTEROP_REG} -m %{PGINTEROP_MOF} >/dev/null 2>&1 || true
+%{_datadir}/%{name}/provider-register.sh -d -t sfcb \
+ -n root/cimv2 \
+ -r %{CIMV2_REG} -m %{CIMV2_MOF} >/dev/null 2>&1 || true
+fi
%postun -p /sbin/ldconfig
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 5 months
[PATCH] Fix possible memory leaks
by Eduardo Lima (Etrunko)
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
Another Coverity scan report provided by Red Hat:
https://bugzilla.redhat.com/show_bug.cgi?id=750418#c10
Error: RESOURCE_LEAK:
Virt_AppliedFilterList.c:608: alloc_arg: Calling allocation function "get_dominfo" on "dominfo".
device_parsing.c:1251: alloc_arg: "get_dominfo_from_xml" allocates memory that is stored into "*dominfo".
device_parsing.c:1205: alloc_fn: Storage is returned from allocation function "calloc".
device_parsing.c:1205: var_assign: Assigning: "*dominfo" = "calloc(1UL, 216UL)".
device_parsing.c:1209: noescape: Variable "*dominfo" is not freed or pointed-to in function "_get_dominfo".
device_parsing.c:1168:57: noescape: "_get_dominfo" does not free or save its pointer parameter "dominfo".
Virt_AppliedFilterList.c:644: leaked_storage: Variable "dominfo" going out of scope leaks the storage it points to.
Error: RESOURCE_LEAK:
Virt_AppliedFilterList.c:485: alloc_arg: Calling allocation function "get_dominfo" on "dominfo".
device_parsing.c:1251: alloc_arg: "get_dominfo_from_xml" allocates memory that is stored into "*dominfo".
device_parsing.c:1205: alloc_fn: Storage is returned from allocation function "calloc".
device_parsing.c:1205: var_assign: Assigning: "*dominfo" = "calloc(1UL, 216UL)".
device_parsing.c:1209: noescape: Variable "*dominfo" is not freed or pointed-to in function "_get_dominfo".
device_parsing.c:1168:57: noescape: "_get_dominfo" does not free or save its pointer parameter "dominfo".
Virt_AppliedFilterList.c:529: leaked_storage: Variable "dominfo" going out of scope leaks the storage it points to.
Error: RESOURCE_LEAK:
misc_util.c:275: alloc_arg: Calling allocation function "get_domain_list" on "list".
cs_util_instance.c:52: alloc_fn: Storage is returned from allocation function "calloc".
cs_util_instance.c:52: var_assign: Assigning: "list" = "calloc(n_names + n_ids, 8UL)".
cs_util_instance.c:112: var_assign: Assigning: "*_list" = "list".
misc_util.c:277: leaked_storage: Variable "list" going out of scope leaks the storage it points to.
Signed-off-by: Eduardo Lima (Etrunko) <eblima(a)br.ibm.com>
---
libxkutil/misc_util.c | 6 +++---
src/Virt_AppliedFilterList.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
index 61893c3..2d149ae 100644
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -267,14 +267,14 @@ bool match_pn_to_cn(const char *pn, const char *cn)
uint64_t allocated_memory(virConnectPtr conn)
{
- virDomainPtr *list;
+ virDomainPtr *list = NULL;
int count;
int i;
uint64_t memory = 0;
count = get_domain_list(conn, &list);
if (count <= 0)
- return 0;
+ goto end;
for (i = 0; i < count; i ++) {
virDomainPtr dom = list[i];
@@ -286,8 +286,8 @@ uint64_t allocated_memory(virConnectPtr conn)
virDomainFree(dom);
}
+ end:
free(list);
-
return memory;
}
diff --git a/src/Virt_AppliedFilterList.c b/src/Virt_AppliedFilterList.c
index 538adf4..0dfe6a3 100644
--- a/src/Virt_AppliedFilterList.c
+++ b/src/Virt_AppliedFilterList.c
@@ -521,7 +521,7 @@ static CMPIStatus CreateInstance(
free(net_name);
cleanup_filters(&filter, 1);
- cleanup_virt_devices(&device, 1);
+ cleanup_dominfo(&dominfo);
virDomainFree(dom);
virConnectClose(conn);
@@ -636,7 +636,7 @@ static CMPIStatus DeleteInstance(
free(net_name);
cleanup_filters(&filter, 1);
- cleanup_virt_devices(&device, 1);
+ cleanup_dominfo(&dominfo);
virDomainFree(dom);
virConnectClose(conn);
--
1.7.7.6
12 years, 6 months
Rebélate by self-management, first project of free software by which we bet all / Rebélate por la autogestión, primer proyecto de software libre por el que apostamos todas
by Orquidea Salt mas
Inglés :
Many already we have contributed to the first project of free software
dedicated to self-management in this campaign of collective financing,
it collaborates and it spreads!/
Beginning campaign collective financing
http://www.goteo.org/project/rebelaos-publicacion-por-la-autogestion?lang=en
Login to enter with user of social networks and for would register in Goteo :
http://www.goteo.org/user/login?lang=en
Rebelaos! Publication by self-management A massive publication that
floods the public transport, the work centers, the parks, the
consumption centers, by means of distribution of 500,000 gratuitous
units, acting simultaneously in all sides and nowhere.
We announce the main tool of a vestibule Web for the management of
self-sustaining resources by means of Drupal, in addition in the
publication there will be an article dedicated to free software,
hardware, It is being prepared in inglès, the machinery You can see
more details in the index of the
publication https://n-1.cc/pg/file/read/1151902/indexresumen-de-los-contenidos-pdf
. A computer system that allows us to share resources in all the
scopes of our life so that we do not have to generate means different
for each subject nor for each territory.
A point of contact digitalis to generate projects of life outside
Capitalism and to margin of the State.
A tool to spread and to impel the social transformation through the
resources that will set out in their contents around self-management,
the autoorganización, the disobedience and the collective action.
In which the capitalist system goes to the collapse, in a while
immersed in a deep systemic crisis (ecological, political and
economic, but mainly of values), where individual and collective of
people they are being lacking of his fundamental rights, is necessary
to develop a horizontal collective process where all the human beings
we pruned to interact in equality of conditions and freedom.
To interact means to relate to us (as much human as economically), to
communicate to us, to cover our basic needs, to generate and to
protect communal properties, to know and to provide collective
solutions us problematic that our lives interfere. We want abrir a
breach within normality in the monotonous life state-capitalist, a day
anyone, that finally will not be any day.
By means of this publication we try:
- To drive a horizontal collective process where all and all we pruned
to interact in equality of conditions and freedom.
- To create communications network between the people it jeopardize
with the change and arranged to act.
- To find collective solutions to problematic that our lives interfere
- To facilitate the access to resources that make possible self-management.
- To participate in the construction of networks of mutual support,
generated horizontals, asamblearias and from the base.
- To publish all this information in an attractive format stops to
facilitate the access to all the society.
There are 15 days remaining for the upcoming March 15, the day that
will come Rebelaos!, Magazine for the selfmanagement
Today, we issue the cover of Rebelaos! (Castilian version) that can be
displayed on the following link:
https://n-1.cc/pg/file/read/1200503/portada-15-de-marzo-rebelaos
The contents of the store owners to us by 15 March. Do you? Do you
keep on 15 March?
In addition, we have over 200 distribution nodes, distributed
throughout the Spanish state. Check the map:
https://afinidadrebelde.crowdmap.com/
On the other hand, the funding campaign continues to move and still
have 12 days to collect the remaining 6,000 euros. We can all make a
bit for all the grains of sand become a great beach on March 15. You
can access the co-financing campaign:
http://www.goteo.org/project/rebelaos-publicacion-por-la-autogestion
Rebel Affinity group
www.rebelaos.net
-------------------------------------------------------------------------------
Castellano:
Muchos ya hemos aportado al primer proyecto de software libre dedicado
a la la financiación colectiva, colabora y diffunde !!!!!
Inicio campaña financiación colectiva goteo.org
www.goteo.org/project/rebelaos-publicacion-por-la-autogestion
Link para registrarse en Goteo y acceder a redes sociales para
colaborar en la difusín
http://www.goteo.org/user/login
¡Rebelaos! Publicación por la autogestión
Una publicación masiva que inunde el transporte público, los centros
de trabajo, los parques, los centros de consumo, mediante la
distribución de 500.000 ejemplares gratuitos, actuando simultáneamente
en todos lados y en ninguna parte.
Anunciamos la herramienta principal de un portal web para la gestión
de recursos autogestionados mediante Drupal, además en la publicación
habrá un artículo dedicado al software libre, el hardware, la
maquinaria... Puedes ver más detalles en el índice de la publicación
https://n-1.cc/pg/file/read/1151902/indexresumen-de-los-contenidos-pdf
Un sistema infórmatico que nos permita compartir recursos en todos los
ámbitos de nuestra vida de forma que no tengamos que generar un medio
distinto para cada tema ni para cada territorio. Un punto de encuentro
digital para generar proyectos de vida fuera del capitalismo y al
margen del Estado.
Una herramienta para difundir e impulsar la transformación social a
través de los recursos que se propondrán en sus contenidos en torno a
la autogestión, la autoorganización, la desobediencia y la acción
colectiva.
En un momento en que el sistema capitalista se dirige al colapso,
inmerso en una profunda crisis sistémica (ecológica, política y
económica, pero principalmente de valores), donde individuos y
colectivos de personas están siendo desprovistos de sus derechos
fundamentales, es necesario desarrollar un proceso colectivo
horizontal donde todos los seres humanos podamos interactuar en
igualdad de condiciones y en libertad.
Interactuar significa relacionarnos (tanto humana como
económicamente), comunicarnos, cubrir nuestras necesidades básicas,
generar y proteger bienes comunes, conocernos y dar soluciones
colectivas a problemáticas que interfieren nuestras vidas. Queremos
abrir una brecha dentro de la normalidad en la monótona vida
estatal-capitalista, un día cualquiera, que finalmente no será
cualquier día.
Mediante esta publicación pretendemos:
- Impulsar un proceso colectivo horizontal donde todos y todas podamos
interactuar en igualdad de condiciones y en libertad.
- Crear red de comunicaciones entre las personas comprometidas con el
cambio y dispuestas a actuar.
- Encontrar soluciones colectivas a problemáticas que interfieren
nuestras vidas.
- Facilitar el acceso a recursos que posibiliten la autogestión.
- Participar en la construcción de redes de apoyo mutuo, horizontales,
asamblearias y generadas desde la base.
- Publicar toda esta información en un formato atractivo para
facilitar el acceso a toda la sociedad.
Son 15 los días que restan para el próximo 15 de marzo, día en el que
verá la luz ¡Rebelaos!, publicación por la autogestión.
Hoy, hacemos pública la portada de ¡Rebelaos! (versión en castellano)
que podéis visualizar en el siguiente enlace:
https://n-1.cc/pg/file/read/1200503/portada-15-de-marzo-rebelaos
El contenido de los titulares nos los guardamos para el 15 de marzo.
¿Y tú? ¿Te guardas el 15 de marzo?
Además, ya hemos superado los 200 nodos de distribución, repartidos
por todo el estado español. Ver el mapa:
https://afinidadrebelde.crowdmap.com/
Por otro lado, la campaña de financiación continúa avanzando y todavía
quedan 12 días para reunir los 6.000 euros que restan. Todas podemos
aportar un poco para que todos los granitos de arena se conviertan en
una gran playa el 15 de marzo. Podéis acceder a la campaña de
cofinanciación en:
http://www.goteo.org/project/rebelaos-publicacion-por-la-autogestion
Colectivo Afinidad Rebelde
www.rebelaos.net
12 years, 6 months
[PATCH 0/2] ComputerSystem: Make reboot/shutdown work as a job
by Eduardo Lima (Etrunko)
From: "Eduardo Lima (Etrunko)" <eblima(a)br.ibm.com>
This code is based on the VSMigrationService for the job creation and on
ComputerSystemIndication for the job thread, which will listen for the
respective domain event to mark the job as finished.
Unfortunately I could not make it work properly. In this case I need a help
from more experienced people to help on the debug. The call in line 1318 will
fail with status code 100. I am sending a simple python test program as a
reply to this email so everyone can reproduce.
Eduardo Lima (Etrunko) (2):
VSMigrationService: Move job state definitions to svpc_types.h
ComputerSystem: Reboot/Shutdown state changes as jobs
schema/ComputerSystem.mof | 9 ++
src/Virt_ComputerSystem.c | 300 +++++++++++++++++++++++++++++++++++++++--
src/Virt_VSMigrationService.c | 14 +--
src/svpc_types.h | 13 ++
4 files changed, 317 insertions(+), 19 deletions(-)
--
1.7.7.6
12 years, 6 months