]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: Generate object property type information
authorSri Ramanujam <sramanujam@datto.com>
Tue, 27 Jun 2017 19:13:24 +0000 (15:13 -0400)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 8 Jul 2017 11:44:59 +0000 (13:44 +0200)
Update the generator to generate basic property type information for
each CIM object representation. Right now, it generates arrays of
hypervCimType structs:

struct _hypervCimType {
    const char *name;
    const char *type;
    bool isArray;
};

src/hyperv/hyperv_wmi_classes.h
src/hyperv/hyperv_wmi_generator.py

index f7d596febf73018418b4060e4054a359a449e2ac..ce4643e9d3a1e6209a240e01d6e0ee3e0a586da5 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * hyperv_wmi_classes.h: WMI classes for managing Microsoft Hyper-V hosts
  *
+ * Copyright (C) 2017 Datto Inc
  * Copyright (C) 2011 Matthias Bolte <matthias.bolte@googlemail.com>
  * Copyright (C) 2009 Michael Sievers <msievers83@googlemail.com>
  *
@@ -23,6 +24,7 @@
 #ifndef __HYPERV_WMI_CLASSES_H__
 # define __HYPERV_WMI_CLASSES_H__
 
+# include "internal.h"
 # include "openwsman.h"
 
 # include "hyperv_wmi_classes.generated.typedef"
@@ -96,6 +98,21 @@ enum _Msvm_ConcreteJob_JobState {
 };
 
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * WMI
+ */
+
+typedef struct _hypervCimType hypervCimType;
+typedef hypervCimType *hypervCimTypePtr;
+struct _hypervCimType {
+    /* Parameter name */
+    const char *name;
+    /* Parameter type */
+    const char *type;
+    /* whether parameter is an array type */
+    bool isArray;
+};
+
 typedef struct _hypervWmiClassInfo hypervWmiClassInfo;
 typedef hypervWmiClassInfo *hypervWmiClassInfoPtr;
 struct _hypervWmiClassInfo {
@@ -109,6 +126,8 @@ struct _hypervWmiClassInfo {
     const char *resourceUri;
     /* The wsman serializer info - one of the *_TypeInfo structs */
     XmlSerializerInfo *serializerInfo;
+    /* Property type information */
+    hypervCimTypePtr propertyInfo;
 };
 
 
index 9aee0b9bf377e9fbcccd1237baf4e92bdf714dcc..9c0accea05bdea88cb7aa86b15ff5c0227b39016 100755 (executable)
@@ -122,6 +122,14 @@ class WmiClass:
 
             source += "SER_END_ITEMS(%s_Data);\n\n" % cls.name
 
+            # also generate typemap data while we're here
+            source += "hypervCimType %s_Typemap[] = {\n" % cls.name
+
+            for property in cls.properties:
+                source += property.generate_typemap()
+            source += '    { "", "", 0 },\n' # null terminated
+            source += '};\n\n'
+
 
         source += self._define_WmiInfo_struct()
         source += "\n\n"
@@ -222,7 +230,8 @@ class WmiClass:
                 source += "            .version = NULL,\n"
             source += "            .rootUri = %s,\n" % cls.uri_info.rootUri
             source += "            .resourceUri = %s_RESOURCE_URI,\n" % cls.name.upper()
-            source += "            .serializerInfo = %s_Data_TypeInfo\n" % cls.name
+            source += "            .serializerInfo = %s_Data_TypeInfo,\n" % cls.name
+            source += "            .propertyInfo = %s_Typemap\n" % cls.name
             source += "        },\n"
 
         source += "    }\n"
@@ -374,6 +383,10 @@ class Property:
                    % (Property.typemap[self.type], class_name.upper(), self.name)
 
 
+    def generate_typemap(self):
+        return '    { "%s", "%s", %s },\n' % (self.name, self.type.lower(), str(self.is_array).lower())
+
+
 
 def open_and_print(filename):
     if filename.startswith("./"):