ESX: Unify naming of VI API utility and convenience functions.

Unified function naming scheme:
- 'lookup' functions query the ESX or vCenter for information
- 'get' functions return information from a local object

* src/esx/esx_driver.c, src/esx/esx_vi.[ch]: unify function naming
This commit is contained in:
Matthias Bolte 2009-10-18 21:31:46 +02:00
parent 7c7681dd90
commit 447ef8863c
3 changed files with 116 additions and 88 deletions

View File

@ -90,7 +90,8 @@ esxSupportsLongMode(virConnectPtr conn)
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"hardware.cpuFeature") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->hostFolder,
esxVI_LookupObjectContentByType(conn, priv->host,
priv->host->hostFolder,
"HostSystem", propertyNameList,
esxVI_Boolean_True, &hostSystem) < 0) {
goto failure;
@ -522,7 +523,8 @@ esxSupportsVMotion(virConnectPtr conn)
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"capability.vmotionSupported") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->hostFolder,
esxVI_LookupObjectContentByType(conn, priv->host,
priv->host->hostFolder,
"HostSystem", propertyNameList,
esxVI_Boolean_True, &hostSystem) < 0) {
goto failure;
@ -653,7 +655,8 @@ esxGetHostname(virConnectPtr conn)
(conn, &propertyNameList,
"config.network.dnsConfig.hostName\0"
"config.network.dnsConfig.domainName\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->hostFolder,
esxVI_LookupObjectContentByType(conn, priv->host,
priv->host->hostFolder,
"HostSystem", propertyNameList,
esxVI_Boolean_True, &hostSystem) < 0) {
goto failure;
@ -750,7 +753,8 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
"hardware.memorySize\0"
"hardware.numaInfo.numNodes\0"
"summary.hardware.cpuModel\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->hostFolder,
esxVI_LookupObjectContentByType(conn, priv->host,
priv->host->hostFolder,
"HostSystem", propertyNameList,
esxVI_Boolean_True, &hostSystem) < 0) {
goto failure;
@ -914,9 +918,10 @@ esxListDomains(virConnectPtr conn, int *ids, int maxids)
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"runtime.powerState") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
esxVI_LookupObjectContentByType(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -970,7 +975,7 @@ esxNumberOfDomains(virConnectPtr conn)
return -1;
}
return esxVI_GetNumberOfDomainsByPowerState
return esxVI_LookupNumberOfDomainsByPowerState
(conn, priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_False);
}
@ -999,9 +1004,10 @@ esxDomainLookupByID(virConnectPtr conn, int id)
"name\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
esxVI_LookupObjectContentByType(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -1082,9 +1088,10 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
"name\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
esxVI_LookupObjectContentByType(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -1168,9 +1175,10 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
"name\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
esxVI_LookupObjectContentByType(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -2042,7 +2050,7 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList,
"capability.maxSupportedVcpus") < 0 ||
esxVI_GetObjectContent(domain->conn, priv->host,
esxVI_LookupObjectContentByType(domain->conn, priv->host,
priv->host->hostFolder, "HostSystem",
propertyNameList, esxVI_Boolean_True,
&hostSystem) < 0) {
@ -2270,9 +2278,10 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
if (esxVI_String_AppendValueListToList(conn, &propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
esxVI_GetObjectContent(conn, priv->host, priv->host->vmFolder,
esxVI_LookupObjectContentByType(conn, priv->host, priv->host->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True, &virtualMachineList) < 0) {
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -2337,7 +2346,7 @@ esxNumberOfDefinedDomains(virConnectPtr conn)
return -1;
}
return esxVI_GetNumberOfDomainsByPowerState
return esxVI_LookupNumberOfDomainsByPowerState
(conn, priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_True);
}
@ -2550,7 +2559,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
goto failure;
}
if (esxVI_GetResourcePool(conn, priv->host, hostSystem,
if (esxVI_LookupResourcePoolByHostSystem(conn, priv->host, hostSystem,
&resourcePool) < 0) {
goto failure;
}
@ -3071,8 +3080,8 @@ esxDomainMigratePerform(virDomainPtr domain,
goto failure;
}
if (esxVI_GetResourcePool(domain->conn, priv->vCenter, hostSystem,
&resourcePool) < 0) {
if (esxVI_LookupResourcePoolByHostSystem(domain->conn, priv->vCenter,
hostSystem, &resourcePool) < 0) {
goto failure;
}
@ -3172,7 +3181,7 @@ esxNodeGetFreeMemory(virConnectPtr conn)
goto failure;
}
if (esxVI_GetResourcePool(conn, priv->host, hostSystem,
if (esxVI_LookupResourcePoolByHostSystem(conn, priv->host, hostSystem,
&managedObjectReference) < 0) {
goto failure;
}
@ -3182,9 +3191,11 @@ esxNodeGetFreeMemory(virConnectPtr conn)
/* Get memory usage of resource pool */
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"runtime.memory") < 0 ||
esxVI_GetObjectContent(conn, priv->host, managedObjectReference,
esxVI_LookupObjectContentByType(conn, priv->host,
managedObjectReference,
"ResourcePool", propertyNameList,
esxVI_Boolean_False, &resourcePool) < 0) {
esxVI_Boolean_False,
&resourcePool) < 0) {
goto failure;
}

View File

@ -374,9 +374,10 @@ esxVI_Context_Connect(virConnectPtr conn, esxVI_Context *ctx, const char *url,
}
/* Get pointer to Datacenter for later use */
if (esxVI_GetObjectContent(conn, ctx, ctx->service->rootFolder,
if (esxVI_LookupObjectContentByType(conn, ctx, ctx->service->rootFolder,
"Datacenter", propertyNameList,
esxVI_Boolean_True, &datacenterList) < 0) {
esxVI_Boolean_True,
&datacenterList) < 0) {
goto failure;
}
@ -1061,6 +1062,10 @@ esxVI_List_Deserialize(virConnectPtr conn, xmlNodePtr node, esxVI_List **list,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Utility and Convenience Functions
*
* Function naming scheme:
* - 'lookup' functions query the ESX or vCenter for information
* - 'get' functions get information from a local object
*/
int
@ -1301,9 +1306,11 @@ esxVI_EnsureSession(virConnectPtr conn, esxVI_Context *ctx)
#else
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"currentSession") < 0 ||
esxVI_GetObjectContent(conn, ctx, ctx->service->sessionManager,
esxVI_LookupObjectContentByType(conn, ctx,
ctx->service->sessionManager,
"SessionManager", propertyNameList,
esxVI_Boolean_False, &sessionManager) < 0) {
esxVI_Boolean_False,
&sessionManager) < 0) {
goto failure;
}
@ -1358,9 +1365,10 @@ esxVI_EnsureSession(virConnectPtr conn, esxVI_Context *ctx)
int
esxVI_GetObjectContent(virConnectPtr conn, esxVI_Context *ctx,
esxVI_LookupObjectContentByType(virConnectPtr conn, esxVI_Context *ctx,
esxVI_ManagedObjectReference *root,
const char *type, esxVI_String *propertyNameList,
const char *type,
esxVI_String *propertyNameList,
esxVI_Boolean recurse,
esxVI_ObjectContent **objectContentList)
{
@ -1479,7 +1487,7 @@ esxVI_GetVirtualMachinePowerState(virConnectPtr conn,
int
esxVI_GetNumberOfDomainsByPowerState(virConnectPtr conn, esxVI_Context *ctx,
esxVI_LookupNumberOfDomainsByPowerState(virConnectPtr conn, esxVI_Context *ctx,
esxVI_VirtualMachinePowerState powerState,
esxVI_Boolean inverse)
{
@ -1492,8 +1500,9 @@ esxVI_GetNumberOfDomainsByPowerState(virConnectPtr conn, esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"runtime.powerState") < 0 ||
esxVI_GetObjectContent(conn, ctx, ctx->vmFolder, "VirtualMachine",
propertyNameList, esxVI_Boolean_True,
esxVI_LookupObjectContentByType(conn, ctx, ctx->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
goto failure;
}
@ -1646,8 +1655,9 @@ esxVI_GetVirtualMachineIdentity(virConnectPtr conn,
int esxVI_GetResourcePool(virConnectPtr conn, esxVI_Context *ctx,
esxVI_ObjectContent *hostSystem,
int
esxVI_LookupResourcePoolByHostSystem
(virConnectPtr conn, esxVI_Context *ctx, esxVI_ObjectContent *hostSystem,
esxVI_ManagedObjectReference **resourcePool)
{
int result = 0;
@ -1684,9 +1694,10 @@ int esxVI_GetResourcePool(virConnectPtr conn, esxVI_Context *ctx,
if (esxVI_String_AppendValueToList(conn, &propertyNameList,
"resourcePool") < 0 ||
esxVI_GetObjectContent(conn, ctx, managedObjectReference,
esxVI_LookupObjectContentByType(conn, ctx, managedObjectReference,
"ComputeResource", propertyNameList,
esxVI_Boolean_False, &computeResource) < 0) {
esxVI_Boolean_False,
&computeResource) < 0) {
goto failure;
}
@ -1751,7 +1762,7 @@ esxVI_LookupHostSystemByIp(virConnectPtr conn, esxVI_Context *ctx,
goto failure;
}
if (esxVI_GetObjectContent(conn, ctx, managedObjectReference,
if (esxVI_LookupObjectContentByType(conn, ctx, managedObjectReference,
"HostSystem", propertyNameList,
esxVI_Boolean_False, hostSystem) < 0) {
goto failure;
@ -1803,9 +1814,10 @@ esxVI_LookupVirtualMachineByUuid(virConnectPtr conn, esxVI_Context *ctx,
}
}
if (esxVI_GetObjectContent(conn, ctx, managedObjectReference,
if (esxVI_LookupObjectContentByType(conn, ctx, managedObjectReference,
"VirtualMachine", propertyNameList,
esxVI_Boolean_False, virtualMachine) < 0) {
esxVI_Boolean_False,
virtualMachine) < 0) {
goto failure;
}
@ -1852,9 +1864,10 @@ esxVI_LookupDatastoreByName(virConnectPtr conn, esxVI_Context *ctx,
goto failure;
}
if (esxVI_GetObjectContent(conn, ctx, ctx->datacenter,
if (esxVI_LookupObjectContentByType(conn, ctx, ctx->datacenter,
"Datastore", completePropertyNameList,
esxVI_Boolean_True, &datastoreList) < 0) {
esxVI_Boolean_True,
&datastoreList) < 0) {
goto failure;
}

View File

@ -192,27 +192,31 @@ int esxVI_List_Deserialize(virConnectPtr conn, xmlNodePtr node,
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Utility and Convenience Functions
*
* Function naming scheme:
* - 'lookup' functions query the ESX or vCenter for information
* - 'get' functions get information from a local object
*/
int
esxVI_Alloc(virConnectPtr conn, void **ptrptr, size_t size);
int esxVI_Alloc(virConnectPtr conn, void **ptrptr, size_t size);
int
esxVI_CheckSerializationNecessity(virConnectPtr conn, const char *element,
int esxVI_CheckSerializationNecessity(virConnectPtr conn, const char *element,
esxVI_Boolean required);
int esxVI_BuildFullTraversalSpecItem
(virConnectPtr conn, esxVI_SelectionSpec **fullTraversalSpecList,
const char *name, const char *type, const char *path,
const char *selectSetNames);
int esxVI_BuildFullTraversalSpecList
(virConnectPtr conn, esxVI_SelectionSpec **fullTraversalSpecList);
int esxVI_EnsureSession(virConnectPtr conn, esxVI_Context *ctx);
int esxVI_GetObjectContent(virConnectPtr conn, esxVI_Context *ctx,
int esxVI_LookupObjectContentByType(virConnectPtr conn, esxVI_Context *ctx,
esxVI_ManagedObjectReference *root,
const char *type, esxVI_String *propertyNameList,
const char *type,
esxVI_String *propertyNameList,
esxVI_Boolean recurse,
esxVI_ObjectContent **objectContentList);
@ -225,7 +229,7 @@ int esxVI_GetVirtualMachinePowerState
(virConnectPtr conn, esxVI_ObjectContent *virtualMachine,
esxVI_VirtualMachinePowerState *powerState);
int esxVI_GetNumberOfDomainsByPowerState
int esxVI_LookupNumberOfDomainsByPowerState
(virConnectPtr conn, esxVI_Context *ctx,
esxVI_VirtualMachinePowerState powerState, esxVI_Boolean inverse);
@ -233,8 +237,8 @@ int esxVI_GetVirtualMachineIdentity(virConnectPtr conn,
esxVI_ObjectContent *virtualMachine,
int *id, char **name, unsigned char *uuid);
int esxVI_GetResourcePool(virConnectPtr conn, esxVI_Context *ctx,
esxVI_ObjectContent *hostSystem,
int esxVI_LookupResourcePoolByHostSystem
(virConnectPtr conn, esxVI_Context *ctx, esxVI_ObjectContent *hostSystem,
esxVI_ManagedObjectReference **resourcePool);
int esxVI_LookupHostSystemByIp(virConnectPtr conn, esxVI_Context *ctx,