Issue 830: refactored VdcApi,AdminVdcApi to use urn

This commit is contained in:
Adrian Cole 2012-08-19 16:08:16 -07:00
parent 206af90b77
commit cb844928c0
20 changed files with 631 additions and 352 deletions

View File

@ -46,6 +46,7 @@
<test.vcloud-director.vapptemplate-id></test.vcloud-director.vapptemplate-id>
<!-- URN format: ex. urn:vcloud:network:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.network-id></test.vcloud-director.network-id>
<!-- URN format: ex. urn:vcloud:vdc:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.vdc-id></test.vcloud-director.vdc-id>
<!-- URN format: ex. urn:vcloud:user:7212e451-76e1-4631-b2de-ba1dfd8080e4 -->
<test.vcloud-director.user-id></test.vcloud-director.user-id>

View File

@ -50,7 +50,9 @@ public interface VdcApi {
*
* @return the vdc or null if not found
*/
Vdc getVdc(URI vdcUri);
Vdc get(String vdcUrn);
Vdc get(URI vdcHref);
/**
* Captures a vApp into vApp template.
@ -62,8 +64,10 @@ public interface VdcApi {
* @return a VApp resource which will contain a task. The user should should wait for this task to finish to be able
* to use the vApp.
*/
VAppTemplate captureVApp(URI vdcUri, CaptureVAppParams params);
VAppTemplate captureVApp(String vdcUrn, CaptureVAppParams params);
VAppTemplate captureVApp(URI vdcHref, CaptureVAppParams params);
/**
* Clones a media into new one.
*
@ -74,8 +78,10 @@ public interface VdcApi {
* @return a Media resource which will contain a task. The user should monitor the contained task status in order to
* check when it is completed.
*/
Media cloneMedia(URI vdcUri, CloneMediaParams params);
Media cloneMedia(String vdcUrn, CloneMediaParams params);
Media cloneMedia(URI vdcHref, CloneMediaParams params);
/**
* Clones a vApp into new one.
*
@ -85,8 +91,10 @@ public interface VdcApi {
* @return a VApp resource which will contain a task. The user should should wait for this task to finish to be able
* to use the vApp.
*/
VApp cloneVApp(URI vdcUri, CloneVAppParams params);
VApp cloneVApp(String vdcUrn, CloneVAppParams params);
VApp cloneVApp(URI vdcHref, CloneVAppParams params);
/**
* Clones a vApp template into new one.
*
@ -97,8 +105,10 @@ public interface VdcApi {
* @return a VAppTemplate resource which will contain a task. The user should should wait for this task to finish to
* be able to use the VAppTemplate.
*/
VAppTemplate cloneVAppTemplate(URI vdcUri, CloneVAppTemplateParams params);
VAppTemplate cloneVAppTemplate(String vdcUrn, CloneVAppTemplateParams params);
VAppTemplate cloneVAppTemplate(URI vdcHref, CloneVAppTemplateParams params);
/**
* Composes a new vApp using VMs from other vApps or vApp templates.
*
@ -129,8 +139,10 @@ public interface VdcApi {
* @return a VApp resource which will contain a task. The user should should wait for this task to finish to be able
* to use the vApp.
*/
VApp composeVApp(URI vdcUri, ComposeVAppParams params);
VApp composeVApp(String vdcUrn, ComposeVAppParams params);
VApp composeVApp(URI vdcHref, ComposeVAppParams params);
/**
* Instantiate a vApp template into a new vApp.
*
@ -144,8 +156,10 @@ public interface VdcApi {
* @return a VApp resource which will contain a task. The user should should wait for this task to finish to be able
* to use the vApp.
*/
VApp instantiateVApp(URI vdcUri, InstantiateVAppParams params);
VApp instantiateVApp(String vdcUrn, InstantiateVAppParams params);
VApp instantiateVApp(URI vdcHref, InstantiateVAppParams params);
/**
* Uploading vApp template to a vDC.
*
@ -165,15 +179,19 @@ public interface VdcApi {
* @return a VAppTemplate resource which will contain a task. The user should should wait for this task to finish to
* be able to use the VAppTemplate.
*/
VAppTemplate uploadVAppTemplate(URI vdcUri, UploadVAppTemplateParams params);
VAppTemplate uploadVAppTemplate(String vdcUrn, UploadVAppTemplateParams params);
VAppTemplate uploadVAppTemplate(URI vdcHref, UploadVAppTemplateParams params);
/**
* Creates a media (and present upload link for the floppy/iso file).
*
* @return The response will return a link to transfer site to be able to continue with uploading the media.
*/
Media createMedia(URI vdcUri, Media media);
Media createMedia(String vdcUrn, Media media);
Media createMedia(URI vdcHref, Media media);
/**
* @return synchronous access to {@link Metadata.Readable} features
*/

View File

@ -36,6 +36,7 @@ import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
@ -47,25 +48,124 @@ import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToHref;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see VdcApi
* @author danikov
* @author danikov, Adrian Cole
*/
@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
public interface VdcAsyncApi {
/**
* @see VdcApi#getVdc(URI)
* @see VdcApi#get(String)
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Vdc> getVdc(@EndpointParam URI vdcURI);
ListenableFuture<? extends Vdc> get(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn);
/**
* @see VdcApi#captureVApp(String, CaptureVAppParams)
*/
@POST
@Path("/action/captureVApp")
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> captureVApp(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) CaptureVAppParams params);
/**
* @see VdcApi#cloneMedia(String, CloneMediaParams)
*/
@POST
@Path("/action/cloneMedia")
@Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
@JAXBResponseParser
ListenableFuture<Media> cloneMedia(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) CloneMediaParams params);
/**
* @see VdcApi#cloneVApp(String, CloneVAppParams)
*/
@POST
@Path("/action/cloneVApp")
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.CLONE_VAPP_PARAMS)
// TODO fix these etc.
@JAXBResponseParser
ListenableFuture<VApp> cloneVApp(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) CloneVAppParams params);
/**
* @see VdcApi#cloneVAppTemplate(String, CloneVAppTemplateParams)
*/
@POST
@Path("/action/cloneVAppTemplate")
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CLONE_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> cloneVAppTemplate(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params);
/**
* @see VdcApi#composeVApp(String, ComposeVAppParams)
*/
@POST
@Path("/action/composeVApp")
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS)
@JAXBResponseParser
ListenableFuture<VApp> composeVApp(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) ComposeVAppParams params);
/**
* @see VdcApi#instantiateVApp(String, InstantiateVAppParamsType)
*/
@POST
@Path("/action/instantiateVAppTemplate")
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VApp> instantiateVApp(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) InstantiateVAppParams params);
/**
* @see VdcApi#uploadVAppTemplate(String, UploadVAppTemplateParams)
*/
@POST
@Path("/action/uploadVAppTemplate")
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> uploadVAppTemplate(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params);
/**
* @see VdcApi#createMedia(String, Media)
*/
@POST
@Path("/media")
@Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.MEDIA)
@JAXBResponseParser
ListenableFuture<Media> createMedia(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn,
@BinderParam(BindToXMLPayload.class) Media media);
/**
* @see VdcApi#get(URI)
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends Vdc> get(@EndpointParam URI vdcHref);
/**
* @see VdcApi#captureVApp(URI, CaptureVAppParams)
*/
@ -74,9 +174,9 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CAPTURE_VAPP_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> captureVApp(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) CaptureVAppParams params);
ListenableFuture<VAppTemplate> captureVApp(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) CaptureVAppParams params);
/**
* @see VdcApi#cloneMedia(URI, CloneMediaParams)
*/
@ -85,20 +185,21 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
@JAXBResponseParser
ListenableFuture<Media> cloneMedia(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) CloneMediaParams params);
ListenableFuture<Media> cloneMedia(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) CloneMediaParams params);
/**
* @see VdcApi#cloneVApp(URI, CloneVAppParams)
*/
@POST
@Path("/action/cloneVApp")
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.CLONE_VAPP_PARAMS) //TODO fix these etc.
@Produces(VCloudDirectorMediaType.CLONE_VAPP_PARAMS)
// TODO fix these etc.
@JAXBResponseParser
ListenableFuture<VApp> cloneVApp(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) CloneVAppParams params);
ListenableFuture<VApp> cloneVApp(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) CloneVAppParams params);
/**
* @see VdcApi#cloneVAppTemplate(URI, CloneVAppTemplateParams)
*/
@ -107,9 +208,9 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.CLONE_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> cloneVAppTemplate(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params);
ListenableFuture<VAppTemplate> cloneVAppTemplate(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) CloneVAppTemplateParams params);
/**
* @see VdcApi#composeVApp(URI, ComposeVAppParams)
*/
@ -118,9 +219,9 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.COMPOSE_VAPP_PARAMS)
@JAXBResponseParser
ListenableFuture<VApp> composeVApp(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) ComposeVAppParams params);
ListenableFuture<VApp> composeVApp(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) ComposeVAppParams params);
/**
* @see VdcApi#instantiateVApp(URI, InstantiateVAppParamsType)
*/
@ -129,9 +230,9 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.VAPP)
@Produces(VCloudDirectorMediaType.INSTANTIATE_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VApp> instantiateVApp(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) InstantiateVAppParams params);
ListenableFuture<VApp> instantiateVApp(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) InstantiateVAppParams params);
/**
* @see VdcApi#uploadVAppTemplate(URI, UploadVAppTemplateParams)
*/
@ -140,9 +241,9 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.VAPP_TEMPLATE)
@Produces(VCloudDirectorMediaType.UPLOAD_VAPP_TEMPLATE_PARAMS)
@JAXBResponseParser
ListenableFuture<VAppTemplate> uploadVAppTemplate(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params);
ListenableFuture<VAppTemplate> uploadVAppTemplate(@EndpointParam URI vdcHref,
@BinderParam(BindToXMLPayload.class) UploadVAppTemplateParams params);
/**
* @see VdcApi#createMedia(URI, Media)
*/
@ -151,13 +252,12 @@ public interface VdcAsyncApi {
@Consumes(VCloudDirectorMediaType.MEDIA)
@Produces(VCloudDirectorMediaType.MEDIA)
@JAXBResponseParser
ListenableFuture<Media> createMedia(@EndpointParam URI vdcURI,
@BinderParam(BindToXMLPayload.class) Media media);
ListenableFuture<Media> createMedia(@EndpointParam URI vdcHref, @BinderParam(BindToXMLPayload.class) Media media);
/**
* @return asynchronous access to {@link Metadata.Readable} features
*/
@Delegate
MetadataAsyncApi.Readable getMetadataApi();
}

