]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add virInterface APIs to python code generator
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 21 May 2009 10:57:05 +0000 (10:57 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 21 May 2009 10:57:05 +0000 (10:57 +0000)
ChangeLog
python/generator.py
python/libvirt_wrap.h
python/types.c

index 93f60ae3f37b2f79b1de15b6dbdda5fb1ac8a38a..204a54c71366041dd871e6bf42b598d68f34ec17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 21 11:52:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       * python/generator.py, python/libvirt_wrap.h, python/types.c: Add
+       rules for generating virInterface APIs in python
+
 Thu May 21 10:01:43 CEST 2009 Daniel Veillard <veillard@redhat.com>
 
        * docs/formatstorage.html[.in]: fix a error in format type example
index 00c9aca24bb723cc1bf7721d86e71ff1b0c9c931..952883981d85c5ed5247024bfd15cf3fc8ba6262 100755 (executable)
@@ -246,6 +246,11 @@ py_types = {
     'virNetwork *':  ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
     'const virNetwork *':  ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
 
+    'virInterfacePtr':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
+    'const virInterfacePtr':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
+    'virInterface *':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
+    'const virInterface *':  ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
+
     'virStoragePoolPtr':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
     'const virStoragePoolPtr':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
     'virStoragePool *':  ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
@@ -289,6 +294,8 @@ skip_impl = (
     'virConnectListDefinedDomains',
     'virConnectListNetworks',
     'virConnectListDefinedNetworks',
+    'virConnectListInterfaces',
+    'virConnectListDefinedInterfaces',
     'virConnectListStoragePools',
     'virConnectListDefinedStoragePools',
     'virConnectListStorageVols',
@@ -608,6 +615,8 @@ classes_type = {
     "virDomain *": ("._o", "virDomain(self, _obj=%s)", "virDomain"),
     "virNetworkPtr": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
     "virNetwork *": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
+    "virInterfacePtr": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
+    "virInterface *": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
     "virStoragePoolPtr": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
     "virStoragePool *": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
     "virStorageVolPtr": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"),
@@ -621,7 +630,8 @@ classes_type = {
 converter_type = {
 }
 
-primary_classes = ["virDomain", "virNetwork", "virStoragePool", "virStorageVol",
+primary_classes = ["virDomain", "virNetwork", "virInterface",
+                   "virStoragePool", "virStorageVol",
                    "virConnect", "virNodeDevice" ]
 
 classes_ancestor = {
@@ -629,6 +639,7 @@ classes_ancestor = {
 classes_destructors = {
     "virDomain": "virDomainFree",
     "virNetwork": "virNetworkFree",
+    "virInterface": "virInterfaceFree",
     "virStoragePool": "virStoragePoolFree",
     "virStorageVol": "virStorageVolFree",
     "virNodeDevice" : "virNodeDeviceFree"
@@ -638,6 +649,7 @@ functions_noexcept = {
     'virDomainGetID': True,
     'virDomainGetName': True,
     'virNetworkGetName': True,
+    'virInterfaceGetName': True,
     'virStoragePoolGetName': True,
     'virStorageVolGetName': True,
     'virStorageVolGetkey': True,
@@ -690,6 +702,15 @@ def nameFixup(name, classe, type, file):
     elif name[0:16] == "virNetworkLookup":
         func = name[3:]
         func = string.lower(func[0:1]) + func[1:]
+    elif name[0:18] == "virInterfaceDefine":
+        func = name[3:]
+        func = string.lower(func[0:1]) + func[1:]
+    elif name[0:21] == "virInterfaceCreateXML":
+        func = name[3:]
+        func = string.lower(func[0:1]) + func[1:]
+    elif name[0:18] == "virInterfaceLookup":
+        func = name[3:]
+        func = string.lower(func[0:1]) + func[1:]
     elif name[0:20] == "virStoragePoolDefine":
         func = name[3:]
         func = string.lower(func[0:1]) + func[1:]
@@ -717,6 +738,12 @@ def nameFixup(name, classe, type, file):
     elif name[0:10] == "virNetwork":
         func = name[10:]
         func = string.lower(func[0:1]) + func[1:]
+    elif name[0:15] == "virInterfaceGet":
+        func = name[13:]
+        func = string.lower(func[0:1]) + func[1:]
+    elif name[0:12] == "virInterface":
+        func = name[10:]
+        func = string.lower(func[0:1]) + func[1:]
     elif name[0:17] == "virStoragePoolGet":
         func = name[17:]
         func = string.lower(func[0:1]) + func[1:]
@@ -988,7 +1015,7 @@ def buildWrappers():
            else:
                txt.write("Class %s()\n" % (classname))
                classes.write("class %s:\n" % (classname))
-                if classname in [ "virDomain", "virNetwork", "virStoragePool", "virStorageVol", "virNodeDevice" ]:
+                if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool", "virStorageVol", "virNodeDevice" ]:
                     classes.write("    def __init__(self, conn, _obj=None):\n")
                 else:
                     classes.write("    def __init__(self, _obj=None):\n")
@@ -996,7 +1023,7 @@ def buildWrappers():
                    list = reference_keepers[classname]
                    for ref in list:
                        classes.write("        self.%s = None\n" % ref[1])
-                if classname in [ "virDomain", "virNetwork", "virNodeDevice" ]:
+                if classname in [ "virDomain", "virNetwork", "virInterface", "virNodeDevice" ]:
                     classes.write("        self._conn = conn\n")
                 elif classname in [ "virStorageVol", "virStoragePool" ]:
                     classes.write("        self._conn = conn\n" + \
@@ -1095,6 +1122,10 @@ def buildWrappers():
                                               (name))
                             elif classname == "virNetwork":
                                 classes.write(
+                    "        if ret is None:raise libvirtError('%s() failed', net=self)\n" %
+                                              (name))
+                            elif classname == "virInterface":
+                                classes.write(
                     "        if ret is None:raise libvirtError('%s() failed', net=self)\n" %
                                               (name))
                             elif classname == "virStoragePool":
@@ -1177,6 +1208,10 @@ def buildWrappers():
                                 classes.write (("        if " + test +
                                                 ": raise libvirtError ('%s() failed', net=self)\n") %
                                                ("ret", name))
+                            elif classname == "virInterface":
+                                classes.write (("        if " + test +
+                                                ": raise libvirtError ('%s() failed', net=self)\n") %
+                                               ("ret", name))
                             elif classname == "virStoragePool":
                                 classes.write (("        if " + test +
                                                 ": raise libvirtError ('%s() failed', pool=self)\n") %
@@ -1215,6 +1250,10 @@ def buildWrappers():
                                 classes.write (("        if " + test +
                                                 ": raise libvirtError ('%s() failed', net=self)\n") %
                                                ("ret", name))
+                            elif classname == "virInterface":
+                                classes.write (("        if " + test +
+                                                ": raise libvirtError ('%s() failed', net=self)\n") %
+                                               ("ret", name))
                             elif classname == "virStoragePool":
                                 classes.write (("        if " + test +
                                                 ": raise libvirtError ('%s() failed', pool=self)\n") %
index fa773d2d3c2c8c58b7a43e2d1346bd63129b84f1..158f9f2ac3deba3acfe99b06979802476a20a953 100644 (file)
@@ -48,6 +48,15 @@ typedef struct {
 } PyvirNetwork_Object;
 
 
+#define PyvirInterface_Get(v) (((v) == Py_None) ? NULL : \
+        (((PyvirInterface_Object *)(v))->obj))
+
+typedef struct {
+    PyObject_HEAD
+    virInterfacePtr obj;
+} PyvirInterface_Object;
+
+
 #define PyvirStoragePool_Get(v) (((v) == Py_None) ? NULL : \
         (((PyvirStoragePool_Object *)(v))->obj))
 
@@ -118,6 +127,7 @@ PyObject * libvirt_charPtrConstWrap(const char *str);
 PyObject * libvirt_virConnectPtrWrap(virConnectPtr node);
 PyObject * libvirt_virDomainPtrWrap(virDomainPtr node);
 PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node);
+PyObject * libvirt_virInterfacePtrWrap(virInterfacePtr node);
 PyObject * libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node);
 PyObject * libvirt_virStorageVolPtrWrap(virStorageVolPtr node);
 PyObject * libvirt_virEventHandleCallbackWrap(virEventHandleCallback node);
index 7981f802baa4b7105ec7971313b884c1f6af130d..de75471c909992aa00bb797b3ea75207a09e5cf9 100644 (file)
@@ -118,6 +118,21 @@ libvirt_virNetworkPtrWrap(virNetworkPtr node)
     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)
 {