goto failure;
}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * RemoteRequest
- */
-
-/* esxVI_RemoteRequest_Alloc */
-ESX_VI__TEMPLATE__ALLOC(RemoteRequest);
-
-/* esxVI_RemoteRequest_Free */
-ESX_VI__TEMPLATE__FREE(RemoteRequest,
-{
- VIR_FREE(item->request);
- VIR_FREE(item->xpathExpression);
-});
-
int
-esxVI_RemoteRequest_Execute(virConnectPtr conn, esxVI_Context *ctx,
- esxVI_RemoteRequest *remoteRequest,
- esxVI_RemoteResponse **remoteResponse,
- esxVI_Boolean expectList)
+esxVI_Context_Execute(virConnectPtr conn, esxVI_Context *ctx,
+ const char *request, const char *xpathExpression,
+ esxVI_Response **response, esxVI_Boolean expectList)
{
virBuffer buffer = VIR_BUFFER_INITIALIZER;
esxVI_Fault *fault = NULL;
CURLcode errorCode;
- if (remoteRequest == NULL || remoteRequest->request == NULL ||
- remoteResponse == NULL || *remoteResponse != NULL) {
+ if (request == NULL || response == NULL || *response != NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
goto failure;
}
- if (esxVI_RemoteResponse_Alloc(conn, remoteResponse) < 0) {
+ if (esxVI_Response_Alloc(conn, response) < 0) {
goto failure;
}
curl_easy_setopt(ctx->curl_handle, CURLOPT_URL, ctx->url);
curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEDATA, &buffer);
- curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDS,
- remoteRequest->request);
- curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE,
- strlen(remoteRequest->request));
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDS, request);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_POSTFIELDSIZE, strlen(request));
errorCode = curl_easy_perform(ctx->curl_handle);
}
errorCode = curl_easy_getinfo(ctx->curl_handle, CURLINFO_RESPONSE_CODE,
- &(*remoteResponse)->responseCode);
+ &(*response)->responseCode);
if (errorCode != CURLE_OK) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
goto failure;
}
- (*remoteResponse)->response = virBufferContentAndReset(&buffer);
+ (*response)->content = virBufferContentAndReset(&buffer);
- if ((*remoteResponse)->responseCode == 500 ||
- (remoteRequest->xpathExpression != NULL &&
- (*remoteResponse)->responseCode == 200)) {
- (*remoteResponse)->document =
- xmlReadDoc(BAD_CAST(*remoteResponse)->response, "", NULL,
- XML_PARSE_NONET);
+ if ((*response)->responseCode == 500 ||
+ (xpathExpression != NULL && (*response)->responseCode == 200)) {
+ (*response)->document = xmlReadDoc(BAD_CAST (*response)->content, "",
+ NULL, XML_PARSE_NONET);
- if ((*remoteResponse)->document == NULL) {
+ if ((*response)->document == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"Could not parse XML response");
goto failure;
}
- if (xmlDocGetRootElement((*remoteResponse)->document) == NULL) {
+ if (xmlDocGetRootElement((*response)->document) == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"XML response is an empty document");
goto failure;
}
- (*remoteResponse)->xpathContext =
- xmlXPathNewContext((*remoteResponse)->document);
+ (*response)->xpathContext = xmlXPathNewContext((*response)->document);
- if ((*remoteResponse)->xpathContext == NULL) {
+ if ((*response)->xpathContext == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"Could not create XPath context");
goto failure;
}
- xmlXPathRegisterNs((*remoteResponse)->xpathContext, BAD_CAST "soapenv",
+ xmlXPathRegisterNs((*response)->xpathContext, BAD_CAST "soapenv",
BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/");
- xmlXPathRegisterNs((*remoteResponse)->xpathContext, BAD_CAST "vim",
+ xmlXPathRegisterNs((*response)->xpathContext, BAD_CAST "vim",
BAD_CAST "urn:vim25");
- if ((*remoteResponse)->responseCode == 500) {
- (*remoteResponse)->node =
+ if ((*response)->responseCode == 500) {
+ (*response)->node =
virXPathNode(conn, "/soapenv:Envelope/soapenv:Body/soapenv:Fault",
- (*remoteResponse)->xpathContext);
+ (*response)->xpathContext);
- if ((*remoteResponse)->node == NULL) {
+ if ((*response)->node == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d. VI Fault is unknown, "
"XPath evaluation failed",
- (int)(*remoteResponse)->responseCode);
+ (int)(*response)->responseCode);
goto failure;
}
- if (esxVI_Fault_Deserialize(conn, (*remoteResponse)->node,
- &fault) < 0) {
+ if (esxVI_Fault_Deserialize(conn, (*response)->node, &fault) < 0) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d. VI Fault is unknown, "
"deserialization failed",
- (int)(*remoteResponse)->responseCode);
+ (int)(*response)->responseCode);
goto failure;
}
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"HTTP response code %d. VI Fault: %s - %s",
- (int)(*remoteResponse)->responseCode,
+ (int)(*response)->responseCode,
fault->faultcode, fault->faultstring);
goto failure;
xmlNodePtr *nodeSet = NULL;
int nodeSet_size;
- nodeSet_size = virXPathNodeSet(conn, remoteRequest->xpathExpression,
- (*remoteResponse)->xpathContext,
+ nodeSet_size = virXPathNodeSet(conn, xpathExpression,
+ (*response)->xpathContext,
&nodeSet);
if (nodeSet_size < 0) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"XPath evaluation of '%s' failed",
- remoteRequest->xpathExpression);
+ xpathExpression);
goto failure;
} else if (nodeSet_size == 0) {
- (*remoteResponse)->node = NULL;
+ (*response)->node = NULL;
} else {
- (*remoteResponse)->node = nodeSet[0];
+ (*response)->node = nodeSet[0];
}
VIR_FREE(nodeSet);
} else {
- (*remoteResponse)->node =
- virXPathNode(conn, remoteRequest->xpathExpression,
- (*remoteResponse)->xpathContext);
+ (*response)->node = virXPathNode(conn, xpathExpression,
+ (*response)->xpathContext);
- if ((*remoteResponse)->node == NULL) {
+ if ((*response)->node == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
"XPath evaluation of '%s' failed",
- remoteRequest->xpathExpression);
+ xpathExpression);
goto failure;
}
}
- } else if ((*remoteResponse)->responseCode != 200) {
+ } else if ((*response)->responseCode != 200) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "HTTP response code %d",
- (int)(*remoteResponse)->responseCode);
+ "HTTP response code %d", (int)(*response)->responseCode);
goto failure;
}
failure:
free(virBufferContentAndReset(&buffer));
- esxVI_RemoteResponse_Free(remoteResponse);
+ esxVI_Response_Free(response);
esxVI_Fault_Free(&fault);
return -1;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * RemoteResponse
+ * Response
*/
-/* esxVI_RemoteResponse_Alloc */
-ESX_VI__TEMPLATE__ALLOC(RemoteResponse);
+/* esxVI_Response_Alloc */
+ESX_VI__TEMPLATE__ALLOC(Response);
-/* esxVI_RemoteResponse_Free */
-ESX_VI__TEMPLATE__FREE(RemoteResponse,
+/* esxVI_Response_Free */
+ESX_VI__TEMPLATE__FREE(Response,
{
- VIR_FREE(item->response);
+ VIR_FREE(item->content);
xmlXPathFreeContext(item->xpathContext);
esxVI_ManagedObjectReference **task)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
-
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0) {
- goto failure;
- }
+ char *xpathExpression = NULL;
+ esxVI_Response *response = NULL;
- remoteRequest->request = (char *)request;
-
- if (virAsprintf(&remoteRequest->xpathExpression,
+ if (virAsprintf(&xpathExpression,
ESX_VI__SOAP__RESPONSE_XPATH("%s_Task"), name) < 0) {
virReportOOMError(conn);
goto failure;
}
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_ManagedObjectReference_Deserialize
- (conn, remoteResponse->node, task, "Task") < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request, xpathExpression, &response,
+ esxVI_Boolean_False) < 0 ||
+ esxVI_ManagedObjectReference_Deserialize(conn, response->node, task,
+ "Task") < 0) {
goto failure;
}
cleanup:
- /*
- * Remove values given by the caller from the data structures to prevent
- * them from being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->request = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(xpathExpression);
+ esxVI_Response_Free(&response);
return result;
int
esxVI_SimpleVirtualMachineMethod(virConnectPtr conn, esxVI_Context *ctx,
- const char *name,
- esxVI_ManagedObjectReference *virtualMachine)
+ const char *name,
+ esxVI_ManagedObjectReference *virtualMachine)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
virBufferAdd(&buffer, name, -1);
virBufferAddLit(&buffer, " xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, virtualMachine, "_this",
+ if (esxVI_ManagedObjectReference_Serialize(conn, virtualMachine, "_this",
&buffer,
esxVI_Boolean_True) < 0) {
goto failure;
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request, NULL, &response,
+ esxVI_Boolean_False) < 0) {
goto failure;
}
cleanup:
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
"</soapenv:Envelope>"
#define ESX_VI__SOAP__RESPONSE_XPATH(_type) \
- ((char *)"/soapenv:Envelope/soapenv:Body/" \
- "vim:"_type"Response/vim:returnval")
+ "/soapenv:Envelope/soapenv:Body/vim:"_type"Response/vim:returnval"
* VI Methods
*/
-static const char *_esxVI_RetrieveServiceContentRequest =
-ESX_VI__SOAP__REQUEST_HEADER
- "<RetrieveServiceContent xmlns=\"urn:vim25\">"
- "<_this xmlns=\"urn:vim25\" "
- "xsi:type=\"ManagedObjectReference\" "
- "type=\"ServiceInstance\">"
- "ServiceInstance"
- "</_this>"
- "</RetrieveServiceContent>"
-ESX_VI__SOAP__REQUEST_FOOTER;
-
int
esxVI_RetrieveServiceContent(virConnectPtr conn, esxVI_Context *ctx,
esxVI_ServiceContent **serviceContent)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
+ const char *request = ESX_VI__SOAP__REQUEST_HEADER
+ "<RetrieveServiceContent xmlns=\"urn:vim25\">"
+ "<_this xmlns=\"urn:vim25\" "
+ "xsi:type=\"ManagedObjectReference\" "
+ "type=\"ServiceInstance\">"
+ "ServiceInstance"
+ "</_this>"
+ "</RetrieveServiceContent>"
+ ESX_VI__SOAP__REQUEST_FOOTER;
+ esxVI_Response *response = NULL;
if (serviceContent == NULL || *serviceContent != NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid argument");
return -1;
}
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0) {
- goto failure;
- }
-
- remoteRequest->request = (char *)_esxVI_RetrieveServiceContentRequest;
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("RetrieveServiceContent");
-
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_ServiceContent_Deserialize(conn, remoteResponse->node,
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("RetrieveServiceContent"),
+ &response, esxVI_Boolean_False) < 0 ||
+ esxVI_ServiceContent_Deserialize(conn, response->node,
serviceContent) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->request = NULL;
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ esxVI_Response_Free(&response);
return result;
esxVI_UserSession **userSession)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<Login xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->sessionManager,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression = ESX_VI__SOAP__RESPONSE_XPATH("Login");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_UserSession_Deserialize(conn, remoteResponse->node,
- userSession) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("Login"),
+ &response, esxVI_Boolean_False) < 0 ||
+ esxVI_UserSession_Deserialize(conn, response->node, userSession) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_Logout(virConnectPtr conn, esxVI_Context *ctx)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<Logout xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->sessionManager,
"_this", &buffer,
esxVI_Boolean_True) < 0) {
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request, NULL, &response,
+ esxVI_Boolean_False) < 0) {
goto failure;
}
cleanup:
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_Boolean *active)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<SessionIsActive xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->sessionManager,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("SessionIsActive");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_Boolean_Deserialize(conn, remoteResponse->node, active) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("SessionIsActive"),
+ &response, esxVI_Boolean_False) < 0 ||
+ esxVI_Boolean_Deserialize(conn, response->node, active) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_ObjectContent **objectContentList)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<RetrieveProperties xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->propertyCollector,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("RetrieveProperties");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_True) < 0 ||
- esxVI_ObjectContent_DeserializeList(conn, remoteResponse->node,
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("RetrieveProperties"),
+ &response, esxVI_Boolean_True) < 0 ||
+ esxVI_ObjectContent_DeserializeList(conn, response->node,
objectContentList) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_ManagedObjectReference **propertyFilter)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<CreateFilter xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->propertyCollector,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("CreateFilter");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_ManagedObjectReference_Deserialize
- (conn, remoteResponse->node, propertyFilter, "PropertyFilter") < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("CreateFilter"),
+ &response, esxVI_Boolean_False) < 0 ||
+ esxVI_ManagedObjectReference_Deserialize(conn, response->node,
+ propertyFilter,
+ "PropertyFilter") < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_ManagedObjectReference *propertyFilter)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<DestroyPropertyFilter xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, propertyFilter, "_this",
+ if (esxVI_ManagedObjectReference_Serialize(conn, propertyFilter, "_this",
&buffer,
esxVI_Boolean_True) < 0) {
goto failure;
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request, NULL, &response,
+ esxVI_Boolean_False) < 0) {
goto failure;
}
cleanup:
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
const char *version, esxVI_UpdateSet **updateSet)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<WaitForUpdates xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn,
+ if (esxVI_ManagedObjectReference_Serialize(conn,
ctx->service->propertyCollector,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("WaitForUpdates");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
- esxVI_UpdateSet_Deserialize(conn, remoteResponse->node,
- updateSet) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("WaitForUpdates"),
+ &response, esxVI_Boolean_False) < 0 ||
+ esxVI_UpdateSet_Deserialize(conn, response->node, updateSet) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_Event **eventList)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
"ServiceInstance"
"</_this>");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_SerializeList(conn, virtualMachineList,
+ if (esxVI_ManagedObjectReference_SerializeList(conn, virtualMachineList,
"vm", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_VirtualMachinePowerState_Serialize(conn, powerState, "state",
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("ValidateMigration");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_True) < 0 ||
- esxVI_Event_DeserializeList(conn, remoteResponse->node,
- eventList) < 0) {
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("ValidateMigration"),
+ &response, esxVI_Boolean_True) < 0 ||
+ esxVI_Event_DeserializeList(conn, response->node, eventList) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_ManagedObjectReference **managedObjectReference)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<FindByIp xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, ctx->service->searchIndex,
+ if (esxVI_ManagedObjectReference_Serialize(conn, ctx->service->searchIndex,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_ManagedObjectReference_Serialize(conn, datacenter,
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("FindByIp");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("FindByIp"),
+ &response, esxVI_Boolean_False) < 0 ||
esxVI_ManagedObjectReference_Deserialize
- (conn, remoteResponse->node, managedObjectReference,
+ (conn, response->node, managedObjectReference,
vmSearch == esxVI_Boolean_True ? "VirtualMachine"
: "HostSystem") < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_ManagedObjectReference **managedObjectReference)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<FindByUuid xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, ctx->service->searchIndex,
+ if (esxVI_ManagedObjectReference_Serialize(conn, ctx->service->searchIndex,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_ManagedObjectReference_Serialize(conn, datacenter,
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("FindByUuid");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_False) < 0 ||
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("FindByUuid"),
+ &response, esxVI_Boolean_False) < 0 ||
esxVI_ManagedObjectReference_Deserialize
- (conn, remoteResponse->node, managedObjectReference,
+ (conn, response->node, managedObjectReference,
vmSearch == esxVI_Boolean_True ? "VirtualMachine"
: "HostSystem") < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_PerfMetricId **perfMetricIdList)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<QueryAvailablePerfMetric xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
+ if (esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_ManagedObjectReference_Serialize(conn, entity,
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("QueryAvailablePerfMetric");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_True) < 0 ||
- esxVI_PerfMetricId_DeserializeList(conn, remoteResponse->node,
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("QueryAvailablePerfMetric"),
+ &response, esxVI_Boolean_True) < 0 ||
+ esxVI_PerfMetricId_DeserializeList(conn, response->node,
perfMetricIdList) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_PerfCounterInfo **perfCounterInfoList)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<QueryPerfCounter xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
+ if (esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_Int_SerializeList(conn, counterIdList, "counterId", &buffer,
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression =
- ESX_VI__SOAP__RESPONSE_XPATH("QueryPerfCounter");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_True) < 0 ||
- esxVI_PerfCounterInfo_DeserializeList(conn, remoteResponse->node,
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("QueryPerfCounter"),
+ &response, esxVI_Boolean_True) < 0 ||
+ esxVI_PerfCounterInfo_DeserializeList(conn, response->node,
perfCounterInfoList) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;
esxVI_PerfEntityMetric **perfEntityMetricList)
{
int result = 0;
- esxVI_RemoteRequest *remoteRequest = NULL;
- esxVI_RemoteResponse *remoteResponse = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
+ char *request = NULL;
+ esxVI_Response *response = NULL;
if (ctx->service == NULL) {
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Invalid call");
virBufferAddLit(&buffer, ESX_VI__SOAP__REQUEST_HEADER);
virBufferAddLit(&buffer, "<QueryPerf xmlns=\"urn:vim25\">");
- if (esxVI_RemoteRequest_Alloc(conn, &remoteRequest) < 0 ||
- esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
+ if (esxVI_ManagedObjectReference_Serialize(conn, ctx->service->perfManager,
"_this", &buffer,
esxVI_Boolean_True) < 0 ||
esxVI_PerfQuerySpec_SerializeList(conn, querySpecList, "querySpec",
- &buffer,
- esxVI_Boolean_True) < 0) {
+ &buffer, esxVI_Boolean_True) < 0) {
goto failure;
}
goto failure;
}
- remoteRequest->request = virBufferContentAndReset(&buffer);
- remoteRequest->xpathExpression = ESX_VI__SOAP__RESPONSE_XPATH("QueryPerf");
+ request = virBufferContentAndReset(&buffer);
- if (esxVI_RemoteRequest_Execute(conn, ctx, remoteRequest, &remoteResponse,
- esxVI_Boolean_True) < 0 ||
- esxVI_PerfEntityMetric_DeserializeList(conn, remoteResponse->node,
+ if (esxVI_Context_Execute(conn, ctx, request,
+ ESX_VI__SOAP__RESPONSE_XPATH("QueryPerf"),
+ &response, esxVI_Boolean_True) < 0 ||
+ esxVI_PerfEntityMetric_DeserializeList(conn, response->node,
perfEntityMetricList) < 0) {
goto failure;
}
cleanup:
- /*
- * Remove static values from the data structures to prevent them from
- * being freed by the call to esxVI_RemoteRequest_Free().
- */
- if (remoteRequest != NULL) {
- remoteRequest->xpathExpression = NULL;
- }
-
- esxVI_RemoteRequest_Free(&remoteRequest);
- esxVI_RemoteResponse_Free(&remoteResponse);
+ VIR_FREE(request);
+ esxVI_Response_Free(&response);
return result;
failure:
- free(virBufferContentAndReset(&buffer));
+ if (request == NULL) {
+ request = virBufferContentAndReset(&buffer);
+ }
result = -1;