2005-12-19 19:34:11 +03:00
/*
* types . c : converter functions between the internal representation
* and the Python objects
*
2007-12-07 13:08:06 +03:00
* Copyright ( C ) 2005 , 2007 Red Hat , Inc .
2005-12-19 19:34:11 +03:00
*
* Daniel Veillard < veillard @ redhat . com >
*/
2008-01-29 21:15:54 +03:00
# include <config.h>
2007-12-07 13:08:06 +03:00
2008-04-18 22:31:32 +04:00
/* Horrible kludge to work around even more horrible name-space pollution
* via Python . h . That file includes / usr / include / python2 .5 / pyconfig * . h ,
* which has over 180 autoconf - style HAVE_ * definitions . Shame on them . */
# undef HAVE_PTHREAD_H
2009-09-16 17:03:53 +04:00
# include "typewrappers.h"
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_intWrap ( int val )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
ret = PyInt_FromLong ( ( long ) val ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_longWrap ( long val )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
ret = PyInt_FromLong ( val ) ;
return ( ret ) ;
}
2006-11-15 22:40:00 +03:00
PyObject *
libvirt_ulongWrap ( unsigned long val )
{
PyObject * ret ;
ret = PyLong_FromLong ( val ) ;
return ( ret ) ;
2008-02-05 22:27:37 +03:00
}
2006-11-15 22:40:00 +03:00
2006-01-31 13:24:12 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_longlongWrap ( long long val )
2006-01-31 13:24:12 +03:00
{
PyObject * ret ;
ret = PyLong_FromUnsignedLongLong ( ( unsigned long long ) val ) ;
return ( ret ) ;
}
2010-02-03 14:31:45 +03:00
PyObject *
libvirt_ulonglongWrap ( unsigned long long val )
{
PyObject * ret ;
ret = PyLong_FromUnsignedLongLong ( val ) ;
return ( ret ) ;
}
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_charPtrWrap ( char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
free ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_constcharPtrWrap ( const char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_charPtrConstWrap ( const char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_virDomainPtrWrap ( virDomainPtr node )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virDomainPtr " ,
NULL ) ;
return ( ret ) ;
}
2007-03-09 18:42:50 +03:00
PyObject *
libvirt_virNetworkPtrWrap ( virNetworkPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virNetworkPtr " ,
NULL ) ;
return ( ret ) ;
}
2009-05-21 14:57:05 +04:00
PyObject *
libvirt_virInterfacePtrWrap ( virInterfacePtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virInterfacePtr " ,
NULL ) ;
return ( ret ) ;
}
2008-02-20 18:26:22 +03:00
PyObject *
libvirt_virStoragePoolPtrWrap ( virStoragePoolPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStoragePoolPtr " ,
NULL ) ;
return ( ret ) ;
}
PyObject *
libvirt_virStorageVolPtrWrap ( virStorageVolPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStorageVolPtr " ,
NULL ) ;
return ( ret ) ;
}
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_virConnectPtrWrap ( virConnectPtr node )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virConnectPtr " ,
NULL ) ;
return ( ret ) ;
}
2008-10-31 13:13:45 +03:00
2008-11-21 15:41:15 +03:00
PyObject *
libvirt_virNodeDevicePtrWrap ( virNodeDevicePtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virNodeDevicePtr " ,
NULL ) ;
return ( ret ) ;
}
Secret manipulation API docs refresh & wire up python generator
Sample session:
>>> import libvirt
>>> c = libvirt.open('qemu:///session')
>>> c.listSecrets()
['12247729-47d2-a783-88ce-b329d4781cd3', 'reee', 'abc']
>>> s = c.secretDefineXML("<secret ephemeral='no' private='no'>\n<description>Something for use</description>\n<volume>/foo/bar</volume>\n</secret>\n")
>>> s.UUIDString()
'340c2dfb-811b-eda8-da9e-25ccd7bfd650'
>>> s.XMLDesc()
"<secret ephemeral='no' private='no'>\n <uuid>340c2dfb-811b-eda8-da9e-25ccd7bfd650</uuid>\n <description>Something for use</description>\n <volume>/foo/bar</volume>\n</secret>\n"
>>> s.setValue('abc\0xx\xffx')
0
>>> s.value()
'abc\x00xx\xffx'
>>> s.undefine()
0
* python/generator.py: Add rules for virSecret APIs
* python/libvir.c, python/libvirt-python-api.xml: Manual impl of
virSecretSetValue, virSecretGetValue$ and virConnectListSecrets APIs
* python/libvirt_wrap.h, python/types.c: Wrapper for virSecret objects
* docs/libvirt-api.xml, docs/libvirt-refs.xml,
docs/html/libvirt-virterror.html, docs/html/libvirt-libvirt.html,
docs/devhelp/libvirt-virterror.html, docs/devhelp/libvirt-libvirt.html:
Re-generate with 'make api'
2009-08-04 22:38:21 +04:00
PyObject *
libvirt_virSecretPtrWrap ( virSecretPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return Py_None ;
}
ret = PyCObject_FromVoidPtrAndDesc ( node , ( char * ) " virSecretPtr " , NULL ) ;
2010-04-29 14:46:01 +04:00
return ( ret ) ;
}
PyObject *
libvirt_virNWFilterPtrWrap ( virNWFilterPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return Py_None ;
}
ret = PyCObject_FromVoidPtrAndDesc ( node , ( char * ) " virNWFilterPtr " , NULL ) ;
Secret manipulation API docs refresh & wire up python generator
Sample session:
>>> import libvirt
>>> c = libvirt.open('qemu:///session')
>>> c.listSecrets()
['12247729-47d2-a783-88ce-b329d4781cd3', 'reee', 'abc']
>>> s = c.secretDefineXML("<secret ephemeral='no' private='no'>\n<description>Something for use</description>\n<volume>/foo/bar</volume>\n</secret>\n")
>>> s.UUIDString()
'340c2dfb-811b-eda8-da9e-25ccd7bfd650'
>>> s.XMLDesc()
"<secret ephemeral='no' private='no'>\n <uuid>340c2dfb-811b-eda8-da9e-25ccd7bfd650</uuid>\n <description>Something for use</description>\n <volume>/foo/bar</volume>\n</secret>\n"
>>> s.setValue('abc\0xx\xffx')
0
>>> s.value()
'abc\x00xx\xffx'
>>> s.undefine()
0
* python/generator.py: Add rules for virSecret APIs
* python/libvir.c, python/libvirt-python-api.xml: Manual impl of
virSecretSetValue, virSecretGetValue$ and virConnectListSecrets APIs
* python/libvirt_wrap.h, python/types.c: Wrapper for virSecret objects
* docs/libvirt-api.xml, docs/libvirt-refs.xml,
docs/html/libvirt-virterror.html, docs/html/libvirt-libvirt.html,
docs/devhelp/libvirt-virterror.html, docs/devhelp/libvirt-libvirt.html:
Re-generate with 'make api'
2009-08-04 22:38:21 +04:00
return ( ret ) ;
}
2009-07-10 15:18:12 +04:00
PyObject *
libvirt_virStreamPtrWrap ( virStreamPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return Py_None ;
}
ret = PyCObject_FromVoidPtrAndDesc ( node , ( char * ) " virStreamPtr " , NULL ) ;
return ( ret ) ;
}
2010-04-01 00:33:13 +04:00
PyObject *
libvirt_virDomainSnapshotPtrWrap ( virDomainSnapshotPtr node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virDomainSnapshotPtr " ,
NULL ) ;
return ( ret ) ;
}
2008-10-31 13:13:45 +03:00
PyObject *
libvirt_virEventHandleCallbackWrap ( virEventHandleCallback node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
2008-12-18 15:25:11 +03:00
printf ( " %s: WARNING - Wrapping None \n " , __func__ ) ;
2008-10-31 13:13:45 +03:00
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virEventHandleCallback " ,
NULL ) ;
return ( ret ) ;
}
PyObject *
libvirt_virEventTimeoutCallbackWrap ( virEventTimeoutCallback node )
{
PyObject * ret ;
if ( node = = NULL ) {
2008-12-18 15:25:11 +03:00
printf ( " %s: WARNING - Wrapping None \n " , __func__ ) ;
2008-10-31 13:13:45 +03:00
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virEventTimeoutCallback " ,
NULL ) ;
return ( ret ) ;
}
2008-11-19 19:24:01 +03:00
PyObject *
libvirt_virFreeCallbackWrap ( virFreeCallback node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virFreeCallback " ,
NULL ) ;
return ( ret ) ;
}
2008-10-31 13:13:45 +03:00
PyObject *
libvirt_virVoidPtrWrap ( void * node )
{
PyObject * ret ;
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " void* " ,
NULL ) ;
return ( ret ) ;
}