}
if (esxVI_String_AppendValueListToList(conn, &propertyNameList,
+ "configStatus\0"
"name\0"
"runtime.powerState\0"
- "summary.config.uuid\0") < 0 ||
+ "config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
}
if (esxVI_String_AppendValueListToList(conn, &propertyNameList,
+ "configStatus\0"
"name\0"
"runtime.powerState\0"
- "summary.config.uuid\0") < 0 ||
+ "config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
}
if (esxVI_String_AppendValueListToList(conn, &propertyNameList,
+ "configStatus\0"
"name\0"
"runtime.powerState\0"
- "summary.config.uuid\0") < 0 ||
+ "config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
+int
+esxVI_GetManagedEntityStatus(virConnectPtr conn,
+ esxVI_ObjectContent *objectContent,
+ const char *propertyName,
+ esxVI_ManagedEntityStatus *managedEntityStatus)
+{
+ esxVI_DynamicProperty *dynamicProperty;
+
+ for (dynamicProperty = objectContent->propSet; dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, propertyName)) {
+ return esxVI_ManagedEntityStatus_CastFromAnyType
+ (conn, dynamicProperty->val, managedEntityStatus);
+ }
+ }
+
+ ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+ "Missing '%s' property", propertyName);
+
+ return -1;
+}
+
+
+
int
esxVI_GetVirtualMachinePowerState(virConnectPtr conn,
esxVI_ObjectContent *virtualMachine,
{
const char *uuid_string = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
+ esxVI_ManagedEntityStatus configStatus = esxVI_ManagedEntityStatus_Undefined;
if (STRNEQ(virtualMachine->obj->type, "VirtualMachine")) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
}
if (uuid != NULL) {
- for (dynamicProperty = virtualMachine->propSet;
- dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "summary.config.uuid")) {
- if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
- esxVI_Type_String) < 0) {
- goto failure;
+ if (esxVI_GetManagedEntityStatus(conn, virtualMachine, "configStatus",
+ &configStatus) < 0) {
+ goto failure;
+ }
+
+ if (configStatus == esxVI_ManagedEntityStatus_Green) {
+ for (dynamicProperty = virtualMachine->propSet;
+ dynamicProperty != NULL;
+ dynamicProperty = dynamicProperty->_next) {
+ if (STREQ(dynamicProperty->name, "config.uuid")) {
+ if (esxVI_AnyType_ExpectType(conn, dynamicProperty->val,
+ esxVI_Type_String) < 0) {
+ goto failure;
+ }
+
+ uuid_string = dynamicProperty->val->string;
+ break;
}
+ }
- uuid_string = dynamicProperty->val->string;
- break;
+ if (uuid_string == NULL) {
+ ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+ "Could not get UUID of virtual machine");
+ goto failure;
}
- }
- if (uuid_string == NULL) {
- ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "Could not get UUID of virtual machine");
- goto failure;
- }
+ if (virUUIDParse(uuid_string, uuid) < 0) {
+ ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+ "Could not parse UUID from string '%s'",
+ uuid_string);
+ goto failure;
+ }
+ } else {
+ memset(uuid, 0, VIR_UUID_BUFLEN);
- if (virUUIDParse(uuid_string, uuid) < 0) {
- ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "Could not parse UUID from string '%s'", uuid_string);
- goto failure;
+ VIR_WARN0("Cannot access UUID, because 'configStatus' property "
+ "indicates a config problem");
}
}
esxVI_Boolean recurse,
esxVI_ObjectContent **objectContentList);
+int esxVI_GetManagedEntityStatus
+ (virConnectPtr conn, esxVI_ObjectContent *objectContent,
+ const char *propertyName,
+ esxVI_ManagedEntityStatus *managedEntityStatus);
+
int esxVI_GetVirtualMachinePowerState
(virConnectPtr conn, esxVI_ObjectContent *virtualMachine,
esxVI_VirtualMachinePowerState *powerState);
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Enum: ManagedEntityStatus
+ */
+
+static const esxVI_Enumeration _esxVI_ManagedEntityStatus_Enumeration = {
+ "ManagedEntityStatus", {
+ { "gray", esxVI_ManagedEntityStatus_Gray },
+ { "green", esxVI_ManagedEntityStatus_Green },
+ { "yellow", esxVI_ManagedEntityStatus_Yellow },
+ { "red", esxVI_ManagedEntityStatus_Red },
+ { NULL, -1 },
+ },
+};
+
+/* esxVI_ManagedEntityStatus_CastFromAnyType */
+ESX_VI__TEMPLATE__ENUMERATION__CAST_FROM_ANY_TYPE(ManagedEntityStatus);
+
+
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: ObjectUpdateKind
*/
* VI Enums
*/
+typedef enum _esxVI_ManagedEntityStatus esxVI_ManagedEntityStatus;
typedef enum _esxVI_ObjectUpdateKind esxVI_ObjectUpdateKind;
typedef enum _esxVI_PerfSummaryType esxVI_PerfSummaryType;
typedef enum _esxVI_PerfStatsType esxVI_PerfStatsType;
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * VI Enum: ManagedEntityStatus
+ */
+
+enum _esxVI_ManagedEntityStatus {
+ esxVI_ManagedEntityStatus_Undefined = 0,
+ esxVI_ManagedEntityStatus_Gray,
+ esxVI_ManagedEntityStatus_Green,
+ esxVI_ManagedEntityStatus_Yellow,
+ esxVI_ManagedEntityStatus_Red,
+};
+
+int esxVI_ManagedEntityStatus_CastFromAnyType
+ (virConnectPtr conn, esxVI_AnyType *anyType,
+ esxVI_ManagedEntityStatus *managedEntityStatus);
+
+
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* VI Enum: ObjectUpdateKind
*/