View File

@ -23,17 +23,17 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
import org.jclouds.vcloud.director.v1_5.features.MetadataApi.Writeable;
import org.jclouds.vcloud.director.v1_5.features.VdcApi;
/**
* Provides synchronous access to {@link AdminVdc}.
*
* @see AdminVdcAsyncApi
* @author danikov
* @author danikov, Adrian Cole
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface AdminVdcApi extends VdcApi {
@ -48,34 +48,45 @@ public interface AdminVdcApi extends VdcApi {
* @return the admin vDC or null if not found
*/
@Override
AdminVdc getVdc(URI vdcRef);
AdminVdc get(String vdcUrn);
@Override
AdminVdc get(URI vdcHref);
/**
* Modifies a Virtual Data Center. Virtual Data Center could be enabled or disabled.
* Additionally it could have one of these states FAILED_CREATION(-1), NOT_READY(0),
* READY(1), UNKNOWN(1) and UNRECOGNIZED(3).
*/
Task editVdc(URI vdcRef, AdminVdc vdc);
Task update(String vdcUrn, AdminVdc vdc);
Task update(URI vdcHref, AdminVdc vdc);
/**
* Deletes a Virtual Data Center. The Virtual Data Center should be disabled when delete is issued.
* Otherwise error code 400 Bad Request is returned.
*/
// TODO Saw what exception, instead of 400
Task deleteVdc(URI vdcRef);
Task delete(String vdcUrn);
Task delete(URI vdcHref);
/**
* Enables a Virtual Data Center. This operation enables disabled Virtual Data Center.
* If it is already enabled this operation has no effect.
*/
void enableVdc(@EndpointParam URI vdcRef);
void enable(String vdcUrn);
void enable(URI vdcHref);
/**
* Disables a Virtual Data Center. If the Virtual Data Center is disabled this operation does not
* have an effect.
*/
void disableVdc(URI vdcRef);
void disable(String vdcUrn);
void disable(URI vdcHref);
/**
* @return synchronous access to {@link Writeable} features
*/

View File

@ -38,48 +38,109 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncApi;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncApi.Writeable;
import org.jclouds.vcloud.director.v1_5.features.VdcAsyncApi;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToAdminHref;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see AdminVdcApi
* @author danikov
* @author danikov, Adrian Cole
*/
@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
public interface AdminVdcAsyncApi extends VdcAsyncApi {
/**
* @see AdminVdcApi#get(String)
*/
@Override
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<AdminVdc> getVdc(@EndpointParam URI vdcRef);
ListenableFuture<AdminVdc> get(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
/**
* @see AdminVdcApi#update(String, AdminVdc)
*/
@PUT
@Consumes
@Produces(VCloudDirectorMediaType.ADMIN_VDC)
@JAXBResponseParser
ListenableFuture<Task> editVdc(@EndpointParam URI vdcRef, AdminVdc vdc);
ListenableFuture<Task> update(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn, AdminVdc vdc);
/**
* @see AdminVdcApi#delete(String)
*/
@DELETE
@Consumes
@JAXBResponseParser
ListenableFuture<Task> deleteVdc(@EndpointParam URI vdcRef);
ListenableFuture<Task> delete(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
/**
* @see AdminVdcApi#enable(String)
*/
@POST
@Consumes
@Path("/action/enable")
@JAXBResponseParser
ListenableFuture<Void> enableVdc(@EndpointParam URI vdcRef);
ListenableFuture<Void> enable(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
/**
* @see AdminVdcApi#disable(String)
*/
@POST
@Consumes
@Path("/action/disable")
@JAXBResponseParser
ListenableFuture<Void> disableVdc(@EndpointParam URI vdcRef);
ListenableFuture<Void> disable(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn);
/**
* @see AdminVdcApi#get(URI)
*/
@Override
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<AdminVdc> get(@EndpointParam URI vdcHref);
/**
* @see AdminVdcApi#update(URI, AdminVdc)
*/
@PUT
@Consumes
@Produces(VCloudDirectorMediaType.ADMIN_VDC)
@JAXBResponseParser
ListenableFuture<Task> update(@EndpointParam URI vdcHref, AdminVdc vdc);
/**
* @see AdminVdcApi#delete(URI)
*/
@DELETE
@Consumes
@JAXBResponseParser
ListenableFuture<Task> delete(@EndpointParam URI vdcHref);
/**
* @see AdminVdcApi#enable(URI)
*/
@POST
@Consumes
@Path("/action/enable")
@JAXBResponseParser
ListenableFuture<Void> enable(@EndpointParam URI vdcHref);
/**
* @see AdminVdcApi#disable(URI)
*/
@POST
@Consumes
@Path("/action/disable")
@JAXBResponseParser
ListenableFuture<Void> disable(@EndpointParam URI vdcHref);
/**
* @return asynchronous access to {@link Writeable} features
*/

View File

@ -61,7 +61,7 @@ public class AllVdcsInOrg implements Function<AdminOrg, Iterable<? extends Vdc>>
new Function<Reference, Future<? extends Vdc>>() {
@Override
public Future<? extends Vdc> apply(Reference from) {
return aapi.getVdcApi().getVdc(from.getHref());
return aapi.getVdcApi().get(from.getHref());
}
}, executor, null, logger, "vdcs in org " + org.getName());

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class VdcURNToAdminHref extends URNToHref {
@Inject
public VdcURNToAdminHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.ADMIN_VDC;
}
}

View File

@ -0,0 +1,43 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.functions.href;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Entity;
import org.jclouds.vcloud.director.v1_5.functions.URNToHref;
import com.google.common.cache.LoadingCache;
@Singleton
public class VdcURNToHref extends URNToHref {
@Inject
public VdcURNToHref(LoadingCache<String, Entity> resolveEntityCache) {
super(resolveEntityCache);
}
@Override
protected String type() {
return VCloudDirectorMediaType.VDC;
}
}

View File

@ -134,8 +134,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
@BeforeClass(alwaysRun = true, description = "Retrieves the required apis from the REST API context")
protected void setupEnvironment() {
// Get the configured Vdc for the tests
vdc = vdcApi.getVdc(vdcURI);
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
vdc = lazyGetVdc();
// Get the configured VAppTemplate for the tests
vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI);
@ -192,7 +191,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT
@AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps")
protected void cleanUpEnvironment() {
vdc = vdcApi.getVdc(vdcURI); // Refresh
vdc = vdcApi.get(vdcUrn); // Refresh
// Find references in the Vdc with the VApp type and in the list of instantiated VApp names
Iterable<Reference> vApps = Iterables.filter(vdc.getResourceEntities(),

View File

@ -21,8 +21,6 @@ package org.jclouds.vcloud.director.v1_5.features;
import static com.google.common.base.Predicates.and;
import static com.google.common.collect.Iterables.find;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CORRECT_VALUE_OBJECT_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCatalogItem;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
@ -134,7 +132,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /catalog/{id}")
public void testGetCatalog() {
Catalog catalog = catalogApi.get(catalogUrn);
Catalog catalog = lazyGetCatalog();
assertNotNull(catalog);
// Double check it's pointing at the correct catalog
assertEquals(catalog.getId(), catalogUrn);
@ -149,11 +147,8 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /catalog/{id}/catalogItems")
public void testAddCatalogItem() {
assertNotNull(vdcURI, String.format(URN_REQ_LIVE, VDC));
byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
Vdc vdc = context.getApi().getVdcApi().getVdc(vdcURI);
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
Vdc vdc = lazyGetVdc();
Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));
Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media 1").size(iso.length)
@ -189,13 +184,13 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /catalog/{id}/metadata")
public void testGetCatalogMetadata() {
Metadata catalogMetadata = catalogApi.getMetadataApi().get(catalogApi.get(catalogUrn).getHref());
Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref());
checkMetadata(catalogMetadata);
}
@Test(description = "GET /catalog/{id}/metadata/{key}")
public void testGetCatalogMetadataValue() {
Metadata catalogMetadata = catalogApi.getMetadataApi().get(catalogApi.get(catalogUrn).getHref());
Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref());
MetadataEntry existingMetadataEntry = Iterables.find(catalogMetadata.getMetadataEntries(),
new Predicate<MetadataEntry>() {
@Override

View File

@ -35,7 +35,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.relEquals;
import static org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates.typeEquals;
@ -128,9 +127,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /vdc/{id}/media")
public void testCreateMedia() throws URISyntaxException {
assertNotNull(vdcURI, String.format(URN_REQ_LIVE, VDC));
Vdc vdc = vdcApi.getVdc(vdcURI);
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
Vdc vdc = lazyGetVdc();
Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));
// TODO: generate an iso
@ -207,7 +204,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "POST /vdc/{id}/action/cloneMedia", dependsOnMethods = { "testGetMediaOwner" })
public void testCloneMedia() {
oldMedia = media;
media = vdcApi.cloneMedia(vdcURI, CloneMediaParams.builder()
media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build())
.name("copied "+media.getName())
.description("copied by testCloneMedia()")
@ -230,7 +227,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest {
mediaApi.getMetadataApi().putEntry(media.getHref(), "key", MetadataValue.builder().value("value").build());
media = vdcApi.cloneMedia(vdcURI, CloneMediaParams.builder()
media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build())
.name("moved test media")
.description("moved by testCloneMedia()")

View File

@ -47,10 +47,10 @@ import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
* Tests live behavior of {@link OrgApi}.
*
* @author grkvlt@apache.org
*/
* Tests live behavior of {@link OrgApi}.
*
* @author grkvlt@apache.org
*/
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "OrgApiLiveTest")
public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@ -65,18 +65,18 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void setupRequiredApis() {
orgApi = context.getApi().getOrgApi();
}
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (adminMembersSet) {
try {
Task delete = adminContext.getApi().getOrgApi().getMetadataApi().deleteEntry(toAdminUri(orgURI), "KEY");
taskDoneEventually(delete);
Task delete = adminContext.getApi().getOrgApi().getMetadataApi().deleteEntry(toAdminUri(orgURI), "KEY");
taskDoneEventually(delete);
} catch (Exception e) {
logger.warn(e, "Error when deleting metadata entry");
}
try {
adminContext.getApi().getCatalogApi().delete(catalogUrn);
adminContext.getApi().getCatalogApi().delete(catalogUrn);
} catch (Exception e) {
logger.warn(e, "Error when deleting catalog'%s': %s", catalogUrn);
}
@ -96,14 +96,15 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testGetOrgList() {
// Call the method being tested
orgList = orgApi.list();
// NOTE The environment MUST have at least one organisation configured
// Check test requirements
assertFalse(Iterables.isEmpty(orgList), String.format(NOT_EMPTY_OBJECT_FMT, "Org", "OrgList"));
for (Reference orgRef : orgList) {
assertEquals(orgRef.getType(), VCloudDirectorMediaType.ORG, String.format(CONDITION_FMT, "Reference.Type", VCloudDirectorMediaType.ORG, orgRef.getType()));
assertEquals(orgRef.getType(), VCloudDirectorMediaType.ORG,
String.format(CONDITION_FMT, "Reference.Type", VCloudDirectorMediaType.ORG, orgRef.getType()));
checkReferenceType(orgRef);
}
}
@ -112,64 +113,66 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public void testGetOrg() {
Reference orgRef = Iterables.getFirst(orgList, null);
assertNotNull(orgRef);
orgURI = orgRef.getHref();
// Call the method being tested
org = orgApi.get(orgURI);
assertEquals(orgApi.get(org.getId()), org);
checkOrg(org);
if (adminContext != null) {
setupAdminMembers();
}
}
/**
* If we're running in an admin context, it's cleaner to make temporary entities, plus eliminates the need for configuration
* If we're running in an admin context, it's cleaner to make temporary entities, plus eliminates
* the need for configuration
*/
private void setupAdminMembers() {
adminContext.getApi().getOrgApi().getMetadataApi().putEntry(toAdminUri(orgURI),
"KEY", MetadataValue.builder().value("VALUE").build());
AdminCatalog newCatalog = AdminCatalog.builder()
.name("Test Catalog "+getTestDateTimeStamp())
.description("created by testOrg()")
.build();
adminContext.getApi().getOrgApi().getMetadataApi()
.putEntry(toAdminUri(orgURI), "KEY", MetadataValue.builder().value("VALUE").build());
AdminCatalog newCatalog = AdminCatalog.builder().name("Test Catalog " + getTestDateTimeStamp())
.description("created by testOrg()").build();
newCatalog = adminContext.getApi().getCatalogApi().createCatalogInOrg(newCatalog, org.getId());
catalogUrn = newCatalog.getId();
adminMembersSet = true;
}
@Test(description = "GET /org/{id}/metadata", dependsOnMethods = { "testGetOrg" })
public void testGetOrgMetadata() {
// Call the method being tested
Metadata metadata = orgApi.getMetadataApi().get(orgURI);
// NOTE The environment MUST have at one metadata entry for the first organisation configured
checkMetadata(metadata);
// Check requirements for this test
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(NOT_EMPTY_OBJECT_FMT, "MetadataEntry", "Org"));
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(NOT_EMPTY_OBJECT_FMT, "MetadataEntry", "Org"));
}
@Test(description = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" })
public void testGetOrgMetadataValue() {
// Call the method being tested
MetadataValue value = orgApi.getMetadataApi().getValue(orgURI, "KEY");
// NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )'
// NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE"
// )'
String expected = "VALUE";
checkMetadataValue(value);
assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue()));
assertEquals(value.getValue(), expected,
String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue()));
}
}

View File

@ -124,7 +124,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
@BeforeClass(alwaysRun = true)
protected void setupRequiredEntities() {
Set<Link> links = vdcApi.getVdc(vdcURI).getLinks();
Set<Link> links = lazyGetVdc().getLinks();
if (mediaURI == null) {
Predicate<Link> addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA));
@ -214,7 +214,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest {
public void testRecomposeVApp() {
Set<Vm> vms = getAvailableVMsFromVAppTemplates();
VApp composedVApp = vdcApi.composeVApp(vdcURI, ComposeVAppParams.builder()
VApp composedVApp = vdcApi.composeVApp(vdcUrn, ComposeVAppParams.builder()
.name(name("composed-"))
.instantiationParams(instantiationParams())
.build());

View File

@ -105,7 +105,7 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest {
.isSourceDelete(false)
.name("clone")
.build();
VAppTemplate clonedVappTemplate = vdcApi.cloneVAppTemplate(vdcURI, cloneVAppTemplateParams);
VAppTemplate clonedVappTemplate = vdcApi.cloneVAppTemplate(vdcUrn, cloneVAppTemplateParams);
if (waitForTask) {
Task cloneTask = Iterables.getFirst(clonedVappTemplate.getTasks(), null);

View File

@ -83,7 +83,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
Vdc expected = getVdc();
assertEquals(api.getVdcApi().getVdc(vdcURI), expected);
assertEquals(api.getVdcApi().get(vdcURI), expected);
}
@Test
@ -105,7 +105,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
.build();
try {
api.getVdcApi().getVdc(URI.create(endpoint + "/vdc/NOTAUUID"));
api.getVdcApi().get(URI.create(endpoint + "/vdc/NOTAUUID"));
fail("Should give HTTP 400 error");
} catch (VCloudDirectorException vde) {
assertEquals(vde.getError(), expected);
@ -124,7 +124,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
.xmlFilePayload("/vdc/error403-fake.xml", VCloudDirectorMediaType.ERROR)
.httpResponseBuilder().statusCode(403).build());
assertNull(api.getVdcApi().getVdc(URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")));
assertNull(api.getVdcApi().get(URI.create(endpoint + "/vdc/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")));
}
@Test(enabled = false)

View File

@ -25,7 +25,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.U
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.Map;
@ -69,7 +68,7 @@ import com.google.common.collect.Iterables;
*/
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcApiLiveTest")
public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public static final String VDC = "vdc";
/*
@ -78,7 +77,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
protected VdcApi vdcApi;
protected VAppTemplateApi vappTemplateApi;
protected VAppApi vappApi;
private VApp instantiatedVApp;
private VApp clonedVApp;
private VApp composedVApp;
@ -87,18 +86,18 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
private VAppTemplate uploadedVAppTemplate;
private boolean metadataSet = false;
private Network network;
@Override
@BeforeClass(alwaysRun = true)
public void setupRequiredApis() {
vdcApi = context.getApi().getVdcApi();
vappTemplateApi = context.getApi().getVAppTemplateApi();
vappApi = context.getApi().getVAppApi();
assertNotNull(vdcURI, String.format(URN_REQ_LIVE, VDC));
assertNotNull(vdcUrn, String.format(URN_REQ_LIVE, VDC));
network = lazyGetNetwork();
}
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (clonedVAppTemplate != null) {
@ -119,236 +118,218 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
if (composedVApp != null) {
cleanUpVApp(composedVApp);
}
if (metadataSet) {
try {
Task delete = adminContext.getApi().getVdcApi().getMetadataApi().deleteEntry(toAdminUri(vdcURI), "key");
taskDoneEventually(delete);
Task delete = adminContext.getApi().getVdcApi().getMetadataApi().deleteEntry(lazyGetVdc().getHref(), "key");
taskDoneEventually(delete);
} catch (Exception e) {
logger.warn(e, "Error deleting metadata entry");
}
}
}
@Test(description = "GET /vdc/{id}")
public void testGetVdc() {
Vdc vdc = vdcApi.getVdc(vdcURI);
Vdc vdc = lazyGetVdc();
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
assertTrue(!vdc.getDescription().equals("DO NOT USE"), "vDC isn't to be used for testing");
assertFalse("DO NOT USE".equals(vdc.getDescription()), "vDC isn't to be used for testing");
Checks.checkVdc(vdc);
}
@Test(description = "POST /vdc/{id}/action/captureVApp", dependsOnMethods = { "testInstantiateVAppTemplate" } )
@Test(description = "POST /vdc/{id}/action/captureVApp", dependsOnMethods = { "testInstantiateVAppTemplate" })
public void testCaptureVApp() {
String name = name("captured-");
CaptureVAppParams captureVappParams = CaptureVAppParams.builder()
.name(name)
.source(instantiatedVApp.getHref())
// TODO: test optional params
//.description("")
//.sections(sections) // TODO: ovf sections
CaptureVAppParams captureVappParams = CaptureVAppParams.builder().name(name).source(instantiatedVApp.getHref())
// TODO: test optional params
// .description("")
// .sections(sections) // TODO: ovf sections
.build();
capturedVAppTemplate = vdcApi.captureVApp(vdcURI, captureVappParams);
capturedVAppTemplate = vdcApi.captureVApp(vdcUrn, captureVappParams);
Task task = Iterables.getFirst(capturedVAppTemplate.getTasks(), null);
assertTaskSucceedsLong(task);
Checks.checkVAppTemplate(capturedVAppTemplate);
assertEquals(capturedVAppTemplate.getName(), name,
assertEquals(capturedVAppTemplate.getName(), name,
String.format(OBJ_FIELD_EQ, "VAppTemplate", "name", name, capturedVAppTemplate.getName()));
}
@Test(description = "POST /vdc/{id}/action/cloneVApp", dependsOnMethods = { "testInstantiateVAppTemplate" } )
@Test(description = "POST /vdc/{id}/action/cloneVApp", dependsOnMethods = { "testInstantiateVAppTemplate" })
public void testCloneVApp() {
CloneVAppParams cloneVappParams = CloneVAppParams.builder()
.source(instantiatedVApp.getHref())
// TODO: test optional params
//.name("")
//.description("")
//.deploy(true)
//.isSourceDelete(true)
//.powerOn(true)
//.instantiationParams(InstantiationParams.builder()
// .sections(sections) // TODO: ovf sections? various tests?
// .build())
CloneVAppParams cloneVappParams = CloneVAppParams.builder().source(instantiatedVApp.getHref())
// TODO: test optional params
// .name("")
// .description("")
// .deploy(true)
// .isSourceDelete(true)
// .powerOn(true)
// .instantiationParams(InstantiationParams.builder()
// .sections(sections) // TODO: ovf sections? various tests?
// .build())
// Reserved. Unimplemented params; may test eventually when implemented
//.vAppParent(vAppParentRef)
//.linkedClone(true)
// .vAppParent(vAppParentRef)
// .linkedClone(true)
.build();
clonedVApp = vdcApi.cloneVApp(vdcURI, cloneVappParams);
clonedVApp = vdcApi.cloneVApp(vdcUrn, cloneVappParams);
Task task = Iterables.getFirst(clonedVApp.getTasks(), null);
assertNotNull(task, "vdcApi.cloneVApp returned VApp that did not contain any tasks");
assertTaskSucceedsLong(task);
Checks.checkVApp(clonedVApp);
}
@Test(description = "POST /vdc/{id}/action/cloneVAppTemplate")
public void testCloneVAppTemplate() {
clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcURI, CloneVAppTemplateParams.builder()
.source(vAppTemplateURI)
clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn, CloneVAppTemplateParams.builder().source(vAppTemplateURI)
.build());
Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null);
assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks");
assertTaskSucceedsLong(task);
Checks.checkVAppTemplate(clonedVAppTemplate);
}
@Test(description = "POST /vdc/{id}/action/composeVApp")
public void testComposeVApp() {
String name = name("composed-");
composedVApp = vdcApi.composeVApp(vdcURI, ComposeVAppParams.builder()
.name(name)
// TODO: test optional params
//.sourcedItem(SourcedCompositionItemParam.builder()
//.sourcedItem(vAppTemplateURI)
//.build())
//.description("")
//.deploy(true)
//.isSourceDelete(false)
//.powerOn(true)
//.instantiationParams(InstantiationParams.builder()
// .sections(sections) // TODO: ovf sections? various tests?
// .build())
// Reserved. Unimplemented params; may test eventually when implemented
//.linkedClone()
.build());
composedVApp = vdcApi.composeVApp(vdcUrn, ComposeVAppParams.builder().name(name)
// TODO: test optional params
// .sourcedItem(SourcedCompositionItemParam.builder()
// .sourcedItem(vAppTemplateURI)
// .build())
// .description("")
// .deploy(true)
// .isSourceDelete(false)
// .powerOn(true)
// .instantiationParams(InstantiationParams.builder()
// .sections(sections) // TODO: ovf sections? various tests?
// .build())
// Reserved. Unimplemented params; may test eventually when implemented
// .linkedClone()
.build());
Task task = Iterables.getFirst(composedVApp.getTasks(), null);
assertNotNull(task, "vdcApi.composeVApp returned VApp that did not contain any tasks");
assertTaskSucceedsLong(task);
Checks.checkVApp(composedVApp);
assertEquals(composedVApp.getName(), name,
assertEquals(composedVApp.getName(), name,
String.format(OBJ_FIELD_EQ, "VApp", "name", name, composedVApp.getName()));
}
// TODO Duplicates code in VAppApiLiveTest
@Test(description = "POST /vdc/{id}/action/instantiateVAppTemplate")
public void testInstantiateVAppTemplate() {
Vdc vdc = vdcApi.getVdc(vdcURI);
Vdc vdc = vdcApi.get(vdcUrn);
Set<Reference> networks = vdc.getAvailableNetworks();
Optional<Reference> parentNetwork = Iterables.tryFind(
networks, new Predicate<Reference>() {
@Override
public boolean apply(Reference reference) {
return reference.getHref().equals(network.getHref());
}
});
Optional<Reference> parentNetwork = Iterables.tryFind(networks, new Predicate<Reference>() {
@Override
public boolean apply(Reference reference) {
return reference.getHref().equals(network.getHref());
}
});
if (!parentNetwork.isPresent()) {
fail(String.format("Could not find network %s in vdc", network.getHref().toASCIIString()));
}
NetworkConfiguration networkConfiguration = NetworkConfiguration.builder()
.parentNetwork(parentNetwork.get())
.fenceMode(FenceMode.BRIDGED)
.build();
NetworkConfigSection networkConfigSection = NetworkConfigSection.builder()
NetworkConfiguration networkConfiguration = NetworkConfiguration.builder().parentNetwork(parentNetwork.get())
.fenceMode(FenceMode.BRIDGED).build();
NetworkConfigSection networkConfigSection = NetworkConfigSection
.builder()
.info("Configuration parameters for logical networks")
.networkConfigs(
ImmutableSet.of(VAppNetworkConfiguration.builder()
.networkName("vAppNetwork")
.configuration(networkConfiguration)
.build()))
.build();
ImmutableSet.of(VAppNetworkConfiguration.builder().networkName("vAppNetwork")
.configuration(networkConfiguration).build())).build();
InstantiationParams instantiationParams = InstantiationParams.builder()
.sections(ImmutableSet.of(networkConfigSection))
.build();
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder()
.name(name("test-vapp-"))
.notDeploy()
.notPowerOn()
.description("Test VApp")
.instantiationParams(instantiationParams)
.source(vAppTemplateURI)
.build();
.sections(ImmutableSet.of(networkConfigSection)).build();
instantiatedVApp = vdcApi.instantiateVApp(vdcURI, instantiate);
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name("test-vapp-"))
.notDeploy().notPowerOn().description("Test VApp").instantiationParams(instantiationParams)
.source(vAppTemplateURI).build();
instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiate);
Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null);
assertTaskSucceedsLong(instantiationTask);
Checks.checkVApp(instantiatedVApp);
}
@Test(description = "POST /vdc/{id}/action/uploadVAppTemplate")
public void testUploadVAppTemplate() {
// TODO Should test all 4 stages of upload; currently doing only stage 1 here.
// 1. creating empty vApp template entity
// 2. uploading an OVF of vApp template
// 3. uploading disks described from the OVF
// 4. finishing task for uploading
// 1. creating empty vApp template entity
// 2. uploading an OVF of vApp template
// 3. uploading disks described from the OVF
// 4. finishing task for uploading
String name = name("uploaded-");
UploadVAppTemplateParams uploadVAppTemplateParams = UploadVAppTemplateParams.builder()
.name(name)
// TODO: test optional params
//.description("")
//.transferFormat("")
//.manifestRequired(true)
UploadVAppTemplateParams uploadVAppTemplateParams = UploadVAppTemplateParams.builder().name(name)
// TODO: test optional params
// .description("")
// .transferFormat("")
// .manifestRequired(true)
.build();
uploadedVAppTemplate = vdcApi.uploadVAppTemplate(vdcURI, uploadVAppTemplateParams);
uploadedVAppTemplate = vdcApi.uploadVAppTemplate(vdcUrn, uploadVAppTemplateParams);
Checks.checkVAppTemplateWhenNotReady(uploadedVAppTemplate);
assertEquals(uploadedVAppTemplate.getName(), name,
assertEquals(uploadedVAppTemplate.getName(), name,
String.format(OBJ_FIELD_EQ, "VAppTemplate", "name", name, uploadedVAppTemplate.getName()));
ResourceEntity.Status expectedStatus = ResourceEntity.Status.UNRESOLVED;
ResourceEntity.Status actualStatus = uploadedVAppTemplate.getStatus();
assertEquals(actualStatus, expectedStatus,
String.format(OBJ_FIELD_EQ, "VAppTemplate", "status", expectedStatus, actualStatus));
}
private void setupMetadata() {
adminContext.getApi().getVdcApi().getMetadataApi().putEntry(toAdminUri(vdcURI),
"key", MetadataValue.builder().value("value").build());
adminContext.getApi().getVdcApi().getMetadataApi()
.putEntry(lazyGetVdc().getHref(), "key", MetadataValue.builder().value("value").build());
metadataSet = true;
}
@Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testGetVdc" } )
@Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testGetVdc" })
public void testGetMetadata() {
if(adminContext != null) {
if (adminContext != null) {
setupMetadata();
}
Metadata metadata = vdcApi.getMetadataApi().get(vdcURI);
Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref());
// required for testing
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries"));
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries"));
Checks.checkMetadataFor(VDC, metadata);
}
@Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" } )
@Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
public void testGetMetadataValue() {
// First find a key
Metadata metadata = vdcApi.getMetadataApi().get(vdcURI);
Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref());
Map<String, String> metadataMap = Checks.metadataToMap(metadata);
String key = Iterables.getFirst(metadataMap.keySet(), "MadeUpKey!");
String value = metadataMap.get(key);
MetadataValue metadataValue = vdcApi.getMetadataApi().getValue(vdcURI, key);
MetadataValue metadataValue = vdcApi.getMetadataApi().getValue(lazyGetVdc().getHref(), key);
Checks.checkMetadataValueFor(VDC, metadataValue, value);
}
}

View File

@ -122,7 +122,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest {
@BeforeClass(alwaysRun = true)
protected void setupRequiredEntities() {
Set<Link> links = vdcApi.getVdc(vdcURI).getLinks();
Set<Link> links = vdcApi.get(vdcUrn).getLinks();
if (mediaURI == null) {
Predicate<Link> addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA));

View File

@ -56,7 +56,7 @@ public class AdminVdcApiExpectTest extends VCloudDirectorAdminApiExpectTest {
AdminVdc expected = adminVdc();
assertEquals(api.getVdcApi().getVdc(vdcRef.getHref()), expected);
assertEquals(api.getVdcApi().get(vdcRef.getHref()), expected);
}
public static final AdminVdc adminVdc() {

View File

@ -19,13 +19,10 @@
package org.jclouds.vcloud.director.v1_5.features.admin;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
@ -47,34 +44,30 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminVdcApiLiveTest")
public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
public static final String VDC = "admin vdc";
/*
* Convenience reference to API api.
*/
protected AdminVdcApi vdcApi;
protected MetadataApi.Writeable metadataApi;
protected URI adminVdcUri;
private String metadataKey;
private String metadataValue;
@Override
@BeforeClass(alwaysRun = true)
public void setupRequiredApis() {
vdcApi = adminContext.getApi().getVdcApi();
metadataApi = vdcApi.getMetadataApi();
assertNotNull(vdcURI, String.format(URN_REQ_LIVE, VDC));
adminVdcUri = toAdminUri(vdcURI);
}
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (metadataKey != null) {
try {
Task task = metadataApi.deleteEntry(adminVdcUri, metadataKey);
Task task = metadataApi.deleteEntry(lazyGetVdc().getHref(), metadataKey);
taskDoneEventually(task);
} catch (VCloudDirectorException e) {
logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing...");
@ -84,31 +77,29 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
@Test(description = "GET /admin/vdc/{id}")
public void testGetVdc() {
AdminVdc vdc = vdcApi.getVdc(adminVdcUri);
AdminVdc vdc = vdcApi.get(vdcUrn);
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
// parent type
Checks.checkAdminVdc(vdc);
}
// TODO insufficient permissions to test
@Test(description = "PUT /admin/vdc/{id}", enabled=false)
@Test(description = "PUT /admin/vdc/{id}", enabled = false)
public void testEditVdc() throws Exception {
String origName = vdcApi.getVdc(adminVdcUri).getName();
String origName = lazyGetVdc().getName();
String newName = name("a");
Exception exception = null;
AdminVdc vdc = AdminVdc.builder()
.name(newName)
.build();
AdminVdc vdc = AdminVdc.builder().name(newName).build();
try {
Task task = vdcApi.editVdc(adminVdcUri, vdc);
Task task = vdcApi.update(vdcUrn, vdc);
assertTaskSucceeds(task);
AdminVdc modified = vdcApi.getVdc(adminVdcUri);
AdminVdc modified = vdcApi.get(vdcUrn);
assertEquals(modified.getName(), newName);
// parent type
Checks.checkAdminVdc(vdc);
} catch (Exception e) {
@ -116,7 +107,7 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} finally {
try {
AdminVdc restorableVdc = AdminVdc.builder().name(origName).build();
Task task = vdcApi.editVdc(adminVdcUri, restorableVdc);
Task task = vdcApi.update(vdcUrn, restorableVdc);
assertTaskSucceeds(task);
} catch (Exception e) {
if (exception != null) {
@ -128,34 +119,35 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
}
}
}
// TODO insufficient permissions to test
@Test(description = "DELETE /admin/vdc/{id}", enabled=false)
@Test(description = "DELETE /admin/vdc/{id}", enabled = false)
public void testDeleteVdc() throws Exception {
// TODO Need to have a VDC that we're happy to delete!
Task task = vdcApi.deleteVdc(adminVdcUri);
Task task = vdcApi.delete(vdcUrn);
assertTaskSucceeds(task);
try {
vdcApi.getVdc(adminVdcUri);
vdcApi.get(vdcUrn);
} catch (VCloudDirectorException e) {
// success; unreachable because it has been deleted
// TODO: ^^ wrong. this should return null
}
}
// TODO insufficient permissions to test
@Test(description = "DISABLE/ENABLE /admin/vdc/{id}", enabled=false)
@Test(description = "DISABLE/ENABLE /admin/vdc/{id}", enabled = false)
public void testDisableAndEnableVdc() throws Exception {
// TODO Need to have a VDC that we're happy to delete!
Exception exception = null;
try {
vdcApi.disableVdc(adminVdcUri);
vdcApi.disable(vdcUrn);
} catch (Exception e) {
exception = e;
} finally {
try {
vdcApi.enableVdc(adminVdcUri);
vdcApi.enable(vdcUrn);
} catch (Exception e) {
if (exception != null) {
logger.warn(e, "Error resetting adminVdc.name; rethrowing original test exception...");
@ -166,63 +158,62 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest {
}
}
}
@Test(description = "GET /admin/vdc/{id}/metadata")
public void testGetMetadata() throws Exception {
Metadata metadata = metadataApi.get(adminVdcUri);
Metadata metadata = metadataApi.get(lazyGetVdc().getHref());
Checks.checkMetadata(metadata);
}
// TODO insufficient permissions to test
@Test(description = "PUT /admin/vdc/{id}/metadata", enabled=false)
@Test(description = "PUT /admin/vdc/{id}/metadata", enabled = false)
public void testSetMetadata() throws Exception {
metadataKey = name("key-");
metadataValue = name("value-");
Metadata metadata = Metadata.builder()
.entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build())
Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build())
.build();
Task task = metadataApi.merge(adminVdcUri, metadata);
Task task = metadataApi.merge(lazyGetVdc().getHref(), metadata);
assertTaskSucceeds(task);
MetadataValue modified = metadataApi.getValue(adminVdcUri, metadataKey);
MetadataValue modified = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey);
Checks.checkMetadataValueFor("AdminVdc", modified, metadataValue);
Checks.checkMetadata(metadata);
}
// TODO insufficient permissions to test
@Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled=false)
@Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled = false)
public void testGetMetadataValue() throws Exception {
MetadataValue retrievedMetadataValue = metadataApi.getValue(adminVdcUri, metadataKey);
MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey);
Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue);
}
// TODO insufficient permissions to test
@Test(description = "PUT /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }, enabled=false )
@Test(description = "PUT /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }, enabled = false)
public void testSetMetadataValue() throws Exception {
metadataValue = name("value-");
MetadataValue newV = MetadataValue.builder().value(metadataValue).build();
Task task = metadataApi.putEntry(adminVdcUri, metadataKey, newV);
Task task = metadataApi.putEntry(lazyGetVdc().getHref(), metadataKey, newV);
assertTaskSucceeds(task);
MetadataValue retrievedMetadataValue = metadataApi.getValue(adminVdcUri, metadataKey);
MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey);
Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue);
}
// TODO insufficient permissions to test
@Test(description = "DELETE /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled=false )
@Test(description = "DELETE /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled = false)
public void testDeleteMetadataValue() throws Exception {
// TODO Remove dependency on other tests; make cleanUp delete a list of metadata entries?
Task task = metadataApi.deleteEntry(adminVdcUri, metadataKey);
Task task = metadataApi.deleteEntry(lazyGetVdc().getHref(), metadataKey);
assertTaskSucceeds(task);
try {
metadataApi.getValue(adminVdcUri, metadataKey);
fail("Retrieval of metadata value "+metadataKey+" should have fail after deletion");
metadataApi.getValue(lazyGetVdc().getHref(), metadataKey);
fail("Retrieval of metadata value " + metadataKey + " should have fail after deletion");
} catch (VCloudDirectorException e) {
// success; should not be accessible
}

View File

@ -19,12 +19,10 @@
package org.jclouds.vcloud.director.v1_5.internal;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.getFirst;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.tryFind;
import static com.google.common.io.Closeables.closeQuietly;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
@ -33,6 +31,9 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.U
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CATALOG;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ORG_NETWORK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.USER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VDC;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@ -58,6 +59,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi;
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncApi;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
@ -97,7 +99,6 @@ import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@ -120,9 +121,6 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected static final long TASK_TIMEOUT_SECONDS = 100L;
protected static final long LONG_TASK_TIMEOUT_SECONDS = 300L;
public static final String VAPP = "vApp";
public static final String VAPP_TEMPLATE = "vAppTemplate";
public static final String VDC = "vdc";
public static final int REQUIRED_ADMIN_VM_QUOTA = 0;
public static final int REQUIRED_USER_VM_QUOTA = 0;
@ -135,11 +133,13 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
protected Session session;
protected String catalogUrn;
private Catalog catalog;
protected URI vAppTemplateURI;
protected URI mediaURI;
protected String networkUrn;
private Network network;
protected URI vdcURI;
protected String vdcUrn;
private Vdc vdc;
protected String userUrn;
private User user;
@ -255,9 +255,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
if (vAppTemplateId != null)
vAppTemplateURI = URI.create(endpoint + "/vAppTemplate/" + vAppTemplateId);
String vdcId = emptyToNull(System.getProperty("test." + provider + ".vdc-id"));
if (vdcId != null)
vdcURI = URI.create(endpoint + "/vdc/" + vdcId);
vdcUrn = emptyToNull(System.getProperty("test." + provider + ".vdc-id"));
String mediaId = emptyToNull(System.getProperty("test." + provider + ".media-id"));
if (mediaId != null)
@ -271,11 +269,13 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
find(context.getApi().getOrgApi().list(),
ReferencePredicates.<Reference> nameEquals(session.get())).getHref());
if (any(Lists.newArrayList(vAppTemplateURI, networkUrn, vdcURI), Predicates.isNull())) {
if (any(Lists.newArrayList(vAppTemplateURI, networkUrn, vdcUrn), Predicates.isNull())) {
if (vdcURI == null)
vdcURI = find(org.getLinks(),
ReferencePredicates.<Link> typeEquals(VDC)).getHref();
if (vdcUrn == null) {
vdc = context.getApi().getVdcApi().get(find(org.getLinks(),
ReferencePredicates.<Link> typeEquals(VDC)).getHref());
vdcUrn = vdc.getId();
}
if (networkUrn == null) {
network = context.getApi().getNetworkApi().get(find(org.getLinks(),
@ -283,14 +283,29 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
networkUrn = network.getId();
}
// FIXME the URI should be opaque
if (isNullOrEmpty(catalogUrn)) {
String uri = find(org.getLinks(),
ReferencePredicates.<Link> typeEquals(CATALOG)).getHref().toASCIIString();
catalogUrn = getLast(Splitter.on('/').split(uri));
if (catalogUrn == null) {
catalog = context.getApi().getCatalogApi().get(find(org.getLinks(),
ReferencePredicates.<Link> typeEquals(CATALOG)).getHref());
catalogUrn = catalog.getId();
}
}
}
protected Vdc lazyGetVdc() {
if (vdc == null) {
assertNotNull(vdcUrn, String.format(URN_REQ_LIVE, VDC));
vdc = from(org.getLinks()).filter(LinkPredicates.typeEquals(VDC))
.transform(new Function<Link, Vdc>() {
@Override
public Vdc apply(Link in) {
return context.getApi().getVdcApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(vdcUrn)).get();
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
}
return vdc;
}
protected Network lazyGetNetwork() {
if (network == null) {
@ -303,21 +318,42 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
return context.getApi().getNetworkApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(networkUrn)).get();
assertNotNull(network, String.format(ENTITY_NON_NULL, NETWORK));
}
return network;
}
protected Catalog lazyGetCatalog() {
if (catalog == null) {
assertNotNull(catalogUrn, String.format(URN_REQ_LIVE, CATALOG));
catalog = from(org.getLinks()).filter(LinkPredicates.typeEquals(CATALOG))
.transform(new Function<Link, Catalog>() {
@Override
public Catalog apply(Link in) {
return context.getApi().getCatalogApi().get(in.getHref());
}
}).firstMatch(EntityPredicates.idEquals(catalogUrn)).get();
assertNotNull(catalog, String.format(ENTITY_NON_NULL, CATALOG));
}
return catalog;
}
protected User lazyGetUser() {
if (user == null) {
assertNotNull(userUrn, String.format(URN_REQ_LIVE, USER));
user = adminContext.getApi().getUserApi().get(userUrn);
assertNotNull(user, String.format(ENTITY_NON_NULL, USER));
}
return user;
}
@Deprecated
public URI toAdminUri(Reference ref) {
return toAdminUri(ref.getHref());
}
@Deprecated
public URI toAdminUri(URI uri) {
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
}
@ -377,7 +413,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
.build();
VdcApi vdcApi = context.getApi().getVdcApi();
VApp vAppInstantiated = vdcApi.instantiateVApp(vdcURI, instantiate);
VApp vAppInstantiated = vdcApi.instantiateVApp(vdcUrn, instantiate);
assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP));
Task instantiationTask = getFirst(vAppInstantiated.getTasks(), null);
@ -415,7 +451,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest<
/** Build a {@link NetworkConfiguration} object. */
private NetworkConfiguration networkConfiguration() {
Vdc vdc = context.getApi().getVdcApi().getVdc(vdcURI);
Vdc vdc = context.getApi().getVdcApi().get(vdcUrn);
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
Set<Reference> networks = vdc.getAvailableNetworks();