[Libvir] [PATCH 3/6] Inactive domain support: python bindings

Daniel P. Berrange berrange at redhat.com
Wed Nov 15 02:20:33 UTC 2006


The attached patch implements the virListDefinedDomains method in the python
bindings, since it wasn't being automatically generated by the generator.py
script. 

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
-------------- next part --------------
Index: python/generator.py
===================================================================
RCS file: /data/cvs/libvirt/python/generator.py,v
retrieving revision 1.13
diff -c -r1.13 generator.py
*** python/generator.py	9 Nov 2006 15:32:45 -0000	1.13
--- python/generator.py	15 Nov 2006 02:33:58 -0000
***************
*** 260,265 ****
--- 260,266 ----
  # code is still automatically generated (so they are not in skip_function()).
  skip_impl = (
      'virConnectListDomainsID',
+     'virConnectListDefinedDomains',
      'virConnGetLastError',
      'virGetLastError',
      'virDomainGetInfo',
Index: python/libvir.c
===================================================================
RCS file: /data/cvs/libvirt/python/libvir.c,v
retrieving revision 1.15
diff -c -r1.15 libvir.c
*** python/libvir.c	7 Nov 2006 23:18:56 -0000	1.15
--- python/libvir.c	15 Nov 2006 02:33:59 -0000
***************
*** 241,246 ****
--- 241,287 ----
  }
  
  static PyObject *
+ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
+ 				     PyObject *args) {
+     PyObject *py_retval;
+     char **names = NULL;
+     int c_retval, i;
+     virConnectPtr conn;
+     PyObject *pyobj_conn;
+ 
+ 
+     if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDomains", &pyobj_conn))
+         return(NULL);
+     conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+ 
+     c_retval = virConnectNumOfDefinedDomains(conn);
+     if (c_retval < 0) {
+         Py_INCREF(Py_None);
+ 	return (Py_None);
+     }
+     
+     if (c_retval) {
+         names = malloc(sizeof(char *) * c_retval);
+         c_retval = virConnectListDefinedDomains(conn, names, c_retval);
+         if (c_retval < 0) {
+             free(names);
+             Py_INCREF(Py_None);
+             return(Py_None);
+         }
+     }
+     py_retval = PyList_New(c_retval);
+     for (i = 0;i < c_retval;i++) {
+         PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
+ 	free(names[i]);
+     }
+ 
+     if (names)
+       free(names);
+ 
+     return(py_retval);
+ }
+ 
+ static PyObject *
  libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
      PyObject *py_retval;
      int c_retval;
***************
*** 364,369 ****
--- 405,411 ----
      {(char *) "virDomainFree", libvirt_virDomainFree, METH_VARARGS, NULL},
      {(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL},
      {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
+     {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},
      {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
      {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
      {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
Index: python/libvirt-python-api.xml
===================================================================
RCS file: /data/cvs/libvirt/python/libvirt-python-api.xml,v
retrieving revision 1.4
diff -c -r1.4 libvirt-python-api.xml
*** python/libvirt-python-api.xml	29 Mar 2006 12:46:03 -0000	1.4
--- python/libvirt-python-api.xml	15 Nov 2006 02:33:59 -0000
***************
*** 6,11 ****
--- 6,16 ----
        <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
        <return type='int *' info="the list of ID or None in case of error"/>
      </function>
+     <function name='virConnectListDefinedDomains' file='python'>
+       <info>list the defined domains, stores the pointers to the names in @names</info>
+       <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+       <return type='str *' info='the list of Names of None in case of error'/>
+     </function>
      <function name='virDomainLookupByUUID' file='python'>
        <info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
        <return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>


More information about the libvir-list mailing list