Modeled after the already existing esxVI_GetLong.
---
src/esx/esx_vi.c | 32 ++++++++++++++++++++++++++++++++
src/esx/esx_vi.h | 3 +++
src/esx/esx_vi_types.c | 3 +++
src/esx/esx_vi_types.h | 1 +
4 files changed, 39 insertions(+)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index bbec912..af822b1 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -2413,6 +2413,38 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char
*propertyName,
int
+esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
+ esxVI_Int **value, esxVI_Occurrence occurence)
+{
+ esxVI_DynamicProperty *dynamicProperty;
+
+ if (!value || *value) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid
argument"));
+ return -1;
+ }
+
+ for (dynamicProperty = objectContent->propSet; dynamicProperty;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, propertyName)) {
+ if (esxVI_Int_CastFromAnyType(dynamicProperty->val, value) < 0)
+ return -1;
+
+ break;
+ }
+ }
+
+ if (!(*value) && occurence == esxVI_Occurrence_RequiredItem) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Missing '%s' property"), propertyName);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+
+int
esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence)
{
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index b7f0160..c41541e 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -338,6 +338,9 @@ int esxVI_GetBoolean(esxVI_ObjectContent *objectContent,
const char *propertyName,
esxVI_Boolean *value, esxVI_Occurrence occurrence);
+int esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
+ esxVI_Int **value, esxVI_Occurrence occurrence);
+
int esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence);
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 1502467..6b558e5 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -1376,6 +1376,9 @@ ESX_VI__TEMPLATE__DEEP_COPY(Int,
(*dest)->value = src->value;
})
+/* esxVI_Int_CastFromAnyType */
+ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Int)
+
/* esxVI_Int_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Int,
{
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index 34901d7..66a5705 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -241,6 +241,7 @@ void esxVI_Int_Free(esxVI_Int **numberList);
int esxVI_Int_Validate(esxVI_Int *number);
int esxVI_Int_AppendToList(esxVI_Int **numberList, esxVI_Int *number);
int esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src);
+int esxVI_Int_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Int **number);
int esxVI_Int_Serialize(esxVI_Int *number, const char *element,
virBufferPtr output);
int esxVI_Int_SerializeList(esxVI_Int *numberList, const char *element,
--
2.1.0