typedef struct _esxPrivate {
esxVI_Context *host;
- esxVI_Context *vcenter;
+ esxVI_Context *vCenter;
int phantom; // boolean
char *transport;
- int32_t nvcpus_max;
- esxVI_Boolean supports_vmotion;
+ int32_t maxVcpus;
+ esxVI_Boolean supportsVMotion;
int32_t usedCpuTimeCounterId;
} esxPrivate;
esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{
esxPrivate *priv = NULL;
- char dummy_string[NI_MAXHOST] = "";
+ char ipAddress[NI_MAXHOST] = "";
char *url = NULL;
- char *vcenter = NULL;
+ char *vCenter = NULL;
int noVerify = 0; // boolean
char *username = NULL;
char *password = NULL;
}
priv->phantom = phantom;
- priv->nvcpus_max = -1;
- priv->supports_vmotion = esxVI_Boolean_Undefined;
+ priv->maxVcpus = -1;
+ priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->usedCpuTimeCounterId = -1;
/* Request credentials and login to non-phantom host/vCenter */
if (! phantom) {
- if (esxUtil_ParseQuery(conn, &priv->transport, &vcenter,
+ if (esxUtil_ParseQuery(conn, &priv->transport, &vCenter,
&noVerify) < 0) {
goto failure;
}
- if (esxUtil_ResolveHostname(conn, conn->uri->server, dummy_string,
+ if (esxUtil_ResolveHostname(conn, conn->uri->server, ipAddress,
NI_MAXHOST) < 0) {
goto failure;
}
- if (vcenter != NULL &&
- esxUtil_ResolveHostname(conn, vcenter, dummy_string,
+ if (vCenter != NULL &&
+ esxUtil_ResolveHostname(conn, vCenter, ipAddress,
NI_MAXHOST) < 0) {
goto failure;
}
VIR_FREE(password);
VIR_FREE(username);
- if (vcenter != NULL) {
+ if (vCenter != NULL) {
if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
- vcenter) < 0) {
+ vCenter) < 0) {
virReportOOMError(conn);
goto failure;
}
- if (esxVI_Context_Alloc(conn, &priv->vcenter) < 0) {
+ if (esxVI_Context_Alloc(conn, &priv->vCenter) < 0) {
goto failure;
}
- username = esxUtil_RequestUsername(auth, "administrator", vcenter);
+ username = esxUtil_RequestUsername(auth, "administrator", vCenter);
if (username == NULL) {
ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
goto failure;
}
- password = esxUtil_RequestPassword(auth, username, vcenter);
+ password = esxUtil_RequestPassword(auth, username, vCenter);
if (password == NULL) {
ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
goto failure;
}
- if (esxVI_Context_Connect(conn, priv->vcenter, url, username,
+ if (esxVI_Context_Connect(conn, priv->vCenter, url, username,
password, noVerify) < 0) {
goto failure;
}
- if (priv->vcenter->productVersion != esxVI_ProductVersion_VPX25 &&
- priv->vcenter->productVersion != esxVI_ProductVersion_VPX40) {
+ if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
+ priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"%s is neither a vCenter 2.5 server nor a vCenter "
"4.0 server",
VIR_FREE(username);
}
- VIR_FREE(vcenter);
+ VIR_FREE(vCenter);
}
conn->privateData = priv;
failure:
VIR_FREE(url);
- VIR_FREE(vcenter);
+ VIR_FREE(vCenter);
VIR_FREE(password);
VIR_FREE(username);
if (priv != NULL) {
esxVI_Context_Free(&priv->host);
- esxVI_Context_Free(&priv->vcenter);
+ esxVI_Context_Free(&priv->vCenter);
VIR_FREE(priv->transport);
VIR_FREE(priv);
esxVI_Logout(conn, priv->host);
esxVI_Context_Free(&priv->host);
- if (priv->vcenter != NULL) {
- esxVI_EnsureSession(conn, priv->vcenter);
+ if (priv->vCenter != NULL) {
+ esxVI_EnsureSession(conn, priv->vCenter);
- esxVI_Logout(conn, priv->vcenter);
- esxVI_Context_Free(&priv->vcenter);
+ esxVI_Logout(conn, priv->vCenter);
+ esxVI_Context_Free(&priv->vCenter);
}
}
goto failure;
}
- if (priv->supports_vmotion != esxVI_Boolean_Undefined) {
- return priv->supports_vmotion;
+ if (priv->supportsVMotion != esxVI_Boolean_Undefined) {
+ return priv->supportsVMotion;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
- priv->supports_vmotion = dynamicProperty->val->boolean;
+ priv->supportsVMotion = dynamicProperty->val->boolean;
break;
} else {
VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&hostSystem);
- return priv->supports_vmotion;
+ return priv->supportsVMotion;
failure:
- priv->supports_vmotion = esxVI_Boolean_Undefined;
+ priv->supportsVMotion = esxVI_Boolean_Undefined;
goto cleanup;
}
esxSupportsFeature(virConnectPtr conn, int feature)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
- esxVI_Boolean supports_vmotion = esxVI_Boolean_Undefined;
+ esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
switch (feature) {
case VIR_DRV_FEATURE_MIGRATION_V1:
- supports_vmotion = esxSupportsVMotion(conn);
+ supportsVMotion = esxSupportsVMotion(conn);
- if (supports_vmotion == esxVI_Boolean_Undefined) {
+ if (supportsVMotion == esxVI_Boolean_Undefined) {
return -1;
}
- /*
- * Migration is only possible via a Virtual Center and if VMotion is
- * enabled
- */
- return priv->vcenter != NULL &&
- supports_vmotion == esxVI_Boolean_True ? 1 : 0;
+ /* Migration is only possible via a vCenter and if VMotion is enabled */
+ return priv->vCenter != NULL &&
+ supportsVMotion == esxVI_Boolean_True ? 1 : 0;
default:
return 0;
esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState;
- int id_ = -1;
- char *name_ = NULL;
- unsigned char uuid_[VIR_UUID_BUFLEN];
+ int id_candidate = -1;
+ char *name_candidate = NULL;
+ unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
if (priv->phantom) {
continue;
}
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
- if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_,
- &name_, uuid_) < 0) {
+ if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
+ &id_candidate, &name_candidate,
+ uuid_candidate) < 0) {
goto failure;
}
- if (id_ != id) {
+ if (id != id_candidate) {
continue;
}
- domain = virGetDomain(conn, name_, uuid_);
+ domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) {
goto failure;
cleanup:
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
return domain;
esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState;
- int id_ = -1;
- char *name_ = NULL;
- unsigned char uuid_[VIR_UUID_BUFLEN];
+ int id_candidate = -1;
+ char *name_candidate = NULL;
+ unsigned char uuid_candidate[VIR_UUID_BUFLEN];
char uuid_string[VIR_UUID_STRING_BUFLEN];
virDomainPtr domain = NULL;
for (virtualMachine = virtualMachineList; virtualMachine != NULL;
virtualMachine = virtualMachine->_next) {
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
- if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_,
- &name_, uuid_) < 0) {
+ if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
+ &id_candidate, &name_candidate,
+ uuid_candidate) < 0) {
goto failure;
}
- if (memcmp(uuid, uuid_,
+ if (memcmp(uuid, uuid_candidate,
VIR_UUID_BUFLEN * sizeof (unsigned char)) != 0) {
continue;
}
- domain = virGetDomain(conn, name_, uuid);
+ domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) {
goto failure;
/* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
- domain->id = id_;
+ domain->id = id_candidate;
} else {
domain->id = -1;
}
cleanup:
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
return domain;
esxVI_ObjectContent *virtualMachineList = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachinePowerState powerState;
- int id_ = -1;
- char *name_ = NULL;
- unsigned char uuid_[VIR_UUID_BUFLEN];
+ int id_candidate = -1;
+ char *name_candidate = NULL;
+ unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
if (priv->phantom) {
for (virtualMachine = virtualMachineList; virtualMachine != NULL;
virtualMachine = virtualMachine->_next) {
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
- if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine, &id_,
- &name_, uuid_) < 0) {
+ if (esxVI_GetVirtualMachineIdentity(conn, virtualMachine,
+ &id_candidate, &name_candidate,
+ uuid_candidate) < 0) {
goto failure;
}
- if (STRNEQ(name_, name)) {
+ if (STRNEQ(name, name_candidate)) {
continue;
}
- domain = virGetDomain(conn, name, uuid_);
+ domain = virGetDomain(conn, name_candidate, uuid_candidate);
if (domain == NULL) {
goto failure;
/* Only running/suspended virtual machines have an ID != -1 */
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
- domain->id = id_;
+ domain->id = id_candidate;
} else {
domain->id = -1;
}
cleanup:
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&virtualMachineList);
- VIR_FREE(name_);
+ VIR_FREE(name_candidate);
return domain;
{
int result = 0;
esxPrivate *priv = (esxPrivate *)domain->conn->privateData;
- int nvcpus_max;
+ int maxVcpus;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_VirtualMachineConfigSpec *spec = NULL;
esxVI_ManagedObjectReference *task = NULL;
goto failure;
}
- nvcpus_max = esxDomainGetMaxVcpus(domain);
+ maxVcpus = esxDomainGetMaxVcpus(domain);
- if (nvcpus_max < 0) {
+ if (maxVcpus < 0) {
goto failure;
}
- if (nvcpus > nvcpus_max) {
+ if (nvcpus > maxVcpus) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Requested number of virtual CPUs is greater than max "
"allowable number of virtual CPUs for the domain: %d > %d",
- nvcpus, nvcpus_max);
+ nvcpus, maxVcpus);
goto failure;
}
goto failure;
}
- if (priv->nvcpus_max > 0) {
- return priv->nvcpus_max;
+ if (priv->maxVcpus > 0) {
+ return priv->maxVcpus;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
- priv->nvcpus_max = dynamicProperty->val->int32;
+ priv->maxVcpus = dynamicProperty->val->int32;
break;
} else {
VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&hostSystem);
- return priv->nvcpus_max;
+ return priv->maxVcpus;
failure:
- priv->nvcpus_max = -1;
+ priv->maxVcpus = -1;
goto cleanup;
}
int result = 0;
esxPrivate *priv = (esxPrivate *)domain->conn->privateData;
xmlURIPtr xmlUri = NULL;
- char host_ip_string[NI_MAXHOST] = "";
+ char hostIpAddress[NI_MAXHOST] = "";
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *hostSystem = NULL;
goto failure;
}
- if (priv->vcenter == NULL) {
+ if (priv->vCenter == NULL) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
- "Migration not possible without a Virtual Center");
+ "Migration not possible without a vCenter");
goto failure;
}
goto failure;
}
- if (esxVI_EnsureSession(domain->conn, priv->vcenter) < 0) {
+ if (esxVI_EnsureSession(domain->conn, priv->vCenter) < 0) {
goto failure;
}
goto failure;
}
- if (esxUtil_ResolveHostname(domain->conn, xmlUri->server, host_ip_string,
+ if (esxUtil_ResolveHostname(domain->conn, xmlUri->server, hostIpAddress,
NI_MAXHOST) < 0) {
goto failure;
}
/* Lookup VirtualMachine, HostSystem and ResourcePool */
- if (esxVI_LookupVirtualMachineByUuid(domain->conn, priv->vcenter,
+ if (esxVI_LookupVirtualMachineByUuid(domain->conn, priv->vCenter,
domain->uuid, NULL,
&virtualMachine) < 0) {
goto failure;
if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList,
"parent") < 0 ||
- esxVI_LookupHostSystemByIp(domain->conn, priv->vcenter,
- host_ip_string, propertyNameList,
+ esxVI_LookupHostSystemByIp(domain->conn, priv->vCenter,
+ hostIpAddress, propertyNameList,
&hostSystem) < 0) {
goto failure;
}
if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList,
"resourcePool") < 0 ||
- esxVI_GetObjectContent(domain->conn, priv->vcenter,
+ esxVI_GetObjectContent(domain->conn, priv->vCenter,
managedObjectReference, "ComputeResource",
propertyNameList, esxVI_Boolean_False,
&computeResource) < 0) {
}
/* Validate the purposed migration */
- if (esxVI_ValidateMigration(domain->conn, priv->vcenter,
+ if (esxVI_ValidateMigration(domain->conn, priv->vCenter,
virtualMachine->obj,
esxVI_VirtualMachinePowerState_Undefined,
NULL, resourcePool, hostSystem->obj,
}
/* Perform the purposed migration */
- if (esxVI_MigrateVM_Task(domain->conn, priv->vcenter, virtualMachine->obj,
+ if (esxVI_MigrateVM_Task(domain->conn, priv->vCenter, virtualMachine->obj,
resourcePool, hostSystem->obj, &task) < 0 ||
- esxVI_WaitForTaskCompletion(domain->conn, priv->vcenter, task,
+ esxVI_WaitForTaskCompletion(domain->conn, priv->vCenter, task,
&taskInfoState) < 0) {
goto failure;
}
if (ctx->vmFolder == NULL || ctx->hostFolder == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"The 'datacenter' object is missing the "
- "'vmFolder'/'hostFolder' propoerty");
+ "'vmFolder'/'hostFolder' property");
goto failure;
}
char **content)
{
virBuffer buffer = VIR_BUFFER_INITIALIZER;
- CURLcode error_code;
- long response_code;
+ CURLcode errorCode;
+ long responseCode;
if (content == NULL || *content != NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(ctx->curl_handle, CURLOPT_HTTPGET, 1);
- error_code = curl_easy_perform(ctx->curl_handle);
+ errorCode = curl_easy_perform(ctx->curl_handle);
- if (error_code != CURLE_OK) {
+ if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_perform() returned an error: %s (%d)",
- curl_easy_strerror(error_code), error_code);
+ curl_easy_strerror(errorCode), errorCode);
goto unlock;
}
- error_code = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
- &response_code);
+ errorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
+ &responseCode);
- if (error_code != CURLE_OK) {
+ if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo() returned an error: %s (%d)",
- curl_easy_strerror(error_code), error_code);
+ curl_easy_strerror(errorCode), errorCode);
goto unlock;
}
*content = virBufferContentAndReset(&buffer);
- if (response_code != 200) {
+ if (responseCode != 200) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "HTTP response code %d", (int)response_code);
+ "HTTP response code %d", (int)responseCode);
goto failure;
}
{
virBuffer buffer = VIR_BUFFER_INITIALIZER;
esxVI_Fault *fault = NULL;
- CURLcode error_code;
+ CURLcode errorCode;
if (remoteRequest == NULL || remoteRequest->request == NULL ||
remoteResponse == NULL || *remoteResponse != NULL) {
curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE,
strlen(remoteRequest->request));
- error_code = curl_easy_perform(ctx->curl_handle);
+ errorCode = curl_easy_perform(ctx->curl_handle);
- if (error_code != CURLE_OK) {
+ if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_perform() returned an error: %s (%d)",
- curl_easy_strerror(error_code), error_code);
+ curl_easy_strerror(errorCode), errorCode);
goto unlock;
}
- error_code = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
- &(*remoteResponse)->response_code);
+ errorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
+ &(*remoteResponse)->responseCode);
- if (error_code != CURLE_OK) {
+ if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo() returned an error: %s (%d)",
- curl_easy_strerror(error_code), error_code);
+ curl_easy_strerror(errorCode), errorCode);
goto unlock;
}
(*remoteResponse)->response = virBufferContentAndReset(&buffer);
- if ((*remoteResponse)->response_code == 500 ||
+ if ((*remoteResponse)->responseCode == 500 ||
(remoteRequest->xpathExpression != NULL &&
- (*remoteResponse)->response_code == 200)) {
+ (*remoteResponse)->responseCode == 200)) {
(*remoteResponse)->document =
xmlReadDoc(BAD_CAST(*remoteResponse)->response, "", NULL,
XML_PARSE_NONET);
xmlXPathRegisterNs((*remoteResponse)->xpathContext, BAD_CAST "vim",
BAD_CAST "urn:vim25");
- if ((*remoteResponse)->response_code == 500) {
+ if ((*remoteResponse)->responseCode == 500) {
(*remoteResponse)->xpathObject =
xmlXPathEval(BAD_CAST
"/soapenv:Envelope/soapenv:Body/soapenv:Fault",
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d. VI Fault: %s - %s",
- (int)(*remoteResponse)->response_code,
+ (int)(*remoteResponse)->responseCode,
fault->faultcode, fault->faultstring);
goto failure;
xmlXPathEval(BAD_CAST remoteRequest->xpathExpression,
(*remoteResponse)->xpathContext);
}
- } else if ((*remoteResponse)->response_code != 200) {
+ } else if ((*remoteResponse)->responseCode != 200) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d",
- (int)(*remoteResponse)->response_code);
+ (int)(*remoteResponse)->responseCode);
goto failure;
}