VCloud Director 1.5: Adding VAppTemplateClient error handling tests and fixing bug in NetworkService.isEnabled

This commit is contained in:
Adam Lowe 2012-03-06 10:40:37 +00:00
parent 200fc85965
commit 14ce89aab2
12 changed files with 366 additions and 66 deletions

View File

@ -174,18 +174,9 @@ public class Catalog extends CatalogType<Catalog> {
} }
} }
<<<<<<< HEAD
public Catalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id, public Catalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id,
String name, Owner owner, CatalogItems catalogItems, Boolean published) { String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published); super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published);
=======
private Catalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id,
String name, Entity owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name);
this.owner = owner;
this.catalogItems = catalogItems;
this.isPublished = published;
>>>>>>> VCloud Director 1.5: Adjusting misleading comments and consistently using @XmlReference only for substitution groups
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")

View File

@ -106,7 +106,6 @@ public class DhcpService extends NetworkServiceType<DhcpService> {
this.isEnabled = enabled; this.isEnabled = enabled;
return this; return this;
} }
} }
@XmlElement(name = "DefaultLeaseTime") @XmlElement(name = "DefaultLeaseTime")

View File

@ -118,6 +118,12 @@ public class FirewallService extends NetworkServiceType<FirewallService> {
.logDefaultAction(in.isLogDefaultAction()) .logDefaultAction(in.isLogDefaultAction())
.firewallRules(in.getFirewallRules()); .firewallRules(in.getFirewallRules());
} }
@Override
public Builder enabled(boolean isEnabled) {
this.isEnabled = isEnabled;
return this;
}
} }
private FirewallService(boolean enabled, String defaultAction, Boolean logDefaultAction, Set<FirewallRule> firewallRules) { private FirewallService(boolean enabled, String defaultAction, Boolean logDefaultAction, Set<FirewallRule> firewallRules) {

View File

@ -118,6 +118,12 @@ public class IpsecVpnService extends NetworkServiceType<IpsecVpnService> {
.publicIpAddress(in.getPublicIpAddress()) .publicIpAddress(in.getPublicIpAddress())
.ipsecVpnTunnels(in.getIpsecVpnTunnels()); .ipsecVpnTunnels(in.getIpsecVpnTunnels());
} }
@Override
public Builder enabled(boolean isEnabled) {
this.isEnabled = isEnabled;
return this;
}
} }
private IpsecVpnService(boolean enabled, String externalIpAddress, String publicIpAddress, List<IpsecVpnTunnel> ipsecVpnTunnel) { private IpsecVpnService(boolean enabled, String externalIpAddress, String publicIpAddress, List<IpsecVpnTunnel> ipsecVpnTunnel) {

View File

@ -56,10 +56,12 @@ import com.google.common.collect.Sets;
*/ */
@XmlRootElement(name = "Owner") @XmlRootElement(name = "Owner")
@XmlType(propOrder = {"user"}) @XmlType(propOrder = {"user"})
public class Owner public class Owner extends ResourceType<Owner> {
extends ResourceType<Owner>
<<<<<<< HEAD
{ {
=======
>>>>>>> VCloud Director 1.5: Adding VAppTemplateClient error handling tests and fixing bug in NetworkService.isEnabled
public static Builder builder() { public static Builder builder() {
return new Builder(); return new Builder();
} }

View File

@ -96,6 +96,12 @@ public class StaticRoutingService extends NetworkServiceType<StaticRoutingServic
return fromNetworkServiceType(in) return fromNetworkServiceType(in)
.staticRoutes(in.getStaticRoutes()); .staticRoutes(in.getStaticRoutes());
} }
@Override
public Builder enabled(boolean isEnabled) {
this.isEnabled = isEnabled;
return this;
}
} }
private StaticRoutingService(boolean enabled, List<StaticRoute> staticRoutes) { private StaticRoutingService(boolean enabled, List<StaticRoute> staticRoutes) {

View File

@ -69,6 +69,7 @@ public interface VAppTemplateAsyncClient {
@Produces(VAPP_TEMPLATE) @Produces(VAPP_TEMPLATE)
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplate(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplate(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) VAppTemplate template); @BinderParam(BindToXMLPayload.class) VAppTemplate template);
@ -78,6 +79,7 @@ public interface VAppTemplateAsyncClient {
@DELETE @DELETE
@Consumes(TASK) @Consumes(TASK)
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteVappTemplate(@EndpointParam URI templateUri); ListenableFuture<Task> deleteVappTemplate(@EndpointParam URI templateUri);
/** /**
@ -87,6 +89,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/action/consolidate") @Path("/action/consolidate")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> consolidateVappTemplate(@EndpointParam URI templateURI); ListenableFuture<Task> consolidateVappTemplate(@EndpointParam URI templateURI);
/** /**
@ -96,6 +99,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/action/disableDownload") @Path("/action/disableDownload")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> disableDownloadVappTemplate(@EndpointParam URI templateURI); ListenableFuture<Task> disableDownloadVappTemplate(@EndpointParam URI templateURI);
/** /**
@ -105,6 +109,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/action/enableDownload") @Path("/action/enableDownload")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> enableDownloadVappTemplate(@EndpointParam URI templateURI); ListenableFuture<Task> enableDownloadVappTemplate(@EndpointParam URI templateURI);
/** /**
@ -115,6 +120,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/action/relocate") @Path("/action/relocate")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> relocateVappTemplate(@EndpointParam URI templateURI, ListenableFuture<Task> relocateVappTemplate(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) RelocateParams params); @BinderParam(BindToXMLPayload.class) RelocateParams params);
@ -125,6 +131,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(CUSTOMIZATION_SECTION) @Consumes(CUSTOMIZATION_SECTION)
@Path("/customizationSection") @Path("/customizationSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<CustomizationSection> getVAppTemplateCustomizationSection(@EndpointParam URI templateURI); ListenableFuture<CustomizationSection> getVAppTemplateCustomizationSection(@EndpointParam URI templateURI);
/** /**
@ -135,6 +142,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/customizationSection") @Path("/customizationSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateCustomizationSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateCustomizationSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) CustomizationSection sectionType); @BinderParam(BindToXMLPayload.class) CustomizationSection sectionType);
@ -145,6 +153,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(GUEST_CUSTOMIZATION_SECTION) @Consumes(GUEST_CUSTOMIZATION_SECTION)
@Path("/guestCustomizationSection") @Path("/guestCustomizationSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<GuestCustomizationSection> getVAppTemplateGuestCustomizationSection(@EndpointParam URI templateURI); ListenableFuture<GuestCustomizationSection> getVAppTemplateGuestCustomizationSection(@EndpointParam URI templateURI);
/** /**
@ -155,6 +164,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/guestCustomizationSection") @Path("/guestCustomizationSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateGuestCustomizationSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateGuestCustomizationSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section);
@ -165,6 +175,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(LEASE_SETTINGS_SECTION) @Consumes(LEASE_SETTINGS_SECTION)
@Path("/leaseSettingsSection") @Path("/leaseSettingsSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<LeaseSettingsSection> getVappTemplateLeaseSettingsSection(@EndpointParam URI templateURI); ListenableFuture<LeaseSettingsSection> getVappTemplateLeaseSettingsSection(@EndpointParam URI templateURI);
/** /**
@ -175,6 +186,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/leaseSettingsSection") @Path("/leaseSettingsSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVappTemplateLeaseSettingsSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVappTemplateLeaseSettingsSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection); @BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection);
@ -185,6 +197,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(METADATA) @Consumes(METADATA)
@Path("/metadata") @Path("/metadata")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getVAppTemplateMetadata(@EndpointParam URI templateURI); ListenableFuture<Metadata> getVAppTemplateMetadata(@EndpointParam URI templateURI);
@PUT @PUT
@ -192,6 +205,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/metadata") @Path("/metadata")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateMetadata(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateMetadata(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) Metadata metadata); @BinderParam(BindToXMLPayload.class) Metadata metadata);
@ -202,6 +216,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(METADATA_ENTRY) @Consumes(METADATA_ENTRY)
@Path("/metadata/{key}") @Path("/metadata/{key}")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataValue> getVAppTemplateMetadataValue(@EndpointParam URI templateURI, ListenableFuture<MetadataValue> getVAppTemplateMetadataValue(@EndpointParam URI templateURI,
@PathParam("key") String key); @PathParam("key") String key);
@ -213,6 +228,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/metadata/{key}") @Path("/metadata/{key}")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateMetadataValue(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateMetadataValue(@EndpointParam URI templateURI,
@PathParam("key") String key, @PathParam("key") String key,
@BinderParam(BindToXMLPayload.class) MetadataValue value); @BinderParam(BindToXMLPayload.class) MetadataValue value);
@ -224,6 +240,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/metadata/{key}") @Path("/metadata/{key}")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> deleteVAppTemplateMetadataValue(@EndpointParam URI templateURI, ListenableFuture<Task> deleteVAppTemplateMetadataValue(@EndpointParam URI templateURI,
@PathParam("key") String key); @PathParam("key") String key);
@ -234,6 +251,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(NETWORK_CONFIG_SECTION) @Consumes(NETWORK_CONFIG_SECTION)
@Path("/networkConfigSection") @Path("/networkConfigSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<NetworkConfigSection> getVAppTemplateNetworkConfigSection(@EndpointParam URI templateURI); ListenableFuture<NetworkConfigSection> getVAppTemplateNetworkConfigSection(@EndpointParam URI templateURI);
/** /**
@ -244,6 +262,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/networkConfigSection") @Path("/networkConfigSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateNetworkConfigSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateNetworkConfigSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) NetworkConfigSection section); @BinderParam(BindToXMLPayload.class) NetworkConfigSection section);
@ -254,6 +273,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(NETWORK_CONNECTION_SECTION) @Consumes(NETWORK_CONNECTION_SECTION)
@Path("/networkConnectionSection") @Path("/networkConnectionSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<NetworkConnectionSection> getVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI); ListenableFuture<NetworkConnectionSection> getVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI);
/** /**
@ -264,6 +284,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/networkConnectionSection") @Path("/networkConnectionSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section);
@ -274,6 +295,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(NETWORK_SECTION) @Consumes(NETWORK_SECTION)
@Path("/networkSection") @Path("/networkSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<NetworkSection> getVAppTemplateNetworkSection(@EndpointParam URI templateURI); ListenableFuture<NetworkSection> getVAppTemplateNetworkSection(@EndpointParam URI templateURI);
/** /**
@ -284,6 +306,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/networkSection") @Path("/networkSection")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editVAppTemplateNetworkSection(@EndpointParam URI templateURI, ListenableFuture<Task> editVAppTemplateNetworkSection(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) NetworkSection section); @BinderParam(BindToXMLPayload.class) NetworkSection section);
@ -294,6 +317,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(ENVELOPE) @Consumes(ENVELOPE)
@Path("/ovf") @Path("/ovf")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Envelope> getVAppTemplateOvf(@EndpointParam URI templateURI); ListenableFuture<Envelope> getVAppTemplateOvf(@EndpointParam URI templateURI);
/** /**
@ -303,6 +327,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(OWNER) @Consumes(OWNER)
@Path("/owner") @Path("/owner")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Owner> getOwnerOfVAppTemplate(@EndpointParam URI templateURI); ListenableFuture<Owner> getOwnerOfVAppTemplate(@EndpointParam URI templateURI);
/** /**
@ -312,6 +337,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(PRODUCT_SECTION_LIST) @Consumes(PRODUCT_SECTION_LIST)
@Path("/productSections") @Path("/productSections")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<ProductSectionList> getProductSectionsForVAppTemplate(@EndpointParam URI templateURI); ListenableFuture<ProductSectionList> getProductSectionsForVAppTemplate(@EndpointParam URI templateURI);
/** /**
@ -322,6 +348,7 @@ public interface VAppTemplateAsyncClient {
@Consumes(TASK) @Consumes(TASK)
@Path("/productSections") @Path("/productSections")
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> editProductSectionsForVAppTemplate(@EndpointParam URI templateURI, ListenableFuture<Task> editProductSectionsForVAppTemplate(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) ProductSectionList sections); @BinderParam(BindToXMLPayload.class) ProductSectionList sections);

View File

@ -38,7 +38,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves a vApp template (can be used also to retrieve a VM from a vApp Template). * Retrieves a vApp template (can be used also to retrieve a VM from a vApp Template).
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the requested template * @return the requested template
*/ */
VAppTemplate getVAppTemplate(URI templateUri); VAppTemplate getVAppTemplate(URI templateUri);
@ -46,8 +46,8 @@ public interface VAppTemplateClient {
/** /**
* Modifies only the name/description of a vApp template. * Modifies only the name/description of a vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param template the template containing the new name and/or description * @param template the template containing the new name and/or description
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplate(URI templateUri, VAppTemplate template); Task editVAppTemplate(URI templateUri, VAppTemplate template);
@ -55,7 +55,7 @@ public interface VAppTemplateClient {
/** /**
* Deletes a vApp template. * Deletes a vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task deleteVappTemplate(URI templateUri); Task deleteVappTemplate(URI templateUri);
@ -63,7 +63,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task consolidateVappTemplate(URI templateUri); Task consolidateVappTemplate(URI templateUri);
@ -71,7 +71,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task disableDownloadVappTemplate(URI templateUri); Task disableDownloadVappTemplate(URI templateUri);
@ -79,7 +79,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM, * Consolidates a VM,
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task enableDownloadVappTemplate(URI templateUri); Task enableDownloadVappTemplate(URI templateUri);
@ -87,7 +87,8 @@ public interface VAppTemplateClient {
/** /**
* Relocates a virtual machine in a vApp template to a different datastore. * * Relocates a virtual machine in a vApp template to a different datastore. *
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param params contains the reference to the new datastore
* @return the task performing the action * @return the task performing the action
*/ */
Task relocateVappTemplate(URI templateUri, RelocateParams params); Task relocateVappTemplate(URI templateUri, RelocateParams params);
@ -95,7 +96,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves the customization section of a vApp template. * Retrieves the customization section of a vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
CustomizationSection getVAppTemplateCustomizationSection(URI templateUri); CustomizationSection getVAppTemplateCustomizationSection(URI templateUri);
@ -103,15 +104,16 @@ public interface VAppTemplateClient {
/** /**
* Modifies the vApp template customization information. * Modifies the vApp template customization information.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateCustomizationSection(URI templateUri, CustomizationSection sectionType); Task editVAppTemplateCustomizationSection(URI templateUri, CustomizationSection section);
/** /**
* Retrieves the Guest Customization Section of a VM * Retrieves the Guest Customization Section of a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
GuestCustomizationSection getVAppTemplateGuestCustomizationSection(URI templateUri); GuestCustomizationSection getVAppTemplateGuestCustomizationSection(URI templateUri);
@ -119,15 +121,16 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateGuestCustomizationSection(URI templateUri, GuestCustomizationSection sectionType); Task editVAppTemplateGuestCustomizationSection(URI templateUri, GuestCustomizationSection section);
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
LeaseSettingsSection getVappTemplateLeaseSettingsSection(URI templateUri); LeaseSettingsSection getVappTemplateLeaseSettingsSection(URI templateUri);
@ -135,15 +138,16 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVappTemplateLeaseSettingsSection(URI templateUri, LeaseSettingsSection settingsSection); Task editVappTemplateLeaseSettingsSection(URI templateUri, LeaseSettingsSection section);
/** /**
* Retrieves the metadata associated with a vApp Template. * Retrieves the metadata associated with a vApp Template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the requested metadata * @return the requested metadata
*/ */
Metadata getVAppTemplateMetadata(URI templateUri); Metadata getVAppTemplateMetadata(URI templateUri);
@ -151,7 +155,7 @@ public interface VAppTemplateClient {
/** /**
* Merges the metadata for a vApp Template with the information provided. * Merges the metadata for a vApp Template with the information provided.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateMetadata(URI templateUri, Metadata metadata); Task editVAppTemplateMetadata(URI templateUri, Metadata metadata);
@ -159,7 +163,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
MetadataValue getVAppTemplateMetadataValue(URI templateUri, String key); MetadataValue getVAppTemplateMetadataValue(URI templateUri, String key);
@ -167,7 +171,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateMetadataValue(URI templateUri, String key, MetadataValue value); Task editVAppTemplateMetadataValue(URI templateUri, String key, MetadataValue value);
@ -175,7 +179,7 @@ public interface VAppTemplateClient {
/** /**
* Consolidates a VM * Consolidates a VM
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task deleteVAppTemplateMetadataValue(URI templateUri, String key); Task deleteVAppTemplateMetadataValue(URI templateUri, String key);
@ -183,7 +187,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves the network config section of a vApp or vApp template. * Retrieves the network config section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network config section requested * @return the network config section requested
*/ */
NetworkConfigSection getVAppTemplateNetworkConfigSection(URI templateUri); NetworkConfigSection getVAppTemplateNetworkConfigSection(URI templateUri);
@ -191,7 +195,8 @@ public interface VAppTemplateClient {
/** /**
* Modifies the network config section of a vApp or vApp template. * Modifies the network config section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateNetworkConfigSection(URI templateUri, NetworkConfigSection section); Task editVAppTemplateNetworkConfigSection(URI templateUri, NetworkConfigSection section);
@ -199,7 +204,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves the network connection section of a vApp or vApp template. * Retrieves the network connection section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network connection section requested * @return the network connection section requested
*/ */
NetworkConnectionSection getVAppTemplateNetworkConnectionSection(URI templateUri); NetworkConnectionSection getVAppTemplateNetworkConnectionSection(URI templateUri);
@ -207,7 +212,8 @@ public interface VAppTemplateClient {
/** /**
* Modifies the network connection section of a vApp or vApp template. * Modifies the network connection section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateNetworkConnectionSection(URI templateUri, NetworkConnectionSection section); Task editVAppTemplateNetworkConnectionSection(URI templateUri, NetworkConnectionSection section);
@ -215,7 +221,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves the network section of a vApp or vApp template. * Retrieves the network section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the network section requested * @return the network section requested
*/ */
NetworkSection getVAppTemplateNetworkSection(URI templateUri); NetworkSection getVAppTemplateNetworkSection(URI templateUri);
@ -223,7 +229,8 @@ public interface VAppTemplateClient {
/** /**
* Modifies the network section of a vApp or vApp template. * Modifies the network section of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @param section the new configuration to apply
* @return the task performing the action * @return the task performing the action
*/ */
Task editVAppTemplateNetworkSection(URI templateUri, NetworkSection section); Task editVAppTemplateNetworkSection(URI templateUri, NetworkSection section);
@ -231,7 +238,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves an OVF descriptor of a vApp template. * Retrieves an OVF descriptor of a vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Envelope getVAppTemplateOvf(URI templateUri); Envelope getVAppTemplateOvf(URI templateUri);
@ -239,7 +246,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves vApp template owner. * Retrieves vApp template owner.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the owner of the vApp template * @return the owner of the vApp template
*/ */
Owner getOwnerOfVAppTemplate(URI templateUri); Owner getOwnerOfVAppTemplate(URI templateUri);
@ -247,7 +254,7 @@ public interface VAppTemplateClient {
/** /**
* Retrieves VAppTemplate/VM product sections * Retrieves VAppTemplate/VM product sections
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the product sections * @return the product sections
*/ */
ProductSectionList getProductSectionsForVAppTemplate(URI templateUri); ProductSectionList getProductSectionsForVAppTemplate(URI templateUri);
@ -255,7 +262,7 @@ public interface VAppTemplateClient {
/** /**
* Modifies the product sections of a vApp or vApp template. * Modifies the product sections of a vApp or vApp template.
* *
* @@param templateUri the URI of the template * @param templateUri the URI of the template
* @return the task performing the action * @return the task performing the action
*/ */
Task editProductSectionsForVAppTemplate(URI templateUri, ProductSectionList sections); Task editProductSectionsForVAppTemplate(URI templateUri, ProductSectionList sections);

View File

@ -39,7 +39,8 @@ import com.google.common.collect.Iterables;
@Singleton @Singleton
public class ThrowVCloudErrorOn4xx implements Function<Exception, Object> { public class ThrowVCloudErrorOn4xx implements Function<Exception, Object> {
@Inject @Inject
private ThrowVCloudErrorOn4xx() { } private ThrowVCloudErrorOn4xx() {
}
@Override @Override
public Object apply(Exception from) { public Object apply(Exception from) {

View File

@ -27,6 +27,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.*; import org.jclouds.vcloud.director.v1_5.domain.*;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -42,7 +43,7 @@ import com.google.common.collect.ImmutableSet;
public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
public void testVAppTemplate() { public void testVAppTemplate() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -59,15 +60,51 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(template, exampleTemplate()); assertEquals(template, exampleTemplate());
Task task = client.editVAppTemplate(uri, template); Task task = client.editVAppTemplate(uri, exampleTemplate());
assertNotNull(task); assertNotNull(task);
task = client.deleteVappTemplate(uri); task = client.deleteVappTemplate(uri);
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId).acceptMedia(VAPP_TEMPLATE).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getVAppTemplate(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId).xmlFilePayload("/vapptemplate/vAppTemplate.xml", VAPP_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.editVAppTemplate(uri, exampleTemplate());
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testDeleteMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.deleteVappTemplate(uri);
}
public void testConsolidateVAppTemplate() { public void testConsolidateVAppTemplate() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -80,8 +117,20 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testConsolidateMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/consolidate").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.consolidateVappTemplate(uri);
}
public void testDisableDownloadVAppTemplate() { public void testDisableDownloadVAppTemplate() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -94,8 +143,20 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testDisableDownloadMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/disableDownload").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.disableDownloadVappTemplate(uri);
}
public void testEnableDownloadVAppTemplate() { public void testEnableDownloadVAppTemplate() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -108,12 +169,24 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testEnableDownloadMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/enableDownload").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.enableDownloadVappTemplate(uri);
}
public void testRelocateVAppTemplate() { public void testRelocateVAppTemplate() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/enableDownload").xmlFilePayload("/vappTemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vappTemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build() new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateClient(); ).getVAppTemplateClient();
@ -126,8 +199,23 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testRelocateMissingVAppTemplate() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vappTemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
Reference datastore = Reference.builder().href(URI.create("https://vcloud.example.com/api/admin/extension/datastore/607")).build();
RelocateParams params = RelocateParams.builder().datastore(datastore).build();
client.relocateVappTemplate(uri, params);
}
public void testCustomizationSection() { public void testCustomizationSection() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -142,12 +230,36 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(section, exampleCustomizationSection()); assertEquals(section, exampleCustomizationSection());
Task task = client.editVAppTemplateCustomizationSection(uri, section); Task task = client.editVAppTemplateCustomizationSection(uri, exampleCustomizationSection());
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/customizationSection").acceptMedia(CUSTOMIZATION_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.getVAppTemplateCustomizationSection(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/customizationSection").xmlFilePayload("/vapptemplate/customizationSection.xml", CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.editVAppTemplateCustomizationSection(uri, exampleCustomizationSection());
}
public void testGuestCustomizationSection() { public void testGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -162,12 +274,36 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(section, exampleGuestCustomizationSection()); assertEquals(section, exampleGuestCustomizationSection());
Task task = client.editVAppTemplateGuestCustomizationSection(uri, section); Task task = client.editVAppTemplateGuestCustomizationSection(uri, exampleGuestCustomizationSection());
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/guestCustomizationSection").acceptMedia(GUEST_CUSTOMIZATION_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getVAppTemplateGuestCustomizationSection(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditGuestCustomizationSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/guestCustomizationSection").xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateGuestCustomizationSection(uri, exampleGuestCustomizationSection());
}
public void testLeaseSettingsSection() throws ParseException { public void testLeaseSettingsSection() throws ParseException {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -182,12 +318,36 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(section, exampleLeaseSettingsSection()); assertEquals(section, exampleLeaseSettingsSection());
Task task = client.editVappTemplateLeaseSettingsSection(uri, section); Task task = client.editVappTemplateLeaseSettingsSection(uri, exampleLeaseSettingsSection());
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetLeaseSettingsSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/leaseSettingsSection").acceptMedia(LEASE_SETTINGS_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.getVappTemplateLeaseSettingsSection(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditLeaseSettingsSection() throws ParseException {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/leaseSettingsSection").xmlFilePayload("/vapptemplate/leaseSettingsSection.xml", LEASE_SETTINGS_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.editVappTemplateLeaseSettingsSection(uri, exampleLeaseSettingsSection());
}
public void testVappTemplateMetadata() { public void testVappTemplateMetadata() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -202,12 +362,36 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(metadata, exampleMetadata()); assertEquals(metadata, exampleMetadata());
Task task = client.editVAppTemplateMetadata(uri, metadata); Task task = client.editVAppTemplateMetadata(uri, exampleMetadata());
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetMetadata() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(METADATA).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getVAppTemplateMetadata(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditMetadata() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateMetadata(uri, exampleMetadata());
}
public void testVappTemplateMetadataValue() { public void testVappTemplateMetadataValue() {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -224,15 +408,51 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(metadata, exampleMetadataValue()); assertEquals(metadata, exampleMetadataValue());
Task task = client.editVAppTemplateMetadataValue(uri, "12345", metadata); Task task = client.editVAppTemplateMetadataValue(uri, "12345", exampleMetadataValue());
assertNotNull(task); assertNotNull(task);
task = client.deleteVAppTemplateMetadataValue(uri, "12345"); task = client.deleteVAppTemplateMetadataValue(uri, "12345");
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetMetadataValue() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata/12345").acceptMedia(METADATA_ENTRY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.getVAppTemplateMetadataValue(uri, "12345");
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditMetadataValue() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata/12345").xmlFilePayload("/vapptemplate/metadataValue.xml", METADATA_ENTRY).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateMetadataValue(uri, "12345", exampleMetadataValue());
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testDeleteMissingMetadataValue() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId + "/metadata/12345").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.deleteVAppTemplateMetadataValue(uri, "12345");
}
public void testNetworkConfigSection() throws ParseException { public void testNetworkConfigSection() throws ParseException {
final String templateId = "/vAppTemplate/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId); URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse, VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
@ -248,17 +468,41 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
assertEquals(section, exampleNetworkConfigSection()); assertEquals(section, exampleNetworkConfigSection());
Task task = client.editVAppTemplateNetworkConfigSection(uri, section); Task task = client.editVAppTemplateNetworkConfigSection(uri, exampleNetworkConfigSection());
assertNotNull(task); assertNotNull(task);
} }
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorGetNetworkConfigSection() {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/networkConfigSection").acceptMedia(NETWORK_CONFIG_SECTION).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getVAppTemplateNetworkConfigSection(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
public void testErrorEditNetworkConfigSection() throws ParseException {
final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9";
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/networkConfigSection").xmlFilePayload("/vapptemplate/networkConfigSection.xml", NETWORK_CONFIG_SECTION).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateNetworkConfigSection(uri, exampleNetworkConfigSection());
}
private VAppTemplate exampleTemplate() { private VAppTemplate exampleTemplate() {
Link aLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07")) Link aLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vdc/d16d333b-e3c0-4176-845d-a5ee6392df07"))
.type("application/vnd.vmware.vcloud.vdc+xml").rel("up").build(); .type("application/vnd.vmware.vcloud.vdc+xml").rel("up").build();
Link bLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9")) Link bLink = Link.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"))
.rel("remove").build(); .rel("remove").build();
Owner owner = Owner.builder().user(Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69")).name("x@jclouds.org").type("application/vnd.vmware.admin.user+xml").build()).build(); Owner owner = Owner.builder().type("application/vnd.vmware.vcloud.owner+xml").user(Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/967d317c-4273-4a95-b8a4-bf63b78e9c69")).name("x@jclouds.org").type("application/vnd.vmware.admin.user+xml").build()).build();
LeaseSettingsSection leaseSettings = LeaseSettingsSection.builder().type("application/vnd.vmware.vcloud.leaseSettingsSection+xml") LeaseSettingsSection leaseSettings = LeaseSettingsSection.builder().type("application/vnd.vmware.vcloud.leaseSettingsSection+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9/leaseSettingsSection/")) .href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9/leaseSettingsSection/"))
@ -359,7 +603,9 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
private NetworkConfigSection exampleNetworkConfigSection() throws ParseException { private NetworkConfigSection exampleNetworkConfigSection() throws ParseException {
FirewallService firewallService = FirewallService firewallService =
FirewallService.builder().firewallRules( FirewallService.builder()
.enabled(true)
.firewallRules(
ImmutableSet.of( ImmutableSet.of(
FirewallRule.builder() FirewallRule.builder()
.isEnabled(true) .isEnabled(true)

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST"
message="validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.vm,com.vmware.vcloud.entity.vapp,com.vmware.vcloud.entity.vapptemplate,com.vmware.vcloud.entity.media."
majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="ACCESS_TO_RESOURCE_IS_FORBIDDEN"
message="Access is forbidden" majorErrorCode="403" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd"></Error>