mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-03 11:51:11 +00:00
9dc3b99345
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'
270 lines
5.5 KiB
C
270 lines
5.5 KiB
C
/*
|
|
* types.c: converter functions between the internal representation
|
|
* and the Python objects
|
|
*
|
|
* Copyright (C) 2005, 2007 Red Hat, Inc.
|
|
*
|
|
* Daniel Veillard <veillard@redhat.com>
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
/* 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
|
|
|
|
#include "libvirt_wrap.h"
|
|
|
|
PyObject *
|
|
libvirt_intWrap(int val)
|
|
{
|
|
PyObject *ret;
|
|
ret = PyInt_FromLong((long) val);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_longWrap(long val)
|
|
{
|
|
PyObject *ret;
|
|
ret = PyInt_FromLong(val);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_ulongWrap(unsigned long val)
|
|
{
|
|
PyObject *ret;
|
|
ret = PyLong_FromLong(val);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_longlongWrap(long long val)
|
|
{
|
|
PyObject *ret;
|
|
ret = PyLong_FromUnsignedLongLong((unsigned long long) val);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_charPtrWrap(char *str)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (str == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret = PyString_FromString(str);
|
|
free(str);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_constcharPtrWrap(const char *str)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (str == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret = PyString_FromString(str);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_charPtrConstWrap(const char *str)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (str == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret = PyString_FromString(str);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_virDomainPtrWrap(virDomainPtr node)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (node == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret =
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virDomainPtr",
|
|
NULL);
|
|
return (ret);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_virConnectPtrWrap(virConnectPtr node)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (node == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret =
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virConnectPtr",
|
|
NULL);
|
|
return (ret);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_virSecretPtrWrap(virSecretPtr node)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (node == NULL) {
|
|
Py_INCREF(Py_None);
|
|
return Py_None;
|
|
}
|
|
ret = PyCObject_FromVoidPtrAndDesc(node, (char *) "virSecretPtr", NULL);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_virEventHandleCallbackWrap(virEventHandleCallback node)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (node == NULL) {
|
|
Py_INCREF(Py_None);
|
|
printf("%s: WARNING - Wrapping None\n", __func__);
|
|
return (Py_None);
|
|
}
|
|
ret =
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virEventHandleCallback",
|
|
NULL);
|
|
return (ret);
|
|
}
|
|
|
|
PyObject *
|
|
libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node)
|
|
{
|
|
PyObject *ret;
|
|
|
|
if (node == NULL) {
|
|
printf("%s: WARNING - Wrapping None\n", __func__);
|
|
Py_INCREF(Py_None);
|
|
return (Py_None);
|
|
}
|
|
ret =
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virEventTimeoutCallback",
|
|
NULL);
|
|
return (ret);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|