提交 23247a1e 编写于 作者: M Matthias Bolte

esx: Support folders in the path of vpx:// connection URIs

Allow the datacenter and compute resource parts of the path
to be prefixed with folders. Therefore, the way the path is
parsed has changed. Before, it was split in 2 or 3 items and
the items' meanings were determined by their positions. Now
the path can have 2 or more items and the the vCenter server
is asked whether a folder, datacenter of compute resource
with the specified name exists at the current hierarchy level.

Before the datacenter and compute resource lookup automatically
traversed folders during lookup. This is logic got removed
and folders have to be specified explicitly.

The proper datacenter path including folders is now used when
accessing a datastore over HTTPS. This makes virsh dumpxml
and define work for datacenters in folders.

https://bugzilla.redhat.com/show_bug.cgi?id=732676
上级 5759a5cc
...@@ -56,7 +56,7 @@ esx://example-esx.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the s ...@@ -56,7 +56,7 @@ esx://example-esx.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the s
URIs have this general form (<code>[...]</code> marks an optional part). URIs have this general form (<code>[...]</code> marks an optional part).
</p> </p>
<pre> <pre>
type://[username@]hostname[:port]/[datacenter[/cluster]/server][?extraparameters] type://[username@]hostname[:port]/[[folder/...]datacenter/[folder/...][cluster/]server][?extraparameters]
</pre> </pre>
<p> <p>
The <code>type://</code> is either <code>esx://</code> or The <code>type://</code> is either <code>esx://</code> or
...@@ -79,6 +79,14 @@ type://[username@]hostname[:port]/[datacenter[/cluster]/server][?extraparameters ...@@ -79,6 +79,14 @@ type://[username@]hostname[:port]/[datacenter[/cluster]/server][?extraparameters
</p> </p>
<pre> <pre>
vpx://example-vcenter.com/dc1/cluster1/example-esx.com vpx://example-vcenter.com/dc1/cluster1/example-esx.com
</pre>
<p>
Datacenters and clusters can be organized in folders, those have to be
specified as well. The driver can handle folders
<span class="since">since 0.9.7</span>.
</p>
<pre>
vpx://example-vcenter.com/folder1/dc1/folder2/example-esx.com
</pre> </pre>
......
...@@ -722,7 +722,7 @@ esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth, ...@@ -722,7 +722,7 @@ esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
if (esxVI_Context_Alloc(&priv->host) < 0 || if (esxVI_Context_Alloc(&priv->host) < 0 ||
esxVI_Context_Connect(priv->host, url, ipAddress, username, password, esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
priv->parsedUri) < 0 || priv->parsedUri) < 0 ||
esxVI_Context_LookupObjectsByPath(priv->host, priv->parsedUri) < 0) { esxVI_Context_LookupManagedObjects(priv->host) < 0) {
goto cleanup; goto cleanup;
} }
...@@ -804,8 +804,7 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth, ...@@ -804,8 +804,7 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
char *url = NULL; char *url = NULL;
if (hostSystemIpAddress == NULL && if (hostSystemIpAddress == NULL &&
(priv->parsedUri->path_datacenter == NULL || (priv->parsedUri->path == NULL || STREQ(priv->parsedUri->path, "/"))) {
priv->parsedUri->path_computeResource == NULL)) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the datacenter and compute resource")); _("Path has to specify the datacenter and compute resource"));
return -1; return -1;
...@@ -869,13 +868,13 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth, ...@@ -869,13 +868,13 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
} }
if (hostSystemIpAddress != NULL) { if (hostSystemIpAddress != NULL) {
if (esxVI_Context_LookupObjectsByHostSystemIp(priv->vCenter, if (esxVI_Context_LookupManagedObjectsByHostSystemIp
hostSystemIpAddress) < 0) { (priv->vCenter, hostSystemIpAddress) < 0) {
goto cleanup; goto cleanup;
} }
} else { } else {
if (esxVI_Context_LookupObjectsByPath(priv->vCenter, if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter,
priv->parsedUri) < 0) { priv->parsedUri->path) < 0) {
goto cleanup; goto cleanup;
} }
} }
...@@ -894,8 +893,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth, ...@@ -894,8 +893,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
/* /*
* URI format: {vpx|esx|gsx}://[<username>@]<hostname>[:<port>]/[<path>][?<query parameter> ...] * URI format: {vpx|esx|gsx}://[<username>@]<hostname>[:<port>]/[<path>][?<query parameter>...]
* <path> = <datacenter>/<computeresource>[/<hostsystem>] * <path> = [<folder>/...]<datacenter>/[<folder>/...]<computeresource>[/<hostsystem>]
* *
* If no port is specified the default port is set dependent on the scheme and * If no port is specified the default port is set dependent on the scheme and
* transport parameter: * transport parameter:
...@@ -909,7 +908,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth, ...@@ -909,7 +908,8 @@ esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
* For a vpx:// connection <path> references a host managed by the vCenter. * For a vpx:// connection <path> references a host managed by the vCenter.
* In case the host is part of a cluster then <computeresource> is the cluster * In case the host is part of a cluster then <computeresource> is the cluster
* name. Otherwise <computeresource> and <hostsystem> are equal and the later * name. Otherwise <computeresource> and <hostsystem> are equal and the later
* can be omitted. * can be omitted. As datacenters and computeresources can be organized in
* folders those have to be included in <path>.
* *
* Optional query parameters: * Optional query parameters:
* - transport={http|https} * - transport={http|https}
...@@ -977,6 +977,12 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, ...@@ -977,6 +977,12 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
if (STRCASENEQ(conn->uri->scheme, "vpx") &&
conn->uri->path != NULL && STRNEQ(conn->uri->path, "/")) {
VIR_WARN("Ignoring unexpected path '%s' for non-vpx scheme '%s'",
conn->uri->path, conn->uri->scheme);
}
/* Require server part */ /* Require server part */
if (conn->uri->server == NULL) { if (conn->uri->server == NULL) {
ESX_ERROR(VIR_ERR_INVALID_ARG, "%s", ESX_ERROR(VIR_ERR_INVALID_ARG, "%s",
...@@ -2769,7 +2775,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) ...@@ -2769,7 +2775,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
domain->conn->uri->server, domain->conn->uri->port); domain->conn->uri->server, domain->conn->uri->port);
virBufferURIEncodeString(&buffer, directoryAndFileName); virBufferURIEncodeString(&buffer, directoryAndFileName);
virBufferAddLit(&buffer, "?dcPath="); virBufferAddLit(&buffer, "?dcPath=");
virBufferURIEncodeString(&buffer, priv->primary->datacenter->name); virBufferURIEncodeString(&buffer, priv->primary->datacenterPath);
virBufferAddLit(&buffer, "&dsName="); virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName); virBufferURIEncodeString(&buffer, datastoreName);
...@@ -3237,7 +3243,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) ...@@ -3237,7 +3243,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
virBufferURIEncodeString(&buffer, escapedName); virBufferURIEncodeString(&buffer, escapedName);
virBufferAddLit(&buffer, ".vmx?dcPath="); virBufferAddLit(&buffer, ".vmx?dcPath=");
virBufferURIEncodeString(&buffer, priv->primary->datacenter->name); virBufferURIEncodeString(&buffer, priv->primary->datacenterPath);
virBufferAddLit(&buffer, "&dsName="); virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName); virBufferURIEncodeString(&buffer, datastoreName);
......
...@@ -51,7 +51,6 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri) ...@@ -51,7 +51,6 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri)
int noVerify; int noVerify;
int autoAnswer; int autoAnswer;
char *tmp; char *tmp;
char *saveptr;
if (parsedUri == NULL || *parsedUri != NULL) { if (parsedUri == NULL || *parsedUri != NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
...@@ -184,26 +183,13 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri) ...@@ -184,26 +183,13 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri)
} }
} }
/* Expected format: [/]<datacenter>/<computeresource>[/<hostsystem>] */
if (uri->path != NULL) { if (uri->path != NULL) {
tmp = strdup(uri->path); (*parsedUri)->path = strdup(uri->path);
if (tmp == NULL) { if ((*parsedUri)->path == NULL) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
if (esxVI_String_DeepCopyValue(&(*parsedUri)->path_datacenter,
strtok_r(tmp, "/", &saveptr)) < 0 ||
esxVI_String_DeepCopyValue(&(*parsedUri)->path_computeResource,
strtok_r(NULL, "/", &saveptr)) < 0 ||
esxVI_String_DeepCopyValue(&(*parsedUri)->path_hostSystem,
strtok_r(NULL, "", &saveptr)) < 0) {
VIR_FREE(tmp);
goto cleanup;
}
VIR_FREE(tmp);
} }
if ((*parsedUri)->transport == NULL) { if ((*parsedUri)->transport == NULL) {
...@@ -242,9 +228,7 @@ esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri) ...@@ -242,9 +228,7 @@ esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri)
VIR_FREE((*parsedUri)->transport); VIR_FREE((*parsedUri)->transport);
VIR_FREE((*parsedUri)->vCenter); VIR_FREE((*parsedUri)->vCenter);
VIR_FREE((*parsedUri)->proxy_hostname); VIR_FREE((*parsedUri)->proxy_hostname);
VIR_FREE((*parsedUri)->path_datacenter); VIR_FREE((*parsedUri)->path);
VIR_FREE((*parsedUri)->path_computeResource);
VIR_FREE((*parsedUri)->path_hostSystem);
VIR_FREE(*parsedUri); VIR_FREE(*parsedUri);
} }
......
...@@ -37,9 +37,7 @@ struct _esxUtil_ParsedUri { ...@@ -37,9 +37,7 @@ struct _esxUtil_ParsedUri {
int proxy_type; int proxy_type;
char *proxy_hostname; char *proxy_hostname;
int proxy_port; int proxy_port;
char *path_datacenter; char *path;
char *path_computeResource;
char *path_hostSystem;
}; };
int esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri); int esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, xmlURIPtr uri);
......
...@@ -616,8 +616,11 @@ ESX_VI__TEMPLATE__FREE(Context, ...@@ -616,8 +616,11 @@ ESX_VI__TEMPLATE__FREE(Context,
esxVI_UserSession_Free(&item->session); esxVI_UserSession_Free(&item->session);
VIR_FREE(item->sessionLock); VIR_FREE(item->sessionLock);
esxVI_Datacenter_Free(&item->datacenter); esxVI_Datacenter_Free(&item->datacenter);
VIR_FREE(item->datacenterPath);
esxVI_ComputeResource_Free(&item->computeResource); esxVI_ComputeResource_Free(&item->computeResource);
VIR_FREE(item->computeResourcePath);
esxVI_HostSystem_Free(&item->hostSystem); esxVI_HostSystem_Free(&item->hostSystem);
VIR_FREE(item->hostSystemName);
esxVI_SelectionSpec_Free(&item->selectSet_folderToChildEntity); esxVI_SelectionSpec_Free(&item->selectSet_folderToChildEntity);
esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent); esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToParent);
esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm); esxVI_SelectionSpec_Free(&item->selectSet_hostSystemToVm);
...@@ -789,21 +792,25 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, ...@@ -789,21 +792,25 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
} }
int int
esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx, esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
esxUtil_ParsedUri *parsedUri)
{ {
char *hostSystemName = NULL;
/* Lookup Datacenter */ /* Lookup Datacenter */
if (esxVI_LookupDatacenter(ctx, parsedUri->path_datacenter, if (esxVI_LookupDatacenter(ctx, NULL, ctx->service->rootFolder, NULL,
ctx->service->rootFolder, NULL, &ctx->datacenter, &ctx->datacenter,
esxVI_Occurrence_RequiredItem) < 0) { esxVI_Occurrence_RequiredItem) < 0) {
return -1; return -1;
} }
ctx->datacenterPath = strdup(ctx->datacenter->name);
if (ctx->datacenterPath == NULL) {
virReportOOMError();
return -1;
}
/* Lookup (Cluster)ComputeResource */ /* Lookup (Cluster)ComputeResource */
if (esxVI_LookupComputeResource(ctx, parsedUri->path_computeResource, if (esxVI_LookupComputeResource(ctx, NULL, ctx->datacenter->hostFolder,
ctx->datacenter->hostFolder, NULL, NULL, &ctx->computeResource,
&ctx->computeResource,
esxVI_Occurrence_RequiredItem) < 0) { esxVI_Occurrence_RequiredItem) < 0) {
return -1; return -1;
} }
...@@ -814,38 +821,240 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx, ...@@ -814,38 +821,240 @@ esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx,
return -1; return -1;
} }
ctx->computeResourcePath = strdup(ctx->computeResource->name);
if (ctx->computeResourcePath == NULL) {
virReportOOMError();
return -1;
}
/* Lookup HostSystem */ /* Lookup HostSystem */
if (parsedUri->path_hostSystem == NULL && if (esxVI_LookupHostSystem(ctx, NULL, ctx->computeResource->_reference,
STREQ(ctx->computeResource->_reference->type, NULL, &ctx->hostSystem,
"ClusterComputeResource")) { esxVI_Occurrence_RequiredItem) < 0) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG, "%s",
_("Path has to specify the host system"));
return -1; return -1;
} }
if (parsedUri->path_hostSystem != NULL || ctx->hostSystemName = strdup(ctx->hostSystem->name);
(parsedUri->path_computeResource != NULL &&
parsedUri->path_hostSystem == NULL)) { if (ctx->hostSystemName == NULL) {
if (parsedUri->path_hostSystem != NULL) { virReportOOMError();
hostSystemName = parsedUri->path_hostSystem; return -1;
}
return 0;
}
int
esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
{
int result = -1;
char *tmp = NULL;
char *saveptr = NULL;
char *previousItem = NULL;
char *item = NULL;
virBuffer buffer = VIR_BUFFER_INITIALIZER;
esxVI_ManagedObjectReference *root = NULL;
esxVI_Folder *folder = NULL;
tmp = strdup(path);
if (tmp == NULL) {
virReportOOMError();
goto cleanup;
}
/* Lookup Datacenter */
item = strtok_r(tmp, "/", &saveptr);
if (item == NULL) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a datacenter"), path);
goto cleanup;
}
root = ctx->service->rootFolder;
while (ctx->datacenter == NULL && item != NULL) {
esxVI_Folder_Free(&folder);
/* Try to lookup item as a folder */
if (esxVI_LookupFolder(ctx, item, root, NULL, &folder,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
if (folder != NULL) {
/* It's a folder, use it as new lookup root */
if (root != ctx->service->rootFolder) {
esxVI_ManagedObjectReference_Free(&root);
}
root = folder->_reference;
folder->_reference = NULL;
} else {
/* Try to lookup item as a datacenter */
if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datacenter,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
}
/* Build datacenter path */
if (virBufferUse(&buffer) > 0) {
virBufferAddChar(&buffer, '/');
}
virBufferAdd(&buffer, item, -1);
previousItem = item;
item = strtok_r(NULL, "/", &saveptr);
}
if (ctx->datacenter == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not find datacenter specified in '%s'"), path);
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
goto cleanup;
}
ctx->datacenterPath = virBufferContentAndReset(&buffer);
/* Lookup (Cluster)ComputeResource */
if (item == NULL) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a compute resource"), path);
goto cleanup;
}
if (root != ctx->service->rootFolder) {
esxVI_ManagedObjectReference_Free(&root);
}
root = ctx->datacenter->hostFolder;
while (ctx->computeResource == NULL && item != NULL) {
esxVI_Folder_Free(&folder);
/* Try to lookup item as a folder */
if (esxVI_LookupFolder(ctx, item, root, NULL, &folder,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
if (folder != NULL) {
/* It's a folder, use it as new lookup root */
if (root != ctx->datacenter->hostFolder) {
esxVI_ManagedObjectReference_Free(&root);
}
root = folder->_reference;
folder->_reference = NULL;
} else { } else {
hostSystemName = parsedUri->path_computeResource; /* Try to lookup item as a compute resource */
if (esxVI_LookupComputeResource(ctx, item, root, NULL,
&ctx->computeResource,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
}
/* Build compute resource path */
if (virBufferUse(&buffer) > 0) {
virBufferAddChar(&buffer, '/');
}
virBufferAdd(&buffer, item, -1);
previousItem = item;
item = strtok_r(NULL, "/", &saveptr);
}
if (ctx->computeResource == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not find compute resource specified in '%s'"),
path);
goto cleanup;
}
if (ctx->computeResource->resourcePool == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not retrieve resource pool"));
goto cleanup;
}
if (virBufferError(&buffer)) {
virReportOOMError();
goto cleanup;
}
ctx->computeResourcePath = virBufferContentAndReset(&buffer);
/* Lookup HostSystem */
if (STREQ(ctx->computeResource->_reference->type,
"ClusterComputeResource")) {
if (item == NULL) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG,
_("Path '%s' does not specify a host system"), path);
goto cleanup;
} }
/* The path specified a cluster, it has to specify a host system too */
previousItem = item;
item = strtok_r(NULL, "/", &saveptr);
}
if (item != NULL) {
ESX_VI_ERROR(VIR_ERR_INVALID_ARG,
_("Path '%s' ends with an excess item"), path);
goto cleanup;
} }
if (esxVI_LookupHostSystem(ctx, hostSystemName, ctx->hostSystemName = strdup(previousItem);
if (ctx->hostSystemName == NULL) {
virReportOOMError();
goto cleanup;
}
if (esxVI_LookupHostSystem(ctx, ctx->hostSystemName,
ctx->computeResource->_reference, NULL, ctx->computeResource->_reference, NULL,
&ctx->hostSystem, &ctx->hostSystem,
esxVI_Occurrence_RequiredItem) < 0) { esxVI_Occurrence_OptionalItem) < 0) {
return -1; goto cleanup;
} }
return 0; if (ctx->hostSystem == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not find host system specified in '%s'"), path);
goto cleanup;
}
result = 0;
cleanup:
if (result < 0) {
virBufferFreeAndReset(&buffer);
}
if (root != ctx->service->rootFolder &&
(ctx->datacenter == NULL || root != ctx->datacenter->hostFolder)) {
esxVI_ManagedObjectReference_Free(&root);
}
VIR_FREE(tmp);
esxVI_Folder_Free(&folder);
return result;
} }
int int
esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx, esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context *ctx,
const char *hostSystemIpAddress) const char *hostSystemIpAddress)
{ {
int result = -1; int result = -1;
esxVI_ManagedObjectReference *managedObjectReference = NULL; esxVI_ManagedObjectReference *managedObjectReference = NULL;
...@@ -1491,8 +1700,7 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx) ...@@ -1491,8 +1700,7 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx)
/* Folder -> childEntity (ManagedEntity) */ /* Folder -> childEntity (ManagedEntity) */
if (esxVI_BuildSelectSet(&ctx->selectSet_folderToChildEntity, if (esxVI_BuildSelectSet(&ctx->selectSet_folderToChildEntity,
"folderToChildEntity", "folderToChildEntity",
"Folder", "childEntity", "Folder", "childEntity", NULL) < 0) {
"folderToChildEntity\0") < 0) {
return -1; return -1;
} }
...@@ -1689,9 +1897,10 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, ...@@ -1689,9 +1897,10 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx,
objectSpec->obj = root; objectSpec->obj = root;
objectSpec->skip = esxVI_Boolean_False; objectSpec->skip = esxVI_Boolean_False;
if (STRNEQ(root->type, type)) { if (STRNEQ(root->type, type) || STREQ(root->type, "Folder")) {
if (STREQ(root->type, "Folder")) { if (STREQ(root->type, "Folder")) {
if (STREQ(type, "Datacenter") || STREQ(type, "ComputeResource") || if (STREQ(type, "Folder") || STREQ(type, "Datacenter") ||
STREQ(type, "ComputeResource") ||
STREQ(type, "ClusterComputeResource")) { STREQ(type, "ClusterComputeResource")) {
objectSpec->selectSet = ctx->selectSet_folderToChildEntity; objectSpec->selectSet = ctx->selectSet_folderToChildEntity;
} else { } else {
......
...@@ -204,8 +204,11 @@ struct _esxVI_Context { ...@@ -204,8 +204,11 @@ struct _esxVI_Context {
esxVI_UserSession *session; /* ... except the session ... */ esxVI_UserSession *session; /* ... except the session ... */
virMutexPtr sessionLock; /* ... that is protected by this mutex */ virMutexPtr sessionLock; /* ... that is protected by this mutex */
esxVI_Datacenter *datacenter; esxVI_Datacenter *datacenter;
char *datacenterPath; /* including folders */
esxVI_ComputeResource *computeResource; esxVI_ComputeResource *computeResource;
char *computeResourcePath; /* including folders */
esxVI_HostSystem *hostSystem; esxVI_HostSystem *hostSystem;
char *hostSystemName;
esxVI_SelectionSpec *selectSet_folderToChildEntity; esxVI_SelectionSpec *selectSet_folderToChildEntity;
esxVI_SelectionSpec *selectSet_hostSystemToParent; esxVI_SelectionSpec *selectSet_hostSystemToParent;
esxVI_SelectionSpec *selectSet_hostSystemToVm; esxVI_SelectionSpec *selectSet_hostSystemToVm;
...@@ -221,10 +224,10 @@ void esxVI_Context_Free(esxVI_Context **ctx); ...@@ -221,10 +224,10 @@ void esxVI_Context_Free(esxVI_Context **ctx);
int esxVI_Context_Connect(esxVI_Context *ctx, const char *ipAddress, int esxVI_Context_Connect(esxVI_Context *ctx, const char *ipAddress,
const char *url, const char *username, const char *url, const char *username,
const char *password, esxUtil_ParsedUri *parsedUri); const char *password, esxUtil_ParsedUri *parsedUri);
int esxVI_Context_LookupObjectsByPath(esxVI_Context *ctx, int esxVI_Context_LookupManagedObjects(esxVI_Context *ctx);
esxUtil_ParsedUri *parsedUri); int esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path);
int esxVI_Context_LookupObjectsByHostSystemIp(esxVI_Context *ctx, int esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context *ctx,
const char *hostSystemIpAddress); const char *hostSystemIpAddress);
int esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, int esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
const char *request, esxVI_Response **response, const char *request, esxVI_Response **response,
esxVI_Occurrence occurrence); esxVI_Occurrence occurrence);
......
...@@ -755,6 +755,10 @@ managed object Datacenter extends ManagedEntity ...@@ -755,6 +755,10 @@ managed object Datacenter extends ManagedEntity
end end
managed object Folder extends ManagedEntity
end
managed object HostSystem extends ManagedEntity managed object HostSystem extends ManagedEntity
HostConfigManager configManager r HostConfigManager configManager r
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册