Accept all types on deserialization in order to accept all Event subtypes. This will be used for the upcoming domain event support. --- src/esx/esx_vi_generator.input | 21 ++++---- src/esx/esx_vi_generator.py | 1 - src/esx/esx_vi_types.c | 100 ++++++++++++++++++++++++++++++++++++++- src/esx/esx_vi_types.h | 34 ++++++++++++++ 4 files changed, 142 insertions(+), 14 deletions(-) diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input index 98b5206..4ec9f93 100644 --- a/src/esx/esx_vi_generator.input +++ b/src/esx/esx_vi_generator.input @@ -209,16 +209,12 @@ object ElementDescription extends Description end -object Event - Int key r - Int chainId r - DateTime createdTime r - String userName r - DatacenterEventArgument datacenter i - ComputeResourceEventArgument computeResource i - HostEventArgument host i - VmEventArgument vm i - String fullFormattedMessage o +object EntityEventArgument extends EventArgument + String name r +end + + +object EventArgument end @@ -709,6 +705,11 @@ object VmDiskFileQueryFlags end +object VmEventArgument extends EntityEventArgument + ManagedObjectReference vm r +end + + object VmLogFileInfo extends FileInfo end diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index ab127a3..ac15c7f 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -1430,7 +1430,6 @@ additional_object_features = { "AutoStartDefaults" : Object.FEATURE__AN "AutoStartPowerInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST, "DatastoreHostMount" : Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE, "DatastoreInfo" : Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST, - "Event" : Object.FEATURE__LIST, "FileInfo" : Object.FEATURE__DYNAMIC_CAST, "FileQuery" : Object.FEATURE__DYNAMIC_CAST, "HostConfigManager" : Object.FEATURE__ANY_TYPE, diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index d264583..dd83954 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -271,13 +271,14 @@ -#define ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, _extra, _deserialize) \ +#define ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, _extra1, _extra2, \ + _deserialize) \ int \ esxVI_##_type##_Deserialize(xmlNodePtr node, esxVI_##_type **ptrptr) \ { \ xmlNodePtr childNode = NULL; \ \ - _extra \ + _extra1 \ \ if (ptrptr == NULL || *ptrptr != NULL) { \ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", \ @@ -289,6 +290,8 @@ return -1; \ } \ \ + _extra2 \ + \ for (childNode = node->children; childNode != NULL; \ childNode = childNode->next) { \ if (childNode->type != XML_ELEMENT_NODE) { \ @@ -317,7 +320,8 @@ #define ESX_VI__TEMPLATE__DESERIALIZE(_type, _deserialize) \ - ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, /* nothing */, _deserialize) + ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(_type, /* nothing */, /* nothing */, \ + _deserialize) @@ -647,6 +651,7 @@ __FUNCTION__, esxVI_Type_ToString(type)); \ return -1; \ }, \ + /* nothing */, \ _deserialize) @@ -773,6 +778,9 @@ esxVI_Type_ToString(esxVI_Type type) case esxVI_Type_ManagedObjectReference: return "ManagedObjectReference"; + case esxVI_Type_Event: + return "Event"; + #include "esx_vi_types.generated.typetostring" case esxVI_Type_Other: @@ -805,6 +813,8 @@ esxVI_Type_FromString(const char *type) return esxVI_Type_MethodFault; } else if (STREQ(type, "ManagedObjectReference")) { return esxVI_Type_ManagedObjectReference; + } else if (STREQ(type, "Event")) { + return esxVI_Type_Event; } #include "esx_vi_types.generated.typefromstring" @@ -1664,6 +1674,90 @@ esxVI_ManagedObjectReference_Deserialize +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * VI Type: Event + */ + +/* esxVI_Event_Alloc */ +ESX_VI__TEMPLATE__ALLOC(Event) + +/* esxVI_Event_Free */ +ESX_VI__TEMPLATE__FREE(Event, +{ + esxVI_Event_Free(&item->_next); + VIR_FREE(item->_actualType); + + esxVI_Int_Free(&item->key); + esxVI_Int_Free(&item->chainId); + esxVI_DateTime_Free(&item->createdTime); + VIR_FREE(item->userName); + /* FIXME: datacenter is currently ignored */ + /* FIXME: computeResource is currently ignored */ + /* FIXME: host is currently ignored */ + esxVI_VmEventArgument_Free(&item->vm); + VIR_FREE(item->fullFormattedMessage); +}) + +/* esxVI_Event_Validate */ +ESX_VI__TEMPLATE__VALIDATE(Event, +{ + ESX_VI__TEMPLATE__PROPERTY__REQUIRE(key) + ESX_VI__TEMPLATE__PROPERTY__REQUIRE(chainId) + ESX_VI__TEMPLATE__PROPERTY__REQUIRE(createdTime) + ESX_VI__TEMPLATE__PROPERTY__REQUIRE(userName) + /* FIXME: datacenter is currently ignored */ + /* FIXME: computeResource is currently ignored */ + /* FIXME: host is currently ignored */ +}) + +/* esxVI_Event_AppendToList */ +ESX_VI__TEMPLATE__LIST__APPEND(Event) + +/* esxVI_Event_CastFromAnyType */ +ESX_VI__TEMPLATE__DYNAMIC_CAST_FROM_ANY_TYPE(Event, +{ + case esxVI_Type_Other: + /* Just accept everything here */ + break; +}) + +/* esxVI_Event_CastListFromAnyType */ +ESX_VI__TEMPLATE__LIST__CAST_FROM_ANY_TYPE(Event) + +/* esxVI_Event_Deserialize */ +ESX_VI__TEMPLATE__DESERIALIZE_EXTRA(Event, /* nothing */, +{ + (*ptrptr)->_actualType = + (char *)xmlGetNsProp(node, BAD_CAST "type", + BAD_CAST "http://www.w3.org/2001/XMLSchema-instance"); + + if ((*ptrptr)->_actualType == NULL) { + ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, + _("%s is missing 'type' property"), + esxVI_Type_ToString((*ptrptr)->_type)); + goto failure; + } +}, +{ + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, key) + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(Int, chainId) + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(DateTime, createdTime) + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, userName) + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(datacenter) /* FIXME */ + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(computeResource) /* FIXME */ + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_IGNORE(host) /* FIXME */ + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE(VmEventArgument, vm) + ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, fullFormattedMessage) + + /* Don't warn about unexpected properties */ + continue; +}) + +/* esxVI_Event_DeserializeList */ +ESX_VI__TEMPLATE__LIST__DESERIALIZE(Event) + + + #include "esx_vi_types.generated.c" diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h index ac3741f..d141a38 100644 --- a/src/esx/esx_vi_types.h +++ b/src/esx/esx_vi_types.h @@ -55,8 +55,10 @@ typedef struct _esxVI_Fault esxVI_Fault; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * VI Objects */ + typedef struct _esxVI_MethodFault esxVI_MethodFault; typedef struct _esxVI_ManagedObjectReference esxVI_ManagedObjectReference; +typedef struct _esxVI_Event esxVI_Event; # include "esx_vi_types.generated.typedef" @@ -78,6 +80,7 @@ enum _esxVI_Type { esxVI_Type_Fault, esxVI_Type_MethodFault, esxVI_Type_ManagedObjectReference, + esxVI_Type_Event, # include "esx_vi_types.generated.typeenum" @@ -345,6 +348,37 @@ int esxVI_ManagedObjectReference_Deserialize +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * VI Type: Event + */ + +struct _esxVI_Event { + esxVI_Event *_next; /* optional */ + esxVI_Type _type; /* required */ + char *_actualType; /* required */ + + esxVI_Int *key; /* required */ + esxVI_Int *chainId; /* required */ + esxVI_DateTime *createdTime; /* required */ + char *userName; /* required */ + /* FIXME: datacenter is currently ignored */ + /* FIXME: computeResource is currently ignored */ + /* FIXME: host is currently ignored */ + esxVI_VmEventArgument *vm; /* optional */ + char *fullFormattedMessage; /* optional */ +}; + +int esxVI_Event_Alloc(esxVI_Event **item); +void esxVI_Event_Free(esxVI_Event **item); +int esxVI_Event_Validate(esxVI_Event *item); +int esxVI_Event_AppendToList(esxVI_Event **list, esxVI_Event *item); +int esxVI_Event_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Event **item); +int esxVI_Event_CastListFromAnyType(esxVI_AnyType *anyType, esxVI_Event **list); +int esxVI_Event_Deserialize(xmlNodePtr node, esxVI_Event **item); +int esxVI_Event_DeserializeList(xmlNodePtr node, esxVI_Event **list); + + + # include "esx_vi_types.generated.h" -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list