+Tue Mar 28 16:40:08 CEST 2006 Daniel Veillard <veillard@redhat.com>
+
+ * python/libvir.c: call the initialize entry point
+ * src/libvirt_sym.version: add initialize entry point
+ * src/libvirt.c: make sure we always initialize the lib
+ * python/tests/*.py: start updating exemple for exception
+ handling as pointed by Jim Meyering
+
Tue Mar 28 11:49:59 CEST 2006 Daniel Veillard <veillard@redhat.com>
* doc/site.xsl doc/libvir.html doc/*: added informations about
if (initialized != 0)
return;
+ virInitialize();
+
/* intialize the python extension module */
Py_InitModule((char *) "libvirtmod", libvirtMethods);
# print conn
-dom0 = conn.lookupByName("Domain-0")
-if dom0 == None:
+try:
+ dom0 = conn.lookupByName("Domain-0")
+except:
print 'Failed to find the main domain'
sys.exit(1)
print "shutdown of test domain"
if dom.shutdown() != 0:
+ okay = 0
print 'Failed to shutdown domain test'
i = 0
while i < 30:
time.sleep(1)
i = i + 1
- t = dom.info()[4]
+ try:
+ t = dom.info()[4]
+ except:
+ okay = 0
+ t = -1
+ break;
+
if t == 0:
break
id = ids[-1]
-dom = conn.lookupByID(id)
-if dom == None:
+try:
+ dom = conn.lookupByID(id)
+except:
print 'Failed to find the domain %d'
sys.exit(1)
name0 = dom.name()
uuid = dom.UUID()
print "Using domain %s" % (name0)
-dom2 = conn.lookupByUUID(uuid)
-if dom2 == None:
+try:
+ dom2 = conn.lookupByUUID(uuid)
+except:
print 'Failed to lookup domain %d based on its UUID'
sys.exit(1)
if dom2.name() != name0:
if (initialized)
return(0);
+ initialized = 1;
/*
* should not be needed but...
xenHypervisorRegister();
xenDaemonRegister();
xenStoreRegister();
- initialized = 1;
return(0);
}
{
int i;
+ if (!initialized)
+ virInitialize();
+
if (driver == NULL) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
virGetVersion(unsigned long *libVer, const char *type,
unsigned long *typeVer)
{
+ if (!initialized)
+ virInitialize();
+
if (libVer == NULL)
return (-1);
*libVer = LIBVIR_VERSION_NUMBER;
{
virConnectPtr ret = NULL;
+ if (!initialized)
+ virInitialize();
+
/* we can only talk to the local Xen supervisor ATM */
if (name != NULL) {
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
int res;
virConnectPtr ret = NULL;
+ if (!initialized)
+ virInitialize();
+
/* we can only talk to the local Xen supervisor ATM */
if (name != NULL) {
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
{
global:
+ virInitialize;
virConnectClose;
virConnectGetType;
virConnectGetVersion;