From 1d8b52d81d55c3591b887364a6c5723ef4fd5197 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 9 Feb 2006 17:45:11 +0000 Subject: * //* : renamed the project libvirt , this affects all makefiles, the specs, the icons, the docs, etc ... * configure.in: prepare for 0.0.3 Daniel --- Makefile.am | 40 ++++++++++++++++++++-------------------- generator.py | 50 +++++++++++++++++++++++++------------------------- libvir-python-api.xml | 15 --------------- libvir.c | 44 ++++++++++++++++++++++---------------------- libvir_wrap.h | 49 ------------------------------------------------- libvirt-python-api.xml | 15 +++++++++++++++ libvirt_wrap.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ types.c | 34 +++++++++++++++++----------------- 8 files changed, 148 insertions(+), 148 deletions(-) delete mode 100644 libvir-python-api.xml delete mode 100644 libvir_wrap.h create mode 100644 libvirt-python-api.xml create mode 100644 libvirt_wrap.h diff --git a/Makefile.am b/Makefile.am index 0921e32..b0eb78e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -# Makefile for libvir python library +# Makefile for libvirt python library INCLUDES = \ -I$(PYTHON_INCLUDES) \ @@ -6,7 +6,7 @@ INCLUDES = \ -I$(top_builddir)/include \ -I$(top_builddir)/$(subdir) -DOCS_DIR = $(datadir)/doc/libvir-python-$(LIBVIR_VERSION) +DOCS_DIR = $(datadir)/doc/libvirt-python-$(LIBVIR_VERSION) DOCS = ${srcdir}/TODO @@ -14,40 +14,40 @@ EXTRA_DIST = \ libvir.c \ types.c \ generator.py \ - libvir_wrap.h \ - libvir.py \ - libvir-python-api.xml \ + libvirt_wrap.h \ + libvirt.py \ + libvirt-python-api.xml \ $(DOCS) -libvirmod_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs +libvirtmod_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/.libs if WITH_PYTHON -mylibs = $(top_builddir)/src/libvir.la +mylibs = $(top_builddir)/src/libvirt.la -all-local: libvir.py +all-local: libvirt.py -python_LTLIBRARIES = libvirmod.la +python_LTLIBRARIES = libvirtmod.la -libvirmod_la_SOURCES = libvir.c types.c libvir-py.c -libvirmod_la_LIBADD = $(mylibs) +libvirtmod_la_SOURCES = libvir.c types.c libvirt-py.c libvirt-py.h +libvirtmod_la_LIBADD = $(mylibs) install-data-local: $(mkinstalldirs) $(DESTDIR)$(pythondir) - @INSTALL@ -m 0644 libvir.py $(DESTDIR)$(pythondir) + @INSTALL@ -m 0644 libvirt.py $(DESTDIR)$(pythondir) $(mkinstalldirs) $(DESTDIR)$(DOCS_DIR) @(for doc in $(DOCS) ; \ do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done) GENERATE = generator.py -API_DESC = $(top_srcdir)/docs/libvir-api.xml $(srcdir)/libvir-python-api.xml -GENERATED= libvir.py \ - libvir-export.c \ - libvirclass.txt \ - libvir-py.c \ - libvir-py.h +API_DESC = $(top_srcdir)/docs/libvirt-api.xml $(srcdir)/libvirt-python-api.xml +GENERATED= libvirt.py \ + libvirt-export.c \ + libvirtclass.txt \ + libvirt-py.c \ + libvirt-py.h -CLEANFILES= $(GENERATED) gen_prog libvir.py +CLEANFILES= $(GENERATED) gen_prog libvirt.py $(GENERATED): gen_prog @@ -55,7 +55,7 @@ gen_prog: $(srcdir)/$(GENERATE) $(API_DESC) $(PYTHON) $(srcdir)/$(GENERATE) $(srcdir) touch gen_prog -$(libvirmod_la_OBJECTS): $(GENERATED) +$(libvirtmod_la_OBJECTS): $(GENERATED) else all: diff --git a/generator.py b/generator.py index 0c22482..c336f61 100755 --- a/generator.py +++ b/generator.py @@ -20,7 +20,7 @@ else: ####################################################################### # # That part if purely the API acquisition phase from the -# libvir API description +# libvirt API description # ####################################################################### import os @@ -354,13 +354,13 @@ def print_function_wrapper(name, output, export, include): c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2]) else: c_call = "\n c_retval = %s(%s);\n" % (name, c_call); - ret_convert = " py_retval = libvir_%sWrap((%s) c_retval);\n" % (n,c) + ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c) ret_convert = ret_convert + " return(py_retval);\n" elif py_return_types.has_key(ret[0]): (f, t, n, c) = py_return_types[ret[0]] c_return = " %s c_retval;\n" % (ret[0]) c_call = "\n c_retval = %s(%s);\n" % (name, c_call); - ret_convert = " py_retval = libvir_%sWrap((%s) c_retval);\n" % (n,c) + ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c) ret_convert = ret_convert + " return(py_retval);\n" else: if skipped_types.has_key(ret[0]): @@ -378,9 +378,9 @@ def print_function_wrapper(name, output, export, include): output.write("#if %s\n" % cond) include.write("PyObject * ") - include.write("libvir_%s(PyObject *self, PyObject *args);\n" % (name)); + include.write("libvirt_%s(PyObject *self, PyObject *args);\n" % (name)); - export.write(" { (char *)\"%s\", libvir_%s, METH_VARARGS, NULL },\n" % + export.write(" { (char *)\"%s\", libvirt_%s, METH_VARARGS, NULL },\n" % (name, name)) if file == "python": @@ -399,7 +399,7 @@ def print_function_wrapper(name, output, export, include): return 1 output.write("PyObject *\n") - output.write("libvir_%s(PyObject *self ATTRIBUTE_UNUSED," % (name)) + output.write("libvirt_%s(PyObject *self ATTRIBUTE_UNUSED," % (name)) output.write(" PyObject *args") if format == "": output.write(" ATTRIBUTE_UNUSED") @@ -432,14 +432,14 @@ def buildStubs(): global unknown_types try: - f = open(os.path.join(srcPref,"libvir-api.xml")) + f = open(os.path.join(srcPref,"libvirt-api.xml")) data = f.read() (parser, target) = getparser() parser.feed(data) parser.close() except IOError, msg: try: - f = open(os.path.join(srcPref,"..","docs","libvir-api.xml")) + f = open(os.path.join(srcPref,"..","docs","libvirt-api.xml")) data = f.read() (parser, target) = getparser() parser.feed(data) @@ -449,11 +449,11 @@ def buildStubs(): sys.exit(1) n = len(functions.keys()) - print "Found %d functions in libvir-api.xml" % (n) + print "Found %d functions in libvirt-api.xml" % (n) py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject") try: - f = open(os.path.join(srcPref,"libvir-python-api.xml")) + f = open(os.path.join(srcPref,"libvirt-python-api.xml")) data = f.read() (parser, target) = getparser() parser.feed(data) @@ -462,22 +462,22 @@ def buildStubs(): print file, ":", msg - print "Found %d functions in libvir-python-api.xml" % ( + print "Found %d functions in libvirt-python-api.xml" % ( len(functions.keys()) - n) nb_wrap = 0 failed = 0 skipped = 0 - include = open("libvir-py.h", "w") + include = open("libvirt-py.h", "w") include.write("/* Generated */\n\n") - export = open("libvir-export.c", "w") + export = open("libvirt-export.c", "w") export.write("/* Generated */\n\n") - wrapper = open("libvir-py.c", "w") + wrapper = open("libvirt-py.c", "w") wrapper.write("/* Generated */\n\n") wrapper.write("#include \n") - wrapper.write("#include \n") - wrapper.write("#include \"libvir_wrap.h\"\n") - wrapper.write("#include \"libvir-py.h\"\n\n") + wrapper.write("#include \n") + wrapper.write("#include \"libvirt_wrap.h\"\n") + wrapper.write("#include \"libvirt-py.h\"\n\n") for function in functions.keys(): ret = print_function_wrapper(function, wrapper, export, include) if ret < 0: @@ -685,19 +685,19 @@ def buildWrappers(): info = (0, func, name, ret, args, file) function_classes['None'].append(info) - classes = open("libvir.py", "w") + classes = open("libvirt.py", "w") classes.write("""#!/usr/bin/python -u # -# Those are the autogenerated Python bindings for libvir. -# Check python/generator.py in the source distribution of libvir +# Those are the autogenerated Python bindings for libvirt. +# Check python/generator.py in the source distribution of libvirt # to find out more about the generation process # """) - classes.write("import libvirmod\n") + classes.write("import libvirtmod\n") classes.write("import types\n\n") - txt = open("libvirclass.txt", "w") + txt = open("libvirtclass.txt", "w") txt.write(" Generated Classes for libvir-python\n\n") txt.write("#\n# Global functions of the module\n#\n\n") @@ -732,7 +732,7 @@ def buildWrappers(): classes.write(" ret = "); else: classes.write(" "); - classes.write("libvirmod.%s(" % name) + classes.write("libvirtmod.%s(" % name) n = 0 for arg in args: if n != 0: @@ -788,7 +788,7 @@ def buildWrappers(): if classes_destructors.has_key(classname): classes.write(" def __del__(self):\n") classes.write(" if self._o != None:\n") - classes.write(" libvirmod.%s(self._o)\n" % + classes.write(" libvirtmod.%s(self._o)\n" % classes_destructors[classname]); classes.write(" self._o = None\n\n"); destruct=classes_destructors[classname] @@ -836,7 +836,7 @@ def buildWrappers(): classes.write(" ret = "); else: classes.write(" "); - classes.write("libvirmod.%s(" % name) + classes.write("libvirtmod.%s(" % name) n = 0 for arg in args: if n != 0: diff --git a/libvir-python-api.xml b/libvir-python-api.xml deleted file mode 100644 index d90da8a..0000000 --- a/libvir-python-api.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Returns the list of the ID of the domains on the hypervisor - - - - - Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the informations can be extracted. - - - - - diff --git a/libvir.c b/libvir.c index 5956fdd..ffc9c03 100644 --- a/libvir.c +++ b/libvir.c @@ -10,14 +10,14 @@ */ #include -#include -#include "libvir_wrap.h" -#include "libvir-py.h" +#include +#include "libvirt_wrap.h" +#include "libvirt-py.h" void initlibvirmod(void); static PyObject * -libvir_virDomainFree(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { +libvirt_virDomainFree(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int c_retval; virDomainPtr domain; @@ -28,12 +28,12 @@ libvir_virDomainFree(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); c_retval = virDomainFree(domain); - py_retval = libvir_intWrap((int) c_retval); + py_retval = libvirt_intWrap((int) c_retval); return(py_retval); } static PyObject * -libvir_virConnectClose(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { +libvirt_virConnectClose(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int c_retval; virConnectPtr conn; @@ -44,12 +44,12 @@ libvir_virConnectClose(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); c_retval = virConnectClose(conn); - py_retval = libvir_intWrap((int) c_retval); + py_retval = libvirt_intWrap((int) c_retval); return(py_retval); } static PyObject * -libvir_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED, +libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int ids[500], c_retval, i; @@ -68,13 +68,13 @@ libvir_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED, } py_retval = PyList_New(c_retval); for (i = 0;i < c_retval;i++) { - PyList_SetItem(py_retval, i, libvir_intWrap(ids[i])); + PyList_SetItem(py_retval, i, libvirt_intWrap(ids[i])); } return(py_retval); } static PyObject * -libvir_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { +libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; int c_retval; virDomainPtr domain; @@ -91,12 +91,12 @@ libvir_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return(Py_None); } py_retval = PyList_New(5); - PyList_SetItem(py_retval, 0, libvir_intWrap((int) info.state)); - PyList_SetItem(py_retval, 1, libvir_longWrap((long) info.maxMem)); - PyList_SetItem(py_retval, 2, libvir_longWrap((long) info.memory)); - PyList_SetItem(py_retval, 3, libvir_intWrap((int) info.nrVirtCpu)); + PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state)); + PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.maxMem)); + PyList_SetItem(py_retval, 2, libvirt_longWrap((long) info.memory)); + PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.nrVirtCpu)); PyList_SetItem(py_retval, 4, - libvir_longlongWrap((unsigned long long) info.cpuTime)); + libvirt_longlongWrap((unsigned long long) info.cpuTime)); return(py_retval); } @@ -105,12 +105,12 @@ libvir_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { * The registration stuff * * * ************************************************************************/ -static PyMethodDef libvirMethods[] = { -#include "libvir-export.c" - {(char *) "virDomainFree", libvir_virDomainFree, METH_VARARGS, NULL}, - {(char *) "virConnectClose", libvir_virConnectClose, METH_VARARGS, NULL}, - {(char *) "virConnectListDomainsID", libvir_virConnectListDomainsID, METH_VARARGS, NULL}, - {(char *) "virDomainGetInfo", libvir_virDomainGetInfo, METH_VARARGS, NULL}, +static PyMethodDef libvirtMethods[] = { +#include "libvirt-export.c" + {(char *) "virDomainFree", libvirt_virDomainFree, METH_VARARGS, NULL}, + {(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL}, + {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL}, + {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; @@ -123,7 +123,7 @@ initlibvirmod(void) return; /* intialize the python extension module */ - Py_InitModule((char *) "libvirmod", libvirMethods); + Py_InitModule((char *) "libvirtmod", libvirtMethods); initialized = 1; } diff --git a/libvir_wrap.h b/libvir_wrap.h deleted file mode 100644 index 41400c0..0000000 --- a/libvir_wrap.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * libvir_wrap.h: type wrappers for libvir python bindings - * - * Copyright (C) 2005 Red Hat, Inc. - * - * Daniel Veillard - */ - -#include -#include - -#ifdef __GNUC__ -#ifdef ATTRIBUTE_UNUSED -#undef ATTRIBUTE_UNUSED -#endif -#ifndef ATTRIBUTE_UNUSED -#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif /* ATTRIBUTE_UNUSED */ -#else -#define ATTRIBUTE_UNUSED -#endif - -#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \ - (((PyvirConnect_Object *)(v))->obj)) - -typedef struct { - PyObject_HEAD - virConnectPtr obj; -} PyvirConnect_Object; - - -#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \ - (((PyvirDomain_Object *)(v))->obj)) - -typedef struct { - PyObject_HEAD - virDomainPtr obj; -} PyvirDomain_Object; - - -PyObject * libvir_intWrap(int val); -PyObject * libvir_longWrap(long val); -PyObject * libvir_longlongWrap(long long val); -PyObject * libvir_charPtrWrap(char *str); -PyObject * libvir_constcharPtrWrap(const char *str); -PyObject * libvir_charPtrConstWrap(const char *str); -PyObject * libvir_virConnectPtrWrap(virConnectPtr node); -PyObject * libvir_virDomainPtrWrap(virDomainPtr node); - diff --git a/libvirt-python-api.xml b/libvirt-python-api.xml new file mode 100644 index 0000000..d90da8a --- /dev/null +++ b/libvirt-python-api.xml @@ -0,0 +1,15 @@ + + + + + Returns the list of the ID of the domains on the hypervisor + + + + + Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the informations can be extracted. + + + + + diff --git a/libvirt_wrap.h b/libvirt_wrap.h new file mode 100644 index 0000000..5d1d3e3 --- /dev/null +++ b/libvirt_wrap.h @@ -0,0 +1,49 @@ +/* + * libvirt_wrap.h: type wrappers for libvir python bindings + * + * Copyright (C) 2005 Red Hat, Inc. + * + * Daniel Veillard + */ + +#include +#include + +#ifdef __GNUC__ +#ifdef ATTRIBUTE_UNUSED +#undef ATTRIBUTE_UNUSED +#endif +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif /* ATTRIBUTE_UNUSED */ +#else +#define ATTRIBUTE_UNUSED +#endif + +#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \ + (((PyvirConnect_Object *)(v))->obj)) + +typedef struct { + PyObject_HEAD + virConnectPtr obj; +} PyvirConnect_Object; + + +#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \ + (((PyvirDomain_Object *)(v))->obj)) + +typedef struct { + PyObject_HEAD + virDomainPtr obj; +} PyvirDomain_Object; + + +PyObject * libvirt_intWrap(int val); +PyObject * libvirt_longWrap(long val); +PyObject * libvirt_longlongWrap(long long val); +PyObject * libvirt_charPtrWrap(char *str); +PyObject * libvirt_constcharPtrWrap(const char *str); +PyObject * libvirt_charPtrConstWrap(const char *str); +PyObject * libvirt_virConnectPtrWrap(virConnectPtr node); +PyObject * libvirt_virDomainPtrWrap(virDomainPtr node); + diff --git a/types.c b/types.c index 3015c1d..b98beef 100644 --- a/types.c +++ b/types.c @@ -7,51 +7,51 @@ * Daniel Veillard */ -#include "libvir_wrap.h" +#include "libvirt_wrap.h" PyObject * -libvir_intWrap(int val) +libvirt_intWrap(int val) { PyObject *ret; #ifdef DEBUG - printf("libvir_intWrap: val = %d\n", val); + printf("libvirt_intWrap: val = %d\n", val); #endif ret = PyInt_FromLong((long) val); return (ret); } PyObject * -libvir_longWrap(long val) +libvirt_longWrap(long val) { PyObject *ret; #ifdef DEBUG - printf("libvir_longWrap: val = %ld\n", val); + printf("libvirt_longWrap: val = %ld\n", val); #endif ret = PyInt_FromLong(val); return (ret); } PyObject * -libvir_longlongWrap(long long val) +libvirt_longlongWrap(long long val) { PyObject *ret; #ifdef DEBUG - printf("libvir_longWrap: val = %ld\n", val); + printf("libvirt_longWrap: val = %ld\n", val); #endif ret = PyLong_FromUnsignedLongLong((unsigned long long) val); return (ret); } PyObject * -libvir_charPtrWrap(char *str) +libvirt_charPtrWrap(char *str) { PyObject *ret; #ifdef DEBUG - printf("libvir_xmlcharPtrWrap: str = %s\n", str); + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); #endif if (str == NULL) { Py_INCREF(Py_None); @@ -63,12 +63,12 @@ libvir_charPtrWrap(char *str) } PyObject * -libvir_constcharPtrWrap(const char *str) +libvirt_constcharPtrWrap(const char *str) { PyObject *ret; #ifdef DEBUG - printf("libvir_xmlcharPtrWrap: str = %s\n", str); + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); #endif if (str == NULL) { Py_INCREF(Py_None); @@ -79,12 +79,12 @@ libvir_constcharPtrWrap(const char *str) } PyObject * -libvir_charPtrConstWrap(const char *str) +libvirt_charPtrConstWrap(const char *str) { PyObject *ret; #ifdef DEBUG - printf("libvir_xmlcharPtrWrap: str = %s\n", str); + printf("libvirt_xmlcharPtrWrap: str = %s\n", str); #endif if (str == NULL) { Py_INCREF(Py_None); @@ -95,12 +95,12 @@ libvir_charPtrConstWrap(const char *str) } PyObject * -libvir_virDomainPtrWrap(virDomainPtr node) +libvirt_virDomainPtrWrap(virDomainPtr node) { PyObject *ret; #ifdef DEBUG - printf("libvir_virDomainPtrWrap: node = %p\n", node); + printf("libvirt_virDomainPtrWrap: node = %p\n", node); #endif if (node == NULL) { Py_INCREF(Py_None); @@ -113,12 +113,12 @@ libvir_virDomainPtrWrap(virDomainPtr node) } PyObject * -libvir_virConnectPtrWrap(virConnectPtr node) +libvirt_virConnectPtrWrap(virConnectPtr node) { PyObject *ret; #ifdef DEBUG - printf("libvir_virConnectPtrWrap: node = %p\n", node); + printf("libvirt_virConnectPtrWrap: node = %p\n", node); #endif if (node == NULL) { Py_INCREF(Py_None); -- cgit