diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java index 356274f307..0e5cb99fda 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java @@ -42,60 +42,59 @@ import org.jclouds.rest.annotations.Delegate; * @author Ignasi Barrera */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface AbiquoApi -{ - /** - * Provides synchronous access to Admin features. - */ - @Delegate - AdminApi getAdminApi(); +public interface AbiquoApi { + /** + * Provides synchronous access to Admin features. + */ + @Delegate + AdminApi getAdminApi(); - /** - * Provides synchronous access to Infrastructure features. - */ - @Delegate - InfrastructureApi getInfrastructureApi(); + /** + * Provides synchronous access to Infrastructure features. + */ + @Delegate + InfrastructureApi getInfrastructureApi(); - /** - * Provides synchronous access to Cloud features. - */ - @Delegate - CloudApi getCloudApi(); + /** + * Provides synchronous access to Cloud features. + */ + @Delegate + CloudApi getCloudApi(); - /** - * Provides synchronous access to Apps library features. - */ - @Delegate - VirtualMachineTemplateApi getVirtualMachineTemplateApi(); + /** + * Provides synchronous access to Apps library features. + */ + @Delegate + VirtualMachineTemplateApi getVirtualMachineTemplateApi(); - /** - * Provides synchronous access to Enterprise features. - */ - @Delegate - EnterpriseApi getEnterpriseApi(); + /** + * Provides synchronous access to Enterprise features. + */ + @Delegate + EnterpriseApi getEnterpriseApi(); - /** - * Provides synchronous access to configuration features. - */ - @Delegate - ConfigApi getConfigApi(); + /** + * Provides synchronous access to configuration features. + */ + @Delegate + ConfigApi getConfigApi(); - /** - * Provides synchronous access to task asynchronous features. - */ - @Delegate - TaskApi getTaskApi(); + /** + * Provides synchronous access to task asynchronous features. + */ + @Delegate + TaskApi getTaskApi(); - /** - * Provides synchronous access to Event features. - */ - @Delegate - EventApi getEventApi(); + /** + * Provides synchronous access to Event features. + */ + @Delegate + EventApi getEventApi(); - /** - * Provides synchronous access to Pricing features. - */ - @Delegate - PricingApi getPricingApi(); + /** + * Provides synchronous access to Pricing features. + */ + @Delegate + PricingApi getPricingApi(); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java index 78fd985237..d3d5c78b61 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java @@ -43,82 +43,70 @@ import com.google.inject.Module; * * @author Ignasi Barrera */ -public class AbiquoApiMetadata extends BaseRestApiMetadata -{ - /** Serial UID. */ - private static final long serialVersionUID = -8355533493674898171L; +public class AbiquoApiMetadata extends BaseRestApiMetadata { + /** Serial UID. */ + private static final long serialVersionUID = -8355533493674898171L; - /** The token describing the rest api context. */ - public static final TypeToken> CONTEXT_TOKEN = - new TypeToken>() - { - private static final long serialVersionUID = -5070937833892503232L; - }; + /** The token describing the rest api context. */ + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; - public AbiquoApiMetadata() - { - this(new Builder()); - } + public AbiquoApiMetadata() { + this(new Builder()); + } - protected AbiquoApiMetadata(final Builder builder) - { - super(builder); - } + protected AbiquoApiMetadata(final Builder builder) { + super(builder); + } - public static Properties defaultProperties() - { - Properties properties = BaseRestApiMetadata.defaultProperties(); - // By default redirects will be handled in the domain objects - properties.setProperty(PROPERTY_MAX_REDIRECTS, "0"); - // The default polling delay between AsyncTask monitor requests - properties.setProperty(ASYNC_TASK_MONITOR_DELAY, "5000"); - // By default the provided credential is not a token - properties.setProperty(CREDENTIAL_IS_TOKEN, "false"); - return properties; - } + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); + // By default redirects will be handled in the domain objects + properties.setProperty(PROPERTY_MAX_REDIRECTS, "0"); + // The default polling delay between AsyncTask monitor requests + properties.setProperty(ASYNC_TASK_MONITOR_DELAY, "5000"); + // By default the provided credential is not a token + properties.setProperty(CREDENTIAL_IS_TOKEN, "false"); + return properties; + } - @Override - public Builder toBuilder() - { - return new Builder().fromApiMetadata(this); - } + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } - public static class Builder extends BaseRestApiMetadata.Builder - { - private static final String DOCUMENTATION_ROOT = "http://community.abiquo.com/display/ABI" + public static class Builder extends BaseRestApiMetadata.Builder { + private static final String DOCUMENTATION_ROOT = "http://community.abiquo.com/display/ABI" + CharMatcher.DIGIT.retainFrom(AbiquoAsyncApi.API_VERSION); - protected Builder() - { - super(AbiquoApi.class, AbiquoAsyncApi.class); - id("abiquo") - .name("Abiquo API") - .identityName("API Username") - .credentialName("API Password") - .documentation(URI.create(DOCUMENTATION_ROOT + "/API+Reference")) - .defaultEndpoint("http://localhost/api") - .version(AbiquoAsyncApi.API_VERSION) - .buildVersion(AbiquoAsyncApi.BUILD_VERSION) - .view(TypeToken.of(AbiquoContext.class)) - .defaultProperties(AbiquoApiMetadata.defaultProperties()) - .defaultModules( - ImmutableSet.> of(AbiquoRestClientModule.class, - AbiquoComputeServiceContextModule.class, - ScheduledExecutorServiceModule.class)); - } + protected Builder() { + super(AbiquoApi.class, AbiquoAsyncApi.class); + id("abiquo") + .name("Abiquo API") + .identityName("API Username") + .credentialName("API Password") + .documentation(URI.create(DOCUMENTATION_ROOT + "/API+Reference")) + .defaultEndpoint("http://localhost/api") + .version(AbiquoAsyncApi.API_VERSION) + .buildVersion(AbiquoAsyncApi.BUILD_VERSION) + .view(TypeToken.of(AbiquoContext.class)) + .defaultProperties(AbiquoApiMetadata.defaultProperties()) + .defaultModules( + ImmutableSet.> of(AbiquoRestClientModule.class, + AbiquoComputeServiceContextModule.class, ScheduledExecutorServiceModule.class)); + } - @Override - public AbiquoApiMetadata build() - { - return new AbiquoApiMetadata(this); - } + @Override + public AbiquoApiMetadata build() { + return new AbiquoApiMetadata(this); + } - @Override - public Builder fromApiMetadata(final ApiMetadata in) - { - super.fromApiMetadata(in); - return this; - } - } + @Override + public Builder fromApiMetadata(final ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoAsyncApi.java index c46e7a0db9..166e3fdfd9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoAsyncApi.java @@ -40,69 +40,68 @@ import com.abiquo.model.transport.SingleResourceTransportDto; * @see InfrastructureAsyncApi * @author Ignasi Barrera */ -public interface AbiquoAsyncApi -{ - /** - * The version of the supported Abiquo API. - */ - public static final String API_VERSION = SingleResourceTransportDto.API_VERSION; +public interface AbiquoAsyncApi { + /** + * The version of the supported Abiquo API. + */ + public static final String API_VERSION = SingleResourceTransportDto.API_VERSION; - /** - * The supported build version of the Abiquo Api. - */ - public static final String BUILD_VERSION = "7bbfe95-158721b"; + /** + * The supported build version of the Abiquo Api. + */ + public static final String BUILD_VERSION = "7bbfe95-158721b"; - /** - * Provides asynchronous access to Admin features. - */ - @Delegate - AdminAsyncApi getAdminApi(); + /** + * Provides asynchronous access to Admin features. + */ + @Delegate + AdminAsyncApi getAdminApi(); - /** - * Provides asynchronous access to Infrastructure features. - */ - @Delegate - InfrastructureAsyncApi getInfrastructureApi(); + /** + * Provides asynchronous access to Infrastructure features. + */ + @Delegate + InfrastructureAsyncApi getInfrastructureApi(); - /** - * Provides asynchronous access to Cloud features. - */ - @Delegate - CloudAsyncApi getCloudApi(); + /** + * Provides asynchronous access to Cloud features. + */ + @Delegate + CloudAsyncApi getCloudApi(); - /** - * Provides asynchronous access to Apps library features. - */ - @Delegate - VirtualMachineTemplateAsyncApi getVirtualMachineTemplateApi(); + /** + * Provides asynchronous access to Apps library features. + */ + @Delegate + VirtualMachineTemplateAsyncApi getVirtualMachineTemplateApi(); - /** - * Provides asynchronous access to Enterprise features. - */ - @Delegate - EnterpriseAsyncApi getEnterpriseApi(); + /** + * Provides asynchronous access to Enterprise features. + */ + @Delegate + EnterpriseAsyncApi getEnterpriseApi(); - /** - * Provides asynchronous access to configuration features. - */ - @Delegate - ConfigAsyncApi getConfigApi(); + /** + * Provides asynchronous access to configuration features. + */ + @Delegate + ConfigAsyncApi getConfigApi(); - /** - * Provides asynchronous access to task asynchronous features. - */ - @Delegate - TaskAsyncApi getTaskApi(); + /** + * Provides asynchronous access to task asynchronous features. + */ + @Delegate + TaskAsyncApi getTaskApi(); - /** - * Provides asynchronous access to Event features. - */ - @Delegate - EventAsyncApi getEventApi(); + /** + * Provides asynchronous access to Event features. + */ + @Delegate + EventAsyncApi getEventApi(); - /** - * Provides asynchronous access to Pricing features. - */ - @Delegate - PricingAsyncApi getPricingApi(); + /** + * Provides asynchronous access to Pricing features. + */ + @Delegate + PricingAsyncApi getPricingApi(); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java index a390a7808a..7989a90ef2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java @@ -32,59 +32,62 @@ import org.jclouds.rest.RestContext; import com.google.inject.ImplementedBy; /** - * Abiquo {@link ComputeServiceContext} implementation to expose high level Abiquo functionalities. + * Abiquo {@link ComputeServiceContext} implementation to expose high level + * Abiquo functionalities. * * @author Ignasi Barrera */ @ImplementedBy(AbiquoContextImpl.class) -public interface AbiquoContext extends ComputeServiceContext -{ - /** - * Returns the Abiquo API context, providing direct access to the Abiquo Rest API. - * - * @return The Abiquo API context. - */ - RestContext getApiContext(); +public interface AbiquoContext extends ComputeServiceContext { + /** + * Returns the Abiquo API context, providing direct access to the Abiquo Rest + * API. + * + * @return The Abiquo API context. + */ + RestContext getApiContext(); - /** - * Returns the administration service. - *

- * This service provides an entry point to infrastructure administration tasks. - */ - AdministrationService getAdministrationService(); + /** + * Returns the administration service. + *

+ * This service provides an entry point to infrastructure administration + * tasks. + */ + AdministrationService getAdministrationService(); - /** - * Returns the cloud service. - *

- * This service provides an entry point to cloud management tasks. - */ - CloudService getCloudService(); + /** + * Returns the cloud service. + *

+ * This service provides an entry point to cloud management tasks. + */ + CloudService getCloudService(); - /** - * Returns the search service. - *

- * This service provides an entry point to listing and filtering tasks. - */ - SearchService getSearchService(); + /** + * Returns the search service. + *

+ * This service provides an entry point to listing and filtering tasks. + */ + SearchService getSearchService(); - /** - * Returns the monitoring service. - *

- * This service provides an entry point to asynchronous task monitoring tasks. - */ - MonitoringService getMonitoringService(); + /** + * Returns the monitoring service. + *

+ * This service provides an entry point to asynchronous task monitoring + * tasks. + */ + MonitoringService getMonitoringService(); - /** - * Returns the event service. - *

- * This service provides an entry point to event management tasks. - */ - EventService getEventService(); + /** + * Returns the event service. + *

+ * This service provides an entry point to event management tasks. + */ + EventService getEventService(); - /** - * Returns the pricing service. - *

- * This service provides an entry point to pricing management tasks. - */ - PricingService getPricingService(); + /** + * Returns the pricing service. + *

+ * This service provides an entry point to pricing management tasks. + */ + PricingService getPricingService(); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java index 06ea947390..ff05887e99 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java @@ -34,23 +34,20 @@ import org.jclouds.rest.Binder; * @author Ignasi Barrera */ @Singleton -public class AppendToPath implements Binder -{ - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(final R request, final Object input) - { - // Append the parameter to the request URI - String valueToAppend = getValue(request, checkNotNull(input, "input")); - URI path = URI.create(request.getEndpoint().toString() + "/" + valueToAppend); - return (R) request.toBuilder().endpoint(path).build(); - } +public class AppendToPath implements Binder { + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(final R request, final Object input) { + // Append the parameter to the request URI + String valueToAppend = getValue(request, checkNotNull(input, "input")); + URI path = URI.create(request.getEndpoint().toString() + "/" + valueToAppend); + return (R) request.toBuilder().endpoint(path).build(); + } - /** - * Get the value that will be appended to the request URI. - */ - protected String getValue(final R request, final Object input) - { - return input.toString(); - } + /** + * Get the value that will be appended to the request URI. + */ + protected String getValue(final R request, final Object input) { + return input.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java index f432d58e68..e7bd255a05 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java @@ -34,16 +34,13 @@ import com.abiquo.model.rest.RESTLink; * @author Francesc Montserrat */ @Singleton -public class BindLinkToPath extends BindToPath -{ +public class BindLinkToPath extends BindToPath { - @Override - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof RESTLink, - "this binder is only valid for RESTLink objects"); + @Override + protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof RESTLink, "this binder is only valid for RESTLink objects"); - return ((RESTLink) input).getHref(); - } + return ((RESTLink) input).getHref(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java index 6479403759..e8ae015693 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java @@ -35,20 +35,16 @@ import com.google.common.annotations.VisibleForTesting; * @author Ignasi Barrera */ @Singleton -public class BindLinkToPathAndAcceptHeader extends BindLinkToPath -{ - @Override - public R bindToRequest(final R request, final Object input) - { - R updatedRequest = super.bindToRequest(request, input); - return addHeader(updatedRequest, HttpHeaders.ACCEPT, ((RESTLink) input).getType()); - } +public class BindLinkToPathAndAcceptHeader extends BindLinkToPath { + @Override + public R bindToRequest(final R request, final Object input) { + R updatedRequest = super.bindToRequest(request, input); + return addHeader(updatedRequest, HttpHeaders.ACCEPT, ((RESTLink) input).getType()); + } - @SuppressWarnings("unchecked") - @VisibleForTesting - R addHeader(final R request, final String header, final String value) - { - return (R) request.toBuilder() - .replaceHeader(HttpHeaders.ACCEPT, checkNotNull(value, "value")).build(); - } + @SuppressWarnings("unchecked") + @VisibleForTesting + R addHeader(final R request, final String header, final String value) { + return (R) request.toBuilder().replaceHeader(HttpHeaders.ACCEPT, checkNotNull(value, "value")).build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java index 6a782e7e8e..3dc129fcfc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java @@ -37,37 +37,32 @@ import com.abiquo.model.transport.SingleResourceTransportDto; * * @author Ignasi Barrera */ -public abstract class BindRefsToPayload extends BindToXMLPayload -{ - @Inject - public BindRefsToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public abstract class BindRefsToPayload extends BindToXMLPayload { + @Inject + public BindRefsToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - protected abstract String getRelToUse(final Object input); + protected abstract String getRelToUse(final Object input); - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto[], + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto[], "this binder is only valid for SingleResourceTransportDto arrays"); - SingleResourceTransportDto[] dtos = (SingleResourceTransportDto[]) input; - LinksDto refs = new LinksDto(); + SingleResourceTransportDto[] dtos = (SingleResourceTransportDto[]) input; + LinksDto refs = new LinksDto(); - for (SingleResourceTransportDto dto : dtos) - { - RESTLink editLink = checkNotNull(dto.getEditLink(), "entity must have an edit link"); + for (SingleResourceTransportDto dto : dtos) { + RESTLink editLink = checkNotNull(dto.getEditLink(), "entity must have an edit link"); - // Do not add repeated references - if (refs.searchLinkByHref(editLink.getHref()) == null) - { - refs.addLink(new RESTLink(getRelToUse(input), editLink.getHref())); - } - } + // Do not add repeated references + if (refs.searchLinkByHref(editLink.getHref()) == null) { + refs.addLink(new RESTLink(getRelToUse(input), editLink.getHref())); + } + } - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java index 2b2732930f..a8da04c4f0 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java @@ -46,114 +46,101 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class BindToPath implements Binder -{ - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, +public class BindToPath implements Binder { + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getArgs() != null, "args should be initialized at this point"); + GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; + checkState(gRequest.getArgs() != null, "args should be initialized at this point"); - // Update the request URI with the configured link URI - String newEndpoint = getNewEndpoint(gRequest, input); - return bindToPath(request, newEndpoint); - } + // Update the request URI with the configured link URI + String newEndpoint = getNewEndpoint(gRequest, input); + return bindToPath(request, newEndpoint); + } - /** - * Get the new endpoint to use. - * - * @param gRequest The request. - * @param input The input parameter. - * @return The new endpoint to use. - */ - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) - { - SingleResourceTransportDto dto = checkValidInput(input); - return getLinkToUse(gRequest, dto).getHref(); - } + /** + * Get the new endpoint to use. + * + * @param gRequest + * The request. + * @param input + * The input parameter. + * @return The new endpoint to use. + */ + protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { + SingleResourceTransportDto dto = checkValidInput(input); + return getLinkToUse(gRequest, dto).getHref(); + } - /** - * Get the link to be used to build the request URI. - * - * @param request The current request. - * @param payload The object containing the link. - * @return The link to be used to build the request URI. - */ - static RESTLink getLinkToUse(final GeneratedHttpRequest request, - final SingleResourceTransportDto payload) - { - int argIndex = request.getArgs().indexOf(payload); - Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[argIndex]; + /** + * Get the link to be used to build the request URI. + * + * @param request + * The current request. + * @param payload + * The object containing the link. + * @return The link to be used to build the request URI. + */ + static RESTLink getLinkToUse(final GeneratedHttpRequest request, final SingleResourceTransportDto payload) { + int argIndex = request.getArgs().indexOf(payload); + Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[argIndex]; - EndpointLink linkName = - (EndpointLink) Iterables.find(Arrays.asList(annotations), - Predicates.instanceOf(EndpointLink.class), null); + EndpointLink linkName = (EndpointLink) Iterables.find(Arrays.asList(annotations), + Predicates.instanceOf(EndpointLink.class), null); - if (linkName == null) - { - throw new BindException(request, - "Expected a EndpointLink annotation but not found in the parameter"); - } + if (linkName == null) { + throw new BindException(request, "Expected a EndpointLink annotation but not found in the parameter"); + } - return checkNotNull(payload.searchLink(linkName.value()), - "No link was found in object with rel: " + linkName); - } + return checkNotNull(payload.searchLink(linkName.value()), "No link was found in object with rel: " + linkName); + } - /** - * Bind the given link to the request URI. - * - * @param request The request to modify. - * @param endpoint The endpoint to use as the request URI. - * @return The updated request. - */ - @SuppressWarnings("unchecked") - static R bindToPath(final R request, final String endpoint) - { - // Preserve current query and matrix parameters - String newEndpoint = endpoint + getParameterString(request); + /** + * Bind the given link to the request URI. + * + * @param request + * The request to modify. + * @param endpoint + * The endpoint to use as the request URI. + * @return The updated request. + */ + @SuppressWarnings("unchecked") + static R bindToPath(final R request, final String endpoint) { + // Preserve current query and matrix parameters + String newEndpoint = endpoint + getParameterString(request); - // Replace the URI with the edit link in the DTO - URI path = URI.create(newEndpoint); - return (R) request.toBuilder().endpoint(path).build(); - } + // Replace the URI with the edit link in the DTO + URI path = URI.create(newEndpoint); + return (R) request.toBuilder().endpoint(path).build(); + } - protected static SingleResourceTransportDto checkValidInput(final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto, + protected static SingleResourceTransportDto checkValidInput(final Object input) { + checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto, "this binder is only valid for SingleResourceTransportDto objects"); - return (SingleResourceTransportDto) input; - } + return (SingleResourceTransportDto) input; + } - protected static String getParameterString(final R request) - { - String endpoint = request.getEndpoint().toString(); + protected static String getParameterString(final R request) { + String endpoint = request.getEndpoint().toString(); - int query = endpoint.indexOf('?'); - int matrix = endpoint.indexOf(';'); + int query = endpoint.indexOf('?'); + int matrix = endpoint.indexOf(';'); - if (query == -1 && matrix == -1) - { - // No parameters - return ""; - } - else if (query != -1 && matrix != -1) - { - // Both parameter types - return endpoint.substring(query < matrix ? query : matrix); - } - else if (query != -1) - { - // Only request parameters - return endpoint.substring(query); - } - else - { - // Only matrix parameters - return endpoint.substring(matrix); - } + if (query == -1 && matrix == -1) { + // No parameters + return ""; + } else if (query != -1 && matrix != -1) { + // Both parameter types + return endpoint.substring(query < matrix ? query : matrix); + } else if (query != -1) { + // Only request parameters + return endpoint.substring(query); + } else { + // Only matrix parameters + return endpoint.substring(matrix); + } - } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java index 8e133d93f3..074fa311e7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java @@ -35,48 +35,47 @@ import org.jclouds.xml.XMLParser; import com.abiquo.model.transport.SingleResourceTransportDto; /** - * Binds teh given object to the payload and extracts the path parameters from the edit link. + * Binds teh given object to the payload and extracts the path parameters from + * the edit link. *

- * This method should be used in {@link PUT} methods to automatically extract the path parameters - * from the edit link of the updated object. + * This method should be used in {@link PUT} methods to automatically extract + * the path parameters from the edit link of the updated object. * * @author Ignasi Barrera */ @Singleton -public class BindToXMLPayloadAndPath extends BindToXMLPayload -{ - @Inject - public BindToXMLPayloadAndPath(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindToXMLPayloadAndPath extends BindToXMLPayload { + @Inject + public BindToXMLPayloadAndPath(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object payload) - { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + @Override + public R bindToRequest(final R request, final Object payload) { + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getArgs() != null, "args should be initialized at this point"); + GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; + checkState(gRequest.getArgs() != null, "args should be initialized at this point"); - // Update the request URI with the configured link URI - String newEndpoint = getNewEndpoint(gRequest, payload); - R updatedRequest = BindToPath.bindToPath(request, newEndpoint); + // Update the request URI with the configured link URI + String newEndpoint = getNewEndpoint(gRequest, payload); + R updatedRequest = BindToPath.bindToPath(request, newEndpoint); - // Add the payload - return super.bindToRequest(updatedRequest, payload); - } + // Add the payload + return super.bindToRequest(updatedRequest, payload); + } - /** - * Get the new endpoint to use. - * - * @param gRequest The request. - * @param input The input parameter. - * @return The new endpoint to use. - */ - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) - { - SingleResourceTransportDto dto = BindToPath.checkValidInput(input); - return BindToPath.getLinkToUse(gRequest, dto).getHref(); - } + /** + * Get the new endpoint to use. + * + * @param gRequest + * The request. + * @param input + * The input parameter. + * @return The new endpoint to use. + */ + protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { + SingleResourceTransportDto dto = BindToPath.checkValidInput(input); + return BindToPath.getLinkToUse(gRequest, dto).getHref(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java index f8595ec870..dbcf72f6e3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java @@ -28,23 +28,21 @@ import org.jclouds.xml.XMLParser; import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; /** - * Bind multiple {@link DiskManagementDto} objects to the payload of the request as a list of links. + * Bind multiple {@link DiskManagementDto} objects to the payload of the request + * as a list of links. * * @author Ignasi Barrera */ @Singleton -public class BindHardDiskRefsToPayload extends BindRefsToPayload -{ - @Inject - public BindHardDiskRefsToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindHardDiskRefsToPayload extends BindRefsToPayload { + @Inject + public BindHardDiskRefsToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - protected String getRelToUse(final Object input) - { - return "disk"; - } + @Override + protected String getRelToUse(final Object input) { + return "disk"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java index 1ac67b6431..e9a1ec4377 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java @@ -39,27 +39,23 @@ import com.abiquo.server.core.infrastructure.network.AbstractIpDto; * @author Ignasi Barrera */ @Singleton -public class BindIpRefToPayload extends BindToXMLPayload -{ - @Inject - public BindIpRefToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindIpRefToPayload extends BindToXMLPayload { + @Inject + public BindIpRefToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto, + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto, "this binder is only valid for AbstractIpDto objects"); - AbstractIpDto ip = (AbstractIpDto) input; - RESTLink selfLink = - checkNotNull(ip.searchLink("self"), "AbstractIpDto must have an self link"); + AbstractIpDto ip = (AbstractIpDto) input; + RESTLink selfLink = checkNotNull(ip.searchLink("self"), "AbstractIpDto must have an self link"); - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink(selfLink.getTitle(), selfLink.getHref())); + LinksDto refs = new LinksDto(); + refs.addLink(new RESTLink(selfLink.getTitle(), selfLink.getHref())); - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java index 8ee5b58721..71596fe3c7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java @@ -40,36 +40,29 @@ import com.abiquo.server.core.infrastructure.network.AbstractIpDto; * @author Ignasi Barrera */ @Singleton -public class BindIpRefsToPayload extends BindToXMLPayload -{ - @Inject - public BindIpRefsToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindIpRefsToPayload extends BindToXMLPayload { + @Inject + public BindIpRefsToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto[], + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto[], "this binder is only valid for AbstractIpDto arrays"); - AbstractIpDto[] ips = (AbstractIpDto[]) input; - LinksDto refs = new LinksDto(); + AbstractIpDto[] ips = (AbstractIpDto[]) input; + LinksDto refs = new LinksDto(); - for (AbstractIpDto ip : ips) - { - RESTLink selfLink = - checkNotNull(LinkUtils.getSelfLink(ip), - "AbstractIpDto must have an edit or self link"); - if (refs.searchLinkByHref(selfLink.getHref()) == null) - { - RESTLink ref = new RESTLink(selfLink.getTitle(), selfLink.getHref()); - ref.setType(selfLink.getType()); - refs.addLink(ref); - } - } + for (AbstractIpDto ip : ips) { + RESTLink selfLink = checkNotNull(LinkUtils.getSelfLink(ip), "AbstractIpDto must have an edit or self link"); + if (refs.searchLinkByHref(selfLink.getHref()) == null) { + RESTLink ref = new RESTLink(selfLink.getTitle(), selfLink.getHref()); + ref.setType(selfLink.getType()); + refs.addLink(ref); + } + } - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java index b99efce8ed..f11d190227 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java @@ -33,20 +33,17 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * * @author Ignasi Barrera */ -public class BindMoveVolumeToPath extends BindToPath -{ +public class BindMoveVolumeToPath extends BindToPath { - @Override - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof VolumeManagementDto, + @Override + protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof VolumeManagementDto, "this binder is only valid for VolumeManagementDto objects"); - VolumeManagementDto volume = (VolumeManagementDto) input; - RESTLink editLink = - checkNotNull(volume.getEditLink(), "VolumeManagementDto must have an edit link"); + VolumeManagementDto volume = (VolumeManagementDto) input; + RESTLink editLink = checkNotNull(volume.getEditLink(), "VolumeManagementDto must have an edit link"); - return editLink.getHref() + "/action/move"; - } + return editLink.getHref() + "/action/move"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java index 6b8ca7fa3b..3ffd9905cd 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java @@ -44,36 +44,30 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class BindNetworkConfigurationRefToPayload extends BindToXMLPayload -{ - @Inject - public BindNetworkConfigurationRefToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindNetworkConfigurationRefToPayload extends BindToXMLPayload { + @Inject + public BindNetworkConfigurationRefToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, "this binder is only valid for GeneratedHttpRequests"); - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, + checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, "this binder is only valid for VLANNetworkDto"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getArgs() != null, "args should be initialized at this point"); + GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; + checkState(gRequest.getArgs() != null, "args should be initialized at this point"); - VLANNetworkDto network = (VLANNetworkDto) input; - VirtualMachineDto vm = - (VirtualMachineDto) Iterables.find(gRequest.getArgs(), - Predicates.instanceOf(VirtualMachineDto.class)); + VLANNetworkDto network = (VLANNetworkDto) input; + VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getArgs(), + Predicates.instanceOf(VirtualMachineDto.class)); - RESTLink configLink = - checkNotNull(vm.searchLink("configurations"), "missing required link"); + RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link"); - LinksDto dto = new LinksDto(); - dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" - + network.getId())); + LinksDto dto = new LinksDto(); + dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId())); - return super.bindToRequest(request, dto); - } + return super.bindToRequest(request, dto); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java index 261af82f2d..5d9ede9580 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java @@ -39,45 +39,40 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * @author Ignasi Barrera */ @Singleton -public class BindNetworkRefToPayload extends BindToXMLPayload -{ - @Inject - public BindNetworkRefToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindNetworkRefToPayload extends BindToXMLPayload { + @Inject + public BindNetworkRefToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, "this binder is only valid for VLANNetworkDto objects"); - VLANNetworkDto network = (VLANNetworkDto) input; - RESTLink editLink = - checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link"); + VLANNetworkDto network = (VLANNetworkDto) input; + RESTLink editLink = checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link"); - LinksDto refs = new LinksDto(); - switch (network.getType()) - { - case INTERNAL: - refs.addLink(new RESTLink("internalnetwork", editLink.getHref())); - break; - case EXTERNAL: - refs.addLink(new RESTLink("externalnetwork", editLink.getHref())); - break; - case PUBLIC: - refs.addLink(new RESTLink("publicnetwork", editLink.getHref())); - break; - case UNMANAGED: - refs.addLink(new RESTLink("unmanagednetwork", editLink.getHref())); - break; - default: - // TODO: EXTERNAL_UNMANAGED network type - throw new IllegalArgumentException("Unsupported network type"); - } + LinksDto refs = new LinksDto(); + switch (network.getType()) { + case INTERNAL: + refs.addLink(new RESTLink("internalnetwork", editLink.getHref())); + break; + case EXTERNAL: + refs.addLink(new RESTLink("externalnetwork", editLink.getHref())); + break; + case PUBLIC: + refs.addLink(new RESTLink("publicnetwork", editLink.getHref())); + break; + case UNMANAGED: + refs.addLink(new RESTLink("unmanagednetwork", editLink.getHref())); + break; + default: + // TODO: EXTERNAL_UNMANAGED network type + throw new IllegalArgumentException("Unsupported network type"); + } - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java index cef4c84033..7d039af54f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java @@ -41,30 +41,25 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * @author Ignasi Barrera */ @Singleton -public class BindUnmanagedIpRefToPayload extends BindToXMLPayload -{ - @Inject - public BindUnmanagedIpRefToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindUnmanagedIpRefToPayload extends BindToXMLPayload { + @Inject + public BindUnmanagedIpRefToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, "this binder is only valid for VLANNetworkDto objects"); - VLANNetworkDto network = (VLANNetworkDto) input; - checkArgument(network.getType() == NetworkType.UNMANAGED, - "this binder is only valid for UNMANAGED networks"); + VLANNetworkDto network = (VLANNetworkDto) input; + checkArgument(network.getType() == NetworkType.UNMANAGED, "this binder is only valid for UNMANAGED networks"); - RESTLink ipsLink = - checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link"); + RESTLink ipsLink = checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link"); - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref())); + LinksDto refs = new LinksDto(); + refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref())); - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java index c6cb64b185..15a8236d97 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java @@ -35,33 +35,29 @@ import com.abiquo.server.core.cloud.VirtualDatacenterDto; import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; /** - * Bind multiple {@link VolumeManagementDto} objects to the payload of the request as a list of - * links. + * Bind multiple {@link VolumeManagementDto} objects to the payload of the + * request as a list of links. * * @author Ignasi Barrera */ @Singleton -public class BindVirtualDatacenterRefToPayload extends BindToXMLPayload -{ - @Inject - public BindVirtualDatacenterRefToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindVirtualDatacenterRefToPayload extends BindToXMLPayload { + @Inject + public BindVirtualDatacenterRefToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof VirtualDatacenterDto, + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof VirtualDatacenterDto, "this binder is only valid for VirtualDatacenterDto objects"); - VirtualDatacenterDto vdc = (VirtualDatacenterDto) input; - RESTLink editLink = - checkNotNull(vdc.getEditLink(), "VirtualDatacenterDto must have an edit link"); - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink("virtualdatacenter", editLink.getHref())); + VirtualDatacenterDto vdc = (VirtualDatacenterDto) input; + RESTLink editLink = checkNotNull(vdc.getEditLink(), "VirtualDatacenterDto must have an edit link"); + LinksDto refs = new LinksDto(); + refs.addLink(new RESTLink("virtualdatacenter", editLink.getHref())); - return super.bindToRequest(request, refs); - } + return super.bindToRequest(request, refs); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java index d71b3c7916..2ecb289b4a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java @@ -28,24 +28,21 @@ import org.jclouds.xml.XMLParser; import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; /** - * Bind multiple {@link VolumeManagementDto} objects to the payload of the request as a list of - * links. + * Bind multiple {@link VolumeManagementDto} objects to the payload of the + * request as a list of links. * * @author Ignasi Barrera */ @Singleton -public class BindVolumeRefsToPayload extends BindRefsToPayload -{ - @Inject - public BindVolumeRefsToPayload(final XMLParser xmlParser) - { - super(xmlParser); - } +public class BindVolumeRefsToPayload extends BindRefsToPayload { + @Inject + public BindVolumeRefsToPayload(final XMLParser xmlParser) { + super(xmlParser); + } - @Override - protected String getRelToUse(final Object input) - { - return "volume"; - } + @Override + protected String getRelToUse(final Object input) { + return "volume"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPath.java index 56d796067f..f24c92cd50 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPath.java @@ -33,21 +33,18 @@ import org.jclouds.http.HttpRequest; * @author Ignasi Barrera */ @Singleton -public class AppendMachineIdToPath extends AppendToPath -{ - private ParseMachineId parser; +public class AppendMachineIdToPath extends AppendToPath { + private ParseMachineId parser; - @Inject - public AppendMachineIdToPath(final ParseMachineId parser) - { - super(); - this.parser = parser; - } + @Inject + public AppendMachineIdToPath(final ParseMachineId parser) { + super(); + this.parser = parser; + } - @Override - protected String getValue(final R request, final Object input) - { - return parser.apply(input); - } + @Override + protected String getValue(final R request, final Object input) { + return parser.apply(input); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPath.java index 4db84bec02..77cd04de57 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPath.java @@ -29,26 +29,24 @@ import org.jclouds.http.HttpRequest; /** * Append the {@link RemoteServiceType} service to the request URI. *

- * This method assumes that the input object is a {@link RemoteServiceType} enumeration. + * This method assumes that the input object is a {@link RemoteServiceType} + * enumeration. * * @author Ignasi Barrera */ @Singleton -public class AppendRemoteServiceTypeToPath extends AppendToPath -{ - private ParseRemoteServiceType parser; +public class AppendRemoteServiceTypeToPath extends AppendToPath { + private ParseRemoteServiceType parser; - @Inject - public AppendRemoteServiceTypeToPath(final ParseRemoteServiceType parser) - { - super(); - this.parser = parser; - } + @Inject + public AppendRemoteServiceTypeToPath(final ParseRemoteServiceType parser) { + super(); + this.parser = parser; + } - @Override - protected String getValue(final R request, final Object input) - { - return parser.apply(input); - } + @Override + protected String getValue(final R request, final Object input) { + return parser.apply(input); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPath.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPath.java index 6bf6d5f86d..e35dff8c23 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPath.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPath.java @@ -30,13 +30,11 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; * @author Ignasi Barrera */ @Singleton -public class BindSupportedDevicesLinkToPath extends BindToPath -{ +public class BindSupportedDevicesLinkToPath extends BindToPath { - @Override - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) - { - return super.getNewEndpoint(gRequest, input) + "/action/supported"; - } + @Override + protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { + return super.getNewEndpoint(gRequest, input) + "/action/supported"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java index ef2072fc40..fc405ad20b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParameters.java @@ -30,24 +30,22 @@ import org.jclouds.rest.Binder; import com.abiquo.server.core.infrastructure.LogicServerDto; /** - * Binds logic server query parameters to request. This method assumes that the input object is a - * {@link LogicServerDto}. + * Binds logic server query parameters to request. This method assumes that the + * input object is a {@link LogicServerDto}. * * @author Francesc Montserrat * @author Ignasi Barrera */ @Singleton -public class BindLogicServerParameters implements Binder -{ - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof LogicServerDto, +public class BindLogicServerParameters implements Binder { + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof LogicServerDto, "this binder is only valid for LogicServerDto objects"); - LogicServerDto server = (LogicServerDto) input; + LogicServerDto server = (LogicServerDto) input; - return (R) request.toBuilder().addQueryParam("lsName", server.getName()).build(); - } + return (R) request.toBuilder().addQueryParam("lsName", server.getName()).build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java index ddde0cddc0..2a56a43923 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParameters.java @@ -30,25 +30,23 @@ import org.jclouds.rest.Binder; import com.abiquo.server.core.infrastructure.OrganizationDto; /** - * Binds organization query parameters to request. This method assumes that the input object is a - * {@link OrganizationDto}. + * Binds organization query parameters to request. This method assumes that the + * input object is a {@link OrganizationDto}. * * @author Francesc Montserrat * @author Ignasi Barrera */ @Singleton -public class BindOrganizationParameters implements Binder -{ +public class BindOrganizationParameters implements Binder { - @SuppressWarnings("unchecked") - @Override - public R bindToRequest(final R request, final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof OrganizationDto, + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(final R request, final Object input) { + checkArgument(checkNotNull(input, "input") instanceof OrganizationDto, "this binder is only valid for OrganizationDto objects"); - OrganizationDto org = (OrganizationDto) input; + OrganizationDto org = (OrganizationDto) input; - return (R) request.toBuilder().addQueryParam("org", org.getDn()).build(); - } + return (R) request.toBuilder().addQueryParam("org", org.getDn()).build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java index d9e78710dd..fe72c8d88e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/config/AbiquoComputeServiceContextModule.java @@ -51,38 +51,29 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ public class AbiquoComputeServiceContextModule - extends - ComputeServiceAdapterContextModule -{ + extends + ComputeServiceAdapterContextModule { - @Override - protected void configure() - { - super.configure(); - bind( - new TypeLiteral>() - { + @Override + protected void configure() { + super.configure(); + bind( + new TypeLiteral>() { }).to(AbiquoComputeServiceAdapter.class); - bind(new TypeLiteral>() - { - }).to(VirtualMachineToNodeMetadata.class); - bind(new TypeLiteral>() - { - }).to(VirtualMachineTemplateToImage.class); - bind(new TypeLiteral>() - { - }).to(VirtualMachineTemplateInVirtualDatacenterToHardware.class); - bind(new TypeLiteral>() - { - }).to(DatacenterToLocation.class); - bind(new TypeLiteral>() - { - }).to(VirtualDatacenterToLocation.class); - bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); - bind(TemplateOptions.class).to(AbiquoTemplateOptions.class); - install(new LocationsFromComputeServiceAdapterModule() - { - }); - } + bind(new TypeLiteral>() { + }).to(VirtualMachineToNodeMetadata.class); + bind(new TypeLiteral>() { + }).to(VirtualMachineTemplateToImage.class); + bind(new TypeLiteral>() { + }).to(VirtualMachineTemplateInVirtualDatacenterToHardware.class); + bind(new TypeLiteral>() { + }).to(DatacenterToLocation.class); + bind(new TypeLiteral>() { + }).to(VirtualDatacenterToLocation.class); + bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON); + bind(TemplateOptions.class).to(AbiquoTemplateOptions.class); + install(new LocationsFromComputeServiceAdapterModule() { + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/DatacenterToLocation.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/DatacenterToLocation.java index 57a872ea94..73e0ec53ff 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/DatacenterToLocation.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/DatacenterToLocation.java @@ -38,22 +38,19 @@ import com.google.common.collect.ImmutableSet; * @author Ignasi Barrera */ @Singleton -public class DatacenterToLocation implements Function -{ +public class DatacenterToLocation implements Function { - @Override - public Location apply(final Datacenter datacenter) - { - LocationBuilder builder = new LocationBuilder(); - builder.id(datacenter.getId().toString()); - builder.description(datacenter.getName() + " [" + datacenter.getLocation() + "]"); - builder.metadata(ImmutableMap. of()); - builder.scope(LocationScope.REGION); - builder.iso3166Codes(ImmutableSet. of()); + @Override + public Location apply(final Datacenter datacenter) { + LocationBuilder builder = new LocationBuilder(); + builder.id(datacenter.getId().toString()); + builder.description(datacenter.getName() + " [" + datacenter.getLocation() + "]"); + builder.metadata(ImmutableMap. of()); + builder.scope(LocationScope.REGION); + builder.iso3166Codes(ImmutableSet. of()); - builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo") - .description("abiquo").build()); + builder.parent(new LocationBuilder().scope(LocationScope.PROVIDER).id("abiquo").description("abiquo").build()); - return builder.build(); - } + return builder.build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocation.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocation.java index d5fb7ff22c..aca53ea8dd 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocation.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocation.java @@ -42,40 +42,37 @@ import com.google.common.collect.ImmutableSet; /** * Converts a {@link VirtualDatacenter} to a {@link Location} one. *

- * Virtual datacenters will be considered zones, since images will be deployed in a virtual - * datacenter. Each zone will be scoped into a physical datacenter (region). + * Virtual datacenters will be considered zones, since images will be deployed + * in a virtual datacenter. Each zone will be scoped into a physical datacenter + * (region). * * @author Ignasi Barrera */ @Singleton -public class VirtualDatacenterToLocation implements Function -{ - private final Function datacenterToLocation; +public class VirtualDatacenterToLocation implements Function { + private final Function datacenterToLocation; - private final Supplier> regionMap; + private final Supplier> regionMap; - @Inject - public VirtualDatacenterToLocation(final Function datacenterToLocation, - @Memoized final Supplier> regionMap) - { - this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation"); - this.regionMap = checkNotNull(regionMap, "regionMap"); - } + @Inject + public VirtualDatacenterToLocation(final Function datacenterToLocation, + @Memoized final Supplier> regionMap) { + this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation"); + this.regionMap = checkNotNull(regionMap, "regionMap"); + } - @Override - public Location apply(final VirtualDatacenter vdc) - { - LocationBuilder builder = new LocationBuilder(); - builder.id(vdc.getId().toString()); - builder.description(vdc.getName()); - builder.metadata(ImmutableMap. of()); - builder.scope(LocationScope.ZONE); - builder.iso3166Codes(ImmutableSet. of()); + @Override + public Location apply(final VirtualDatacenter vdc) { + LocationBuilder builder = new LocationBuilder(); + builder.id(vdc.getId().toString()); + builder.description(vdc.getName()); + builder.metadata(ImmutableMap. of()); + builder.scope(LocationScope.ZONE); + builder.iso3166Codes(ImmutableSet. of()); - Datacenter parent = - regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER)); - builder.parent(datacenterToLocation.apply(parent)); + Datacenter parent = regionMap.get().get(vdc.unwrap().getIdFromLink(ParentLinkName.DATACENTER)); + builder.parent(datacenterToLocation.apply(parent)); - return builder.build(); - } + return builder.build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeState.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeState.java index f7c8c951e5..2ab7e4c272 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeState.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeState.java @@ -32,27 +32,24 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Singleton -public class VirtualMachineStateToNodeState implements Function -{ +public class VirtualMachineStateToNodeState implements Function { - @Override - public Status apply(final VirtualMachineState state) - { - switch (state) - { - case ALLOCATED: - case LOCKED: - case CONFIGURED: - case NOT_ALLOCATED: - return Status.PENDING; - case ON: - return Status.RUNNING; - case OFF: - case PAUSED: - return Status.SUSPENDED; - case UNKNOWN: - default: - return Status.UNRECOGNIZED; - } - } + @Override + public Status apply(final VirtualMachineState state) { + switch (state) { + case ALLOCATED: + case LOCKED: + case CONFIGURED: + case NOT_ALLOCATED: + return Status.PENDING; + case ON: + return Status.RUNNING; + case OFF: + case PAUSED: + return Status.SUSPENDED; + case UNKNOWN: + default: + return Status.UNRECOGNIZED; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java index eddd74605b..401b485479 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardware.java @@ -41,61 +41,56 @@ import com.google.common.base.Function; /** * Transforms a {@link VirtualMachineTemplate} into an {@link Hardware}. *

- * Each {@link Image} ({@link VirtualMachineTemplate}) will have one {@link Hardware} entity for - * each zone (scoped to a virtualization technology) supported by the image. + * Each {@link Image} ({@link VirtualMachineTemplate}) will have one + * {@link Hardware} entity for each zone (scoped to a virtualization technology) + * supported by the image. * * @author Ignasi Barrera */ @Singleton public class VirtualMachineTemplateInVirtualDatacenterToHardware implements - Function -{ - /** The default core speed, 2.0Ghz. */ - public static final double DEFAULT_CORE_SPEED = 2.0; + Function { + /** The default core speed, 2.0Ghz. */ + public static final double DEFAULT_CORE_SPEED = 2.0; - private final Function virtualDatacenterToLocation; + private final Function virtualDatacenterToLocation; - @Inject - public VirtualMachineTemplateInVirtualDatacenterToHardware( - final Function virtualDatacenterToLocation) - { - this.virtualDatacenterToLocation = - checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation"); - } + @Inject + public VirtualMachineTemplateInVirtualDatacenterToHardware( + final Function virtualDatacenterToLocation) { + this.virtualDatacenterToLocation = checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation"); + } - @Override - public Hardware apply( - final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter) - { - VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate(); - VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone(); + @Override + public Hardware apply(final VirtualMachineTemplateInVirtualDatacenter templateInVirtualDatacenter) { + VirtualMachineTemplate template = templateInVirtualDatacenter.getTemplate(); + VirtualDatacenter virtualDatacenter = templateInVirtualDatacenter.getZone(); - HardwareBuilder builder = new HardwareBuilder(); - builder.providerId(template.getId().toString()); - builder.id(template.getId().toString() + "/" + virtualDatacenter.getId()); - builder.uri(template.getURI()); + HardwareBuilder builder = new HardwareBuilder(); + builder.providerId(template.getId().toString()); + builder.id(template.getId().toString() + "/" + virtualDatacenter.getId()); + builder.uri(template.getURI()); - builder.name(template.getName()); - builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED)); - builder.ram(template.getRamRequired()); + builder.name(template.getName()); + builder.processor(new Processor(template.getCpuRequired(), DEFAULT_CORE_SPEED)); + builder.ram(template.getRamRequired()); - // Location information - builder.location(virtualDatacenterToLocation.apply(virtualDatacenter)); - builder.hypervisor(virtualDatacenter.getHypervisorType().name()); - builder.supportsImage(ImagePredicates.idEquals(template.getId().toString())); + // Location information + builder.location(virtualDatacenterToLocation.apply(virtualDatacenter)); + builder.hypervisor(virtualDatacenter.getHypervisorType().name()); + builder.supportsImage(ImagePredicates.idEquals(template.getId().toString())); - VolumeBuilder volumeBuilder = new VolumeBuilder(); - volumeBuilder.bootDevice(true); - volumeBuilder.size(toGb(template.getHdRequired())); - volumeBuilder.type(Volume.Type.LOCAL); - volumeBuilder.durable(false); - builder.volume(volumeBuilder.build()); + VolumeBuilder volumeBuilder = new VolumeBuilder(); + volumeBuilder.bootDevice(true); + volumeBuilder.size(toGb(template.getHdRequired())); + volumeBuilder.type(Volume.Type.LOCAL); + volumeBuilder.durable(false); + builder.volume(volumeBuilder.build()); - return builder.build(); - } + return builder.build(); + } - private static float toGb(final long bytes) - { - return bytes / 1024 / 1024 / (float) 1024; - } + private static float toGb(final long bytes) { + return bytes / 1024 / 1024 / (float) 1024; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImage.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImage.java index 616593ec69..7eb598d398 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImage.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImage.java @@ -49,45 +49,43 @@ import com.google.common.base.Supplier; * @author Ignasi Barrera */ @Singleton -public class VirtualMachineTemplateToImage implements Function -{ - private final Function datacenterToLocation; +public class VirtualMachineTemplateToImage implements Function { + private final Function datacenterToLocation; - private final Supplier> regionMap; + private final Supplier> regionMap; - @Inject - public VirtualMachineTemplateToImage(final Function datacenterToLocation, - @Memoized final Supplier> reginoMap) - { - this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation"); - this.regionMap = checkNotNull(reginoMap, "reginoMap"); - } + @Inject + public VirtualMachineTemplateToImage(final Function datacenterToLocation, + @Memoized final Supplier> reginoMap) { + this.datacenterToLocation = checkNotNull(datacenterToLocation, "datacenterToLocation"); + this.regionMap = checkNotNull(reginoMap, "reginoMap"); + } - @Override - public Image apply(final VirtualMachineTemplate template) - { - ImageBuilder builder = new ImageBuilder(); - builder.ids(template.getId().toString()); - builder.name(template.getName()); - builder.description(template.getDescription()); + @Override + public Image apply(final VirtualMachineTemplate template) { + ImageBuilder builder = new ImageBuilder(); + builder.ids(template.getId().toString()); + builder.name(template.getName()); + builder.description(template.getDescription()); - // Location information - Datacenter region = - regionMap.get().get(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER)); - builder.location(datacenterToLocation.apply(region)); + // Location information + Datacenter region = regionMap.get().get(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER)); + builder.location(datacenterToLocation.apply(region)); - // Only conversions have a status - builder.status(Status.AVAILABLE); - builder.backendStatus(Status.AVAILABLE.name()); // Abiquo images do not have a status + // Only conversions have a status + builder.status(Status.AVAILABLE); + builder.backendStatus(Status.AVAILABLE.name()); // Abiquo images do not + // have a status - RESTLink downloadLink = template.unwrap().searchLink("diskfile"); - builder.uri(downloadLink == null ? null : URI.create(downloadLink.getHref())); + RESTLink downloadLink = template.unwrap().searchLink("diskfile"); + builder.uri(downloadLink == null ? null : URI.create(downloadLink.getHref())); - // TODO: Operating system not implemented in Abiquo Templates - // TODO: Image credentials still not present in Abiquo template metadata - // Will be added in Abiquo 2.4: http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647 - builder.operatingSystem(OperatingSystem.builder().description(template.getName()).build()); + // TODO: Operating system not implemented in Abiquo Templates + // TODO: Image credentials still not present in Abiquo template metadata + // Will be added in Abiquo 2.4: + // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647 + builder.operatingSystem(OperatingSystem.builder().description(template.getName()).build()); - return builder.build(); - } + return builder.build(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadata.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadata.java index 4a552391e8..04fd623415 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadata.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadata.java @@ -55,98 +55,87 @@ import com.google.common.collect.Lists; * @author Ignasi Barrera */ @Singleton -public class VirtualMachineToNodeMetadata implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class VirtualMachineToNodeMetadata implements Function { + @Resource + protected Logger logger = Logger.NULL; - private final VirtualMachineTemplateToImage virtualMachineTemplateToImage; + private final VirtualMachineTemplateToImage virtualMachineTemplateToImage; - private final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware; + private final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware; - private final VirtualMachineStateToNodeState virtualMachineStateToNodeState; + private final VirtualMachineStateToNodeState virtualMachineStateToNodeState; - private final Function virtualDatacenterToLocation; + private final Function virtualDatacenterToLocation; - @Inject - public VirtualMachineToNodeMetadata( - final VirtualMachineTemplateToImage virtualMachineTemplateToImage, - final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware, - final VirtualMachineStateToNodeState virtualMachineStateToNodeState, - final Function virtualDatacenterToLocation) - { - this.virtualMachineTemplateToImage = - checkNotNull(virtualMachineTemplateToImage, "virtualMachineTemplateToImage"); - this.virtualMachineTemplateToHardware = - checkNotNull(virtualMachineTemplateToHardware, "virtualMachineTemplateToHardware"); - this.virtualMachineStateToNodeState = - checkNotNull(virtualMachineStateToNodeState, "virtualMachineStateToNodeState"); - this.virtualDatacenterToLocation = - checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation"); - } + @Inject + public VirtualMachineToNodeMetadata(final VirtualMachineTemplateToImage virtualMachineTemplateToImage, + final VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware, + final VirtualMachineStateToNodeState virtualMachineStateToNodeState, + final Function virtualDatacenterToLocation) { + this.virtualMachineTemplateToImage = checkNotNull(virtualMachineTemplateToImage, "virtualMachineTemplateToImage"); + this.virtualMachineTemplateToHardware = checkNotNull(virtualMachineTemplateToHardware, + "virtualMachineTemplateToHardware"); + this.virtualMachineStateToNodeState = checkNotNull(virtualMachineStateToNodeState, + "virtualMachineStateToNodeState"); + this.virtualDatacenterToLocation = checkNotNull(virtualDatacenterToLocation, "virtualDatacenterToLocation"); + } - @Override - public NodeMetadata apply(final VirtualMachine vm) - { - NodeMetadataBuilder builder = new NodeMetadataBuilder(); - builder.ids(vm.getId().toString()); - builder.uri(vm.getURI()); - builder.name(vm.getNameLabel()); - builder.group(vm.getVirtualAppliance().getName()); + @Override + public NodeMetadata apply(final VirtualMachine vm) { + NodeMetadataBuilder builder = new NodeMetadataBuilder(); + builder.ids(vm.getId().toString()); + builder.uri(vm.getURI()); + builder.name(vm.getNameLabel()); + builder.group(vm.getVirtualAppliance().getName()); - // TODO: Node credentials still not present in Abiquo template metadata - // Will be added in Abiquo 2.4: http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647 + // TODO: Node credentials still not present in Abiquo template metadata + // Will be added in Abiquo 2.4: + // http://jira.abiquo.com/browse/ABICLOUDPREMIUM-3647 - // Location details - VirtualDatacenter vdc = vm.getVirtualDatacenter(); - builder.location(virtualDatacenterToLocation.apply(vdc)); + // Location details + VirtualDatacenter vdc = vm.getVirtualDatacenter(); + builder.location(virtualDatacenterToLocation.apply(vdc)); - // Image details - VirtualMachineTemplate template = vm.getTemplate(); - Image image = virtualMachineTemplateToImage.apply(template); - builder.imageId(image.getId().toString()); - builder.operatingSystem(image.getOperatingSystem()); + // Image details + VirtualMachineTemplate template = vm.getTemplate(); + Image image = virtualMachineTemplateToImage.apply(template); + builder.imageId(image.getId().toString()); + builder.operatingSystem(image.getOperatingSystem()); - // Hardware details - Hardware defaultHardware = - virtualMachineTemplateToHardware - .apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + // Hardware details + Hardware defaultHardware = virtualMachineTemplateToHardware.apply(new VirtualMachineTemplateInVirtualDatacenter( + template, vdc)); - Hardware hardware = - HardwareBuilder - .fromHardware(defaultHardware) - .ram(vm.getRam()) - .processors( - Lists.newArrayList(new Processor(vm.getCpu(), + Hardware hardware = HardwareBuilder + .fromHardware(defaultHardware) + .ram(vm.getRam()) + .processors( + Lists.newArrayList(new Processor(vm.getCpu(), VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED))) // - .build(); + .build(); - builder.hardware(hardware); + builder.hardware(hardware); - // Networking configuration - List> nics = vm.listAttachedNics(); - builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class)))); - builder.publicAddresses(ips(filter(nics, - Predicates.not(Predicates.instanceOf(PrivateIp.class))))); + // Networking configuration + List> nics = vm.listAttachedNics(); + builder.privateAddresses(ips(filter(nics, Predicates.instanceOf(PrivateIp.class)))); + builder.publicAddresses(ips(filter(nics, Predicates.not(Predicates.instanceOf(PrivateIp.class))))); - // Node state - VirtualMachineState state = vm.getState(); - builder.status(virtualMachineStateToNodeState.apply(state)); - builder.backendStatus(state.name()); + // Node state + VirtualMachineState state = vm.getState(); + builder.status(virtualMachineStateToNodeState.apply(state)); + builder.backendStatus(state.name()); - return builder.build(); - } + return builder.build(); + } - private static Iterable ips(final Iterable> nics) - { - return transform(nics, new Function, String>() - { - @Override - public String apply(final Ip< ? , ? > nic) - { - return nic.getIp(); - } - }); - } + private static Iterable ips(final Iterable> nics) { + return transform(nics, new Function, String>() { + @Override + public String apply(final Ip nic) { + return nic.getIp(); + } + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptions.java index f342dafded..00fd6f832e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptions.java @@ -25,119 +25,105 @@ import org.jclouds.compute.options.TemplateOptions; /** * Contains options supported by the * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and - * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} operations on the - * Abiquo provider. + * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} + * operations on the Abiquo provider. * * @author Ignasi Barrera */ -public class AbiquoTemplateOptions extends TemplateOptions implements Cloneable -{ - public static final AbiquoTemplateOptions NONE = new AbiquoTemplateOptions(); +public class AbiquoTemplateOptions extends TemplateOptions implements Cloneable { + public static final AbiquoTemplateOptions NONE = new AbiquoTemplateOptions(); - private Integer overrideCores; + private Integer overrideCores; - private Integer overrideRam; + private Integer overrideRam; - private String vncPassword; + private String vncPassword; - @Override - public TemplateOptions clone() - { - AbiquoTemplateOptions options = new AbiquoTemplateOptions(); - copyTo(options); - return options; - } + @Override + public TemplateOptions clone() { + AbiquoTemplateOptions options = new AbiquoTemplateOptions(); + copyTo(options); + return options; + } - @Override - public void copyTo(final TemplateOptions to) - { - super.copyTo(to); - if (to instanceof AbiquoTemplateOptions) - { - AbiquoTemplateOptions options = AbiquoTemplateOptions.class.cast(to); - options.overrideCores(overrideCores); - options.overrideRam(overrideRam); - options.vncPassword(vncPassword); - } - } + @Override + public void copyTo(final TemplateOptions to) { + super.copyTo(to); + if (to instanceof AbiquoTemplateOptions) { + AbiquoTemplateOptions options = AbiquoTemplateOptions.class.cast(to); + options.overrideCores(overrideCores); + options.overrideRam(overrideRam); + options.vncPassword(vncPassword); + } + } - /** - * Override the number of cores set by the hardware profile. - * - * @return The template options with the number of cores. - */ - public AbiquoTemplateOptions overrideCores(final Integer overrideCores) - { - this.overrideCores = overrideCores; - return this; - } + /** + * Override the number of cores set by the hardware profile. + * + * @return The template options with the number of cores. + */ + public AbiquoTemplateOptions overrideCores(final Integer overrideCores) { + this.overrideCores = overrideCores; + return this; + } - public Integer getOverrideCores() - { - return overrideCores; - } + public Integer getOverrideCores() { + return overrideCores; + } - /** - * Override the amount of ram set by the hardware profile. - * - * @return The template options with the amount of ram. - */ - public AbiquoTemplateOptions overrideRam(final Integer overrideRam) - { - this.overrideRam = overrideRam; - return this; - } + /** + * Override the amount of ram set by the hardware profile. + * + * @return The template options with the amount of ram. + */ + public AbiquoTemplateOptions overrideRam(final Integer overrideRam) { + this.overrideRam = overrideRam; + return this; + } - public Integer getOverrideRam() - { - return overrideRam; - } + public Integer getOverrideRam() { + return overrideRam; + } - /** - * Set the VNC password to access the virtual machine. - *

- * By default virtual machines does not have VNC access password protected. - * - * @return The template options with the VNC password. - */ - public AbiquoTemplateOptions vncPassword(final String vncPassword) - { - this.vncPassword = vncPassword; - return this; - } + /** + * Set the VNC password to access the virtual machine. + *

+ * By default virtual machines does not have VNC access password protected. + * + * @return The template options with the VNC password. + */ + public AbiquoTemplateOptions vncPassword(final String vncPassword) { + this.vncPassword = vncPassword; + return this; + } - public String getVncPassword() - { - return vncPassword; - } + public String getVncPassword() { + return vncPassword; + } - public static class Builder - { - /** - * @see AbiquoTemplateOptions#overrideCores(int) - */ - public static AbiquoTemplateOptions overrideCores(final Integer overrideCores) - { - AbiquoTemplateOptions options = new AbiquoTemplateOptions(); - return options.overrideCores(overrideCores); - } + public static class Builder { + /** + * @see AbiquoTemplateOptions#overrideCores(int) + */ + public static AbiquoTemplateOptions overrideCores(final Integer overrideCores) { + AbiquoTemplateOptions options = new AbiquoTemplateOptions(); + return options.overrideCores(overrideCores); + } - /** - * @see AbiquoTemplateOptions#overrideRam(int) - */ - public static AbiquoTemplateOptions overrideRam(final Integer overrideRam) - { - AbiquoTemplateOptions options = new AbiquoTemplateOptions(); - return options.overrideRam(overrideRam); - } + /** + * @see AbiquoTemplateOptions#overrideRam(int) + */ + public static AbiquoTemplateOptions overrideRam(final Integer overrideRam) { + AbiquoTemplateOptions options = new AbiquoTemplateOptions(); + return options.overrideRam(overrideRam); + } - /** - * @see AbiquoTemplateOptions#vncPassword(String) - */ - public static AbiquoTemplateOptions vncPassword(final String vncPassword) - { - AbiquoTemplateOptions options = new AbiquoTemplateOptions(); - return options.vncPassword(vncPassword); - } - } + /** + * @see AbiquoTemplateOptions#vncPassword(String) + */ + public static AbiquoTemplateOptions vncPassword(final String vncPassword) { + AbiquoTemplateOptions options = new AbiquoTemplateOptions(); + return options.vncPassword(vncPassword); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java index 4b26e5eca3..a58cc3d4ec 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/AbiquoComputeServiceAdapter.java @@ -66,223 +66,195 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; /** - * Defines the connection between the {@link AbiquoApi} implementation and the jclouds - * {@link ComputeService}. + * Defines the connection between the {@link AbiquoApi} implementation and the + * jclouds {@link ComputeService}. * * @author Ignasi Barrera */ @Singleton public class AbiquoComputeServiceAdapter - implements - ComputeServiceAdapter -{ - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; + implements + ComputeServiceAdapter { + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; - private final RestContext context; + private final RestContext context; - private final AdministrationService adminService; + private final AdministrationService adminService; - private final CloudService cloudService; + private final CloudService cloudService; - private final MonitoringService monitoringService; + private final MonitoringService monitoringService; - private final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters; + private final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters; - private final Supplier> regionMap; + private final Supplier> regionMap; - @Inject - public AbiquoComputeServiceAdapter(final RestContext context, - final AdministrationService adminService, final CloudService cloudService, - final MonitoringService monitoringService, - final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters, - @Memoized final Supplier> regionMap) - { - this.context = checkNotNull(context, "context"); - this.adminService = checkNotNull(adminService, "adminService"); - this.cloudService = checkNotNull(cloudService, "cloudService"); - this.monitoringService = checkNotNull(monitoringService, "monitoringService"); - this.compatibleVirtualDatacenters = - checkNotNull(compatibleVirtualDatacenters, "compatibleVirtualDatacenters"); - this.regionMap = checkNotNull(regionMap, "regionMap"); - } + @Inject + public AbiquoComputeServiceAdapter(final RestContext context, + final AdministrationService adminService, final CloudService cloudService, + final MonitoringService monitoringService, + final FindCompatibleVirtualDatacenters compatibleVirtualDatacenters, + @Memoized final Supplier> regionMap) { + this.context = checkNotNull(context, "context"); + this.adminService = checkNotNull(adminService, "adminService"); + this.cloudService = checkNotNull(cloudService, "cloudService"); + this.monitoringService = checkNotNull(monitoringService, "monitoringService"); + this.compatibleVirtualDatacenters = checkNotNull(compatibleVirtualDatacenters, "compatibleVirtualDatacenters"); + this.regionMap = checkNotNull(regionMap, "regionMap"); + } - @Override - public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( - final String tag, final String name, final Template template) - { - AbiquoTemplateOptions options = template.getOptions().as(AbiquoTemplateOptions.class); - Enterprise enterprise = adminService.getCurrentEnterprise(); + @Override + public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(final String tag, + final String name, final Template template) { + AbiquoTemplateOptions options = template.getOptions().as(AbiquoTemplateOptions.class); + Enterprise enterprise = adminService.getCurrentEnterprise(); - // Get the region where the template is available - Datacenter datacenter = - regionMap.get().get(Integer.valueOf(template.getImage().getLocation().getId())); + // Get the region where the template is available + Datacenter datacenter = regionMap.get().get(Integer.valueOf(template.getImage().getLocation().getId())); - // Load the template - VirtualMachineTemplate virtualMachineTemplate = - enterprise.getTemplateInRepository(datacenter, - Integer.valueOf(template.getImage().getId())); + // Load the template + VirtualMachineTemplate virtualMachineTemplate = enterprise.getTemplateInRepository(datacenter, + Integer.valueOf(template.getImage().getId())); - // Get the zone where the template will be deployed - VirtualDatacenter vdc = - cloudService.getVirtualDatacenter(Integer.valueOf(template.getHardware().getLocation() - .getId())); + // Get the zone where the template will be deployed + VirtualDatacenter vdc = cloudService.getVirtualDatacenter(Integer.valueOf(template.getHardware().getLocation() + .getId())); - // Load the virtual appliance or create it if it does not exist - VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag)); - if (vapp == null) - { - vapp = VirtualAppliance.builder(context, vdc).name(tag).build(); - vapp.save(); - } + // Load the virtual appliance or create it if it does not exist + VirtualAppliance vapp = vdc.findVirtualAppliance(VirtualAppliancePredicates.name(tag)); + if (vapp == null) { + vapp = VirtualAppliance.builder(context, vdc).name(tag).build(); + vapp.save(); + } - Integer overrideCores = options.getOverrideCores(); - Integer overrideRam = options.getOverrideRam(); + Integer overrideCores = options.getOverrideCores(); + Integer overrideRam = options.getOverrideRam(); - VirtualMachine vm = VirtualMachine.builder(context, vapp, virtualMachineTemplate) // + VirtualMachine vm = VirtualMachine.builder(context, vapp, virtualMachineTemplate) // .nameLabel(name) // .cpu(overrideCores != null ? overrideCores : totalCores(template.getHardware())) // .ram(overrideRam != null ? overrideRam : template.getHardware().getRam()) // .password(options.getVncPassword()) // Can be null .build(); - vm.save(); + vm.save(); - // Once the virtual machine is created, override the default network settings if needed - // If no public ip is available in the virtual datacenter, the virtual machine will be - // assigned by default an ip address in the default private VLAN for the virtual datacenter - PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates. notUsed()); - if (publicIp != null) - { - List ips = Lists.newArrayList(); - ips.add(publicIp); - vm.setNics(ips); - } + // Once the virtual machine is created, override the default network + // settings if needed + // If no public ip is available in the virtual datacenter, the virtual + // machine will be assigned by default an ip address in the default + // private VLAN for the virtual datacenter + PublicIp publicIp = vdc.findPurchasedPublicIp(IpPredicates. notUsed()); + if (publicIp != null) { + List ips = Lists.newArrayList(); + ips.add(publicIp); + vm.setNics(ips); + } - // This is an async operation, but jclouds already waits until the node is RUNNING, so there - // is no need to block here - vm.deploy(); + // This is an async operation, but jclouds already waits until the node is + // RUNNING, so there is no need to block here + vm.deploy(); - return new NodeAndInitialCredentials(vm, vm.getId().toString(), null); - } + return new NodeAndInitialCredentials(vm, vm.getId().toString(), null); + } - @Override - public Iterable listHardwareProfiles() - { - // In Abiquo, images are scoped to a region (physical datacenter), and hardware profiles are - // scoped to a zone (a virtual datacenter in the region, with a concrete virtualization - // technology) + @Override + public Iterable listHardwareProfiles() { + // In Abiquo, images are scoped to a region (physical datacenter), and + // hardware profiles are scoped to a zone (a virtual datacenter in the + // region, with a concrete virtualization technology) - return concat(transform(listImages(), - new Function>() - { - @Override - public Iterable apply( - final VirtualMachineTemplate template) - { - Iterable compatibleZones = - compatibleVirtualDatacenters.execute(template); + return concat(transform(listImages(), + new Function>() { + @Override + public Iterable apply(final VirtualMachineTemplate template) { + Iterable compatibleZones = compatibleVirtualDatacenters.execute(template); - return transform(compatibleZones, - new Function() - { - @Override - public VirtualMachineTemplateInVirtualDatacenter apply(final VirtualDatacenter vdc) - { - return new VirtualMachineTemplateInVirtualDatacenter(template, vdc); - } + return transform(compatibleZones, + new Function() { + @Override + public VirtualMachineTemplateInVirtualDatacenter apply(final VirtualDatacenter vdc) { + return new VirtualMachineTemplateInVirtualDatacenter(template, vdc); + } }); - } + } })); - } + } - @Override - public Iterable listImages() - { - Enterprise enterprise = adminService.getCurrentEnterprise(); - return enterprise.listTemplates(); - } + @Override + public Iterable listImages() { + Enterprise enterprise = adminService.getCurrentEnterprise(); + return enterprise.listTemplates(); + } - @Override - public VirtualMachineTemplate getImage(final String id) - { - Enterprise enterprise = adminService.getCurrentEnterprise(); - return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(Integer.valueOf(id))); - } + @Override + public VirtualMachineTemplate getImage(final String id) { + Enterprise enterprise = adminService.getCurrentEnterprise(); + return enterprise.findTemplate(VirtualMachineTemplatePredicates.id(Integer.valueOf(id))); + } - @Override - public Iterable listLocations() - { - return cloudService.listVirtualDatacenters(); - } + @Override + public Iterable listLocations() { + return cloudService.listVirtualDatacenters(); + } - @Override - public VirtualMachine getNode(final String id) - { - return cloudService.findVirtualMachine(vmId(id)); - } + @Override + public VirtualMachine getNode(final String id) { + return cloudService.findVirtualMachine(vmId(id)); + } - @Override - public void destroyNode(final String id) - { - VirtualMachine vm = getNode(id); - vm.delete(); - } + @Override + public void destroyNode(final String id) { + VirtualMachine vm = getNode(id); + vm.delete(); + } - @Override - public void rebootNode(final String id) - { - VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); - VirtualMachine vm = getNode(id); - vm.reboot(); - monitor.awaitState(VirtualMachineState.ON, vm); - } + @Override + public void rebootNode(final String id) { + VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); + VirtualMachine vm = getNode(id); + vm.reboot(); + monitor.awaitState(VirtualMachineState.ON, vm); + } - @Override - public void resumeNode(final String id) - { - VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); - VirtualMachine vm = getNode(id); - vm.changeState(VirtualMachineState.ON); - monitor.awaitState(VirtualMachineState.ON, vm); - } + @Override + public void resumeNode(final String id) { + VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); + VirtualMachine vm = getNode(id); + vm.changeState(VirtualMachineState.ON); + monitor.awaitState(VirtualMachineState.ON, vm); + } - @Override - public void suspendNode(final String id) - { - VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); - VirtualMachine vm = getNode(id); - vm.changeState(VirtualMachineState.PAUSED); - monitor.awaitState(VirtualMachineState.PAUSED, vm); - } + @Override + public void suspendNode(final String id) { + VirtualMachineMonitor monitor = monitoringService.getVirtualMachineMonitor(); + VirtualMachine vm = getNode(id); + vm.changeState(VirtualMachineState.PAUSED); + monitor.awaitState(VirtualMachineState.PAUSED, vm); + } - @Override - public Iterable listNodes() - { - return cloudService.listVirtualMachines(); - } + @Override + public Iterable listNodes() { + return cloudService.listVirtualMachines(); + } - private static Predicate vmId(final String id) - { - return new Predicate() - { - @Override - public boolean apply(final VirtualMachine input) - { - return Integer.valueOf(id).equals(input.getId()); - } - }; - } + private static Predicate vmId(final String id) { + return new Predicate() { + @Override + public boolean apply(final VirtualMachine input) { + return Integer.valueOf(id).equals(input.getId()); + } + }; + } - private static int totalCores(final Hardware hardware) - { - double cores = 0; - for (Processor processor : hardware.getProcessors()) - { - cores += processor.getCores(); - } - return Double.valueOf(cores).intValue(); - } + private static int totalCores(final Hardware hardware) { + double cores = 0; + for (Processor processor : hardware.getProcessors()) { + cores += processor.getCores(); + } + return Double.valueOf(cores).intValue(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/FindCompatibleVirtualDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/FindCompatibleVirtualDatacenters.java index b069f98d79..a80bb5391e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/FindCompatibleVirtualDatacenters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/FindCompatibleVirtualDatacenters.java @@ -26,12 +26,12 @@ import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; import com.google.inject.ImplementedBy; /** - * Finds all virtual datacenters where the given {@link VirtualMachineTemplate} can be deployed. + * Finds all virtual datacenters where the given {@link VirtualMachineTemplate} + * can be deployed. * * @author Ignasi Barrera */ @ImplementedBy(FindCompatibleVirtualDatacentersForImageAndConversions.class) -public interface FindCompatibleVirtualDatacenters -{ - Iterable execute(VirtualMachineTemplate template); +public interface FindCompatibleVirtualDatacenters { + Iterable execute(VirtualMachineTemplate template); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java index aee3195b01..d5eecd7b6e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageAndConversions.java @@ -40,43 +40,40 @@ import org.jclouds.rest.RestContext; import com.abiquo.server.core.infrastructure.DatacenterDto; /** - * Default implementation for the {@link FindCompatibleVirtualDatacenters} strategy. + * Default implementation for the {@link FindCompatibleVirtualDatacenters} + * strategy. *

- * This strategy assumes that the datacenter will have different hypervisor technologies, and images - * will have conversions to each of them. + * This strategy assumes that the datacenter will have different hypervisor + * technologies, and images will have conversions to each of them. * * @author Ignasi Barrera */ @Singleton -public class FindCompatibleVirtualDatacentersForImageAndConversions implements - FindCompatibleVirtualDatacenters -{ - private final RestContext context; +public class FindCompatibleVirtualDatacentersForImageAndConversions implements FindCompatibleVirtualDatacenters { + private final RestContext context; - private final CloudService cloudService; + private final CloudService cloudService; - @Inject - public FindCompatibleVirtualDatacentersForImageAndConversions( - final RestContext context, final CloudService cloudService) - { - this.context = checkNotNull(context, "context"); - this.cloudService = checkNotNull(cloudService, "cloudService"); - } + @Inject + public FindCompatibleVirtualDatacentersForImageAndConversions(final RestContext context, + final CloudService cloudService) { + this.context = checkNotNull(context, "context"); + this.cloudService = checkNotNull(cloudService, "cloudService"); + } - @Override - public Iterable execute(final VirtualMachineTemplate template) - { - // Build the transport object with the available information to avoid making an unnecessary - // call to the target API (we only need the id of the datacenter, and it is present in the - // link). - DatacenterDto datacenterDto = new DatacenterDto(); - datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY)); - Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto); + @Override + public Iterable execute(final VirtualMachineTemplate template) { + // Build the transport object with the available information to avoid + // making an unnecessary call to the target API (we only need the id of + // the datacenter, and it is present in the link). + DatacenterDto datacenterDto = new DatacenterDto(); + datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY)); + Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto); - Iterable vdcs = - cloudService.listVirtualDatacenters(VirtualDatacenterPredicates.datacenter(datacenter)); + Iterable vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates + .datacenter(datacenter)); - return filter(vdcs, compatibleWithTemplateOrConversions(template)); - } + return filter(vdcs, compatibleWithTemplateOrConversions(template)); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java index f0e25b73ab..862bb0bbd2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/compute/strategy/internal/FindCompatibleVirtualDatacentersForImageBaseFormat.java @@ -41,54 +41,49 @@ import com.abiquo.server.core.infrastructure.DatacenterDto; import com.google.common.base.Predicate; /** - * Implementation for the {@link FindCompatibleVirtualDatacenters} strategy to be used in - * homogeneous datacenters. + * Implementation for the {@link FindCompatibleVirtualDatacenters} strategy to + * be used in homogeneous datacenters. *

- * For providers that only have one hypervisor technology in the physical datacenter and use - * compatible images, there is no need to check if the images have conversions to other formats. + * For providers that only have one hypervisor technology in the physical + * datacenter and use compatible images, there is no need to check if the images + * have conversions to other formats. *

* This strategy will only consider the base disk format of the image. * * @author Ignasi Barrera */ @Singleton -public class FindCompatibleVirtualDatacentersForImageBaseFormat implements - FindCompatibleVirtualDatacenters -{ - private final RestContext context; +public class FindCompatibleVirtualDatacentersForImageBaseFormat implements FindCompatibleVirtualDatacenters { + private final RestContext context; - private final CloudService cloudService; + private final CloudService cloudService; - @Inject - public FindCompatibleVirtualDatacentersForImageBaseFormat( - final RestContext context, final CloudService cloudService) - { - this.context = checkNotNull(context, "context"); - this.cloudService = checkNotNull(cloudService, "cloudService"); - } + @Inject + public FindCompatibleVirtualDatacentersForImageBaseFormat(final RestContext context, + final CloudService cloudService) { + this.context = checkNotNull(context, "context"); + this.cloudService = checkNotNull(cloudService, "cloudService"); + } - @Override - public Iterable execute(final VirtualMachineTemplate template) - { - // Build the transport object with the available information to avoid making an unnecessary - // call to the target API (we only need the id of the datacenter, and it is present in the - // link). - DatacenterDto datacenterDto = new DatacenterDto(); - datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY)); - Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto); + @Override + public Iterable execute(final VirtualMachineTemplate template) { + // Build the transport object with the available information to avoid + // making an unnecessary call to the target API (we only need the id of + // the datacenter, and it is present in the link). + DatacenterDto datacenterDto = new DatacenterDto(); + datacenterDto.setId(template.unwrap().getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY)); + Datacenter datacenter = wrap(context, Datacenter.class, datacenterDto); - Iterable vdcs = - cloudService.listVirtualDatacenters(VirtualDatacenterPredicates.datacenter(datacenter)); + Iterable vdcs = cloudService.listVirtualDatacenters(VirtualDatacenterPredicates + .datacenter(datacenter)); - return filter(vdcs, new Predicate() - { - @Override - public boolean apply(final VirtualDatacenter vdc) - { - HypervisorType type = vdc.getHypervisorType(); - return type.isCompatible(template.getDiskFormatType()); - } - }); - } + return filter(vdcs, new Predicate() { + @Override + public boolean apply(final VirtualDatacenter vdc) { + HypervisorType type = vdc.getHypervisorType(); + return type.isCompatible(template.getDiskFormatType()); + } + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoEdition.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoEdition.java index c7c88f1630..158b0f5f60 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoEdition.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoEdition.java @@ -24,7 +24,6 @@ package org.jclouds.abiquo.config; * * @author Francesc Montserrat */ -public enum AbiquoEdition -{ - ENTERPRISE, COMMUNITY; +public enum AbiquoEdition { + ENTERPRISE, COMMUNITY; } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoProperties.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoProperties.java index bf98bc50ec..ab04c893f3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoProperties.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoProperties.java @@ -26,20 +26,19 @@ import org.jclouds.abiquo.features.services.MonitoringService; * * @author Ignasi Barrera */ -public interface AbiquoProperties -{ - /** - * Boolean property indicating if the provided credential is an api token. - *

- * Default value: false - */ - public static final String CREDENTIAL_IS_TOKEN = "abiquo.credential-is-token"; +public interface AbiquoProperties { + /** + * Boolean property indicating if the provided credential is an api token. + *

+ * Default value: false + */ + public static final String CREDENTIAL_IS_TOKEN = "abiquo.credential-is-token"; - /** - * The delay (in ms) used between requests by the {@link MonitoringService} when monitoring - * asynchronous task state. - *

- * Default value: 5000 ms - */ - public static final String ASYNC_TASK_MONITOR_DELAY = "abiquo.monitor-delay"; + /** + * The delay (in ms) used between requests by the {@link MonitoringService} + * when monitoring asynchronous task state. + *

+ * Default value: 5000 ms + */ + public static final String ASYNC_TASK_MONITOR_DELAY = "abiquo.monitor-delay"; } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoRestClientModule.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoRestClientModule.java index a15e53e931..c5baf05f9c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoRestClientModule.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/config/AbiquoRestClientModule.java @@ -83,131 +83,103 @@ import com.google.inject.Singleton; * @author Ignasi Barrera */ @ConfiguresRestClient -public class AbiquoRestClientModule extends RestClientModule -{ - public static final Map, Class< ? >> DELEGATE_MAP = ImmutableMap - ., Class< ? >> builder() // - .put(InfrastructureApi.class, InfrastructureAsyncApi.class) // - .put(EnterpriseApi.class, EnterpriseAsyncApi.class) // - .put(AdminApi.class, AdminAsyncApi.class) // - .put(ConfigApi.class, ConfigAsyncApi.class) // - .put(CloudApi.class, CloudAsyncApi.class) // - .put(VirtualMachineTemplateApi.class, VirtualMachineTemplateAsyncApi.class) // - .put(TaskApi.class, TaskAsyncApi.class) // - .put(EventApi.class, EventAsyncApi.class) // - .put(PricingApi.class, PricingAsyncApi.class) // - .build(); +public class AbiquoRestClientModule extends RestClientModule { + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() // + .put(InfrastructureApi.class, InfrastructureAsyncApi.class) // + .put(EnterpriseApi.class, EnterpriseAsyncApi.class) // + .put(AdminApi.class, AdminAsyncApi.class) // + .put(ConfigApi.class, ConfigAsyncApi.class) // + .put(CloudApi.class, CloudAsyncApi.class) // + .put(VirtualMachineTemplateApi.class, VirtualMachineTemplateAsyncApi.class) // + .put(TaskApi.class, TaskAsyncApi.class) // + .put(EventApi.class, EventAsyncApi.class) // + .put(PricingApi.class, PricingAsyncApi.class) // + .build(); - public AbiquoRestClientModule() - { - super(DELEGATE_MAP); - } + public AbiquoRestClientModule() { + super(DELEGATE_MAP); + } - @Override - protected void bindAsyncClient() - { - super.bindAsyncClient(); - BinderUtils.bindAsyncClient(binder(), AbiquoHttpAsyncClient.class); - } + @Override + protected void bindAsyncClient() { + super.bindAsyncClient(); + BinderUtils.bindAsyncClient(binder(), AbiquoHttpAsyncClient.class); + } - @Override - protected void bindClient() - { - super.bindClient(); - BinderUtils.bindClient(binder(), AbiquoHttpClient.class, AbiquoHttpAsyncClient.class, - ImmutableMap., Class< ? >> of(AbiquoHttpClient.class, - AbiquoHttpAsyncClient.class)); - } + @Override + protected void bindClient() { + super.bindClient(); + BinderUtils.bindClient(binder(), AbiquoHttpClient.class, AbiquoHttpAsyncClient.class, + ImmutableMap., Class> of(AbiquoHttpClient.class, AbiquoHttpAsyncClient.class)); + } - @Override - protected void configure() - { - super.configure(); - bind(Utils.class).to(ExtendedUtils.class); - } + @Override + protected void configure() { + super.configure(); + bind(Utils.class).to(ExtendedUtils.class); + } - @Override - protected void bindErrorHandlers() - { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AbiquoErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AbiquoErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AbiquoErrorHandler.class); - } + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AbiquoErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AbiquoErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AbiquoErrorHandler.class); + } - @Provides - @Singleton - @Memoized - public Supplier getCurrentUser( - final AtomicReference authException, - @Named(PROPERTY_SESSION_INTERVAL) final long seconds, - final RestContext context) - { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, - new Supplier() - { - @Override - public User get() - { - return wrap(context, User.class, context.getApi().getAdminApi() - .getCurrentUser()); - } + @Provides + @Singleton + @Memoized + public Supplier getCurrentUser(final AtomicReference authException, + @Named(PROPERTY_SESSION_INTERVAL) final long seconds, final RestContext context) { + return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, new Supplier() { + @Override + public User get() { + return wrap(context, User.class, context.getApi().getAdminApi().getCurrentUser()); + } + }, seconds, TimeUnit.SECONDS); + } + + @Provides + @Singleton + @Memoized + public Supplier getCurrentEnterprise(final AtomicReference authException, + @Named(PROPERTY_SESSION_INTERVAL) final long seconds, final @Memoized Supplier currentUser) { + return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, + new Supplier() { + @Override + public Enterprise get() { + return currentUser.get().getEnterprise(); + } }, seconds, TimeUnit.SECONDS); - } + } - @Provides - @Singleton - @Memoized - public Supplier getCurrentEnterprise( - final AtomicReference authException, - @Named(PROPERTY_SESSION_INTERVAL) final long seconds, - final @Memoized Supplier currentUser) - { - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, - new Supplier() - { - @Override - public Enterprise get() - { - return currentUser.get().getEnterprise(); - } - }, seconds, TimeUnit.SECONDS); - } - - @Provides - @Singleton - @Memoized - public Supplier> getAvailableRegionsIndexedById( - final AtomicReference authException, - @Named(PROPERTY_SESSION_INTERVAL) final long seconds, - @Memoized final Supplier currentEnterprise) - { - Supplier> availableRegionsMapSupplier = - Suppliers2.compose(new Function, Map>() - { - @Override - public Map apply(final List datacenters) - { - // Index available regions by id - return Maps.uniqueIndex(datacenters, new Function() - { - @Override - public Integer apply(final Datacenter input) - { - return input.getId(); - } - }); - } - }, new Supplier>() - { - @Override - public List get() - { - // Get the list of regions available for the user's tenant - return currentEnterprise.get().listAllowedDatacenters(); - } + @Provides + @Singleton + @Memoized + public Supplier> getAvailableRegionsIndexedById( + final AtomicReference authException, + @Named(PROPERTY_SESSION_INTERVAL) final long seconds, @Memoized final Supplier currentEnterprise) { + Supplier> availableRegionsMapSupplier = Suppliers2.compose( + new Function, Map>() { + @Override + public Map apply(final List datacenters) { + // Index available regions by id + return Maps.uniqueIndex(datacenters, new Function() { + @Override + public Integer apply(final Datacenter input) { + return input.getId(); + } + }); + } + }, new Supplier>() { + @Override + public List get() { + // Get the list of regions available for the user's tenant + return currentEnterprise.get().listAllowedDatacenters(); + } }); - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, + return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, availableRegionsMapSupplier, seconds, TimeUnit.SECONDS); - } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithLimitsWrapper.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithLimitsWrapper.java index 6983299bf1..82cddcd393 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithLimitsWrapper.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithLimitsWrapper.java @@ -19,8 +19,6 @@ package org.jclouds.abiquo.domain; - - import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.rest.RestContext; @@ -28,168 +26,136 @@ import org.jclouds.rest.RestContext; import com.abiquo.model.transport.SingleResourceWithLimitsDto; /** - * This class is used to decorate transport objects that have limits with high level functionality. + * This class is used to decorate transport objects that have limits with high + * level functionality. * * @author Ignasi Barrera */ -public abstract class DomainWithLimitsWrapper extends - DomainWrapper -{ +public abstract class DomainWithLimitsWrapper extends DomainWrapper { - protected DomainWithLimitsWrapper(final RestContext context, final T target) - { - super(context, target); - } + protected DomainWithLimitsWrapper(final RestContext context, final T target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public int getCpuCountHardLimit() - { - return target.getCpuCountHardLimit(); - } + public int getCpuCountHardLimit() { + return target.getCpuCountHardLimit(); + } - public int getCpuCountSoftLimit() - { - return target.getCpuCountSoftLimit(); - } + public int getCpuCountSoftLimit() { + return target.getCpuCountSoftLimit(); + } - public long getHdHardLimitInMb() - { - return target.getHdHardLimitInMb(); - } + public long getHdHardLimitInMb() { + return target.getHdHardLimitInMb(); + } - public long getHdSoftLimitInMb() - { - return target.getHdSoftLimitInMb(); - } + public long getHdSoftLimitInMb() { + return target.getHdSoftLimitInMb(); + } - public long getPublicIpsHard() - { - return target.getPublicIpsHard(); - } + public long getPublicIpsHard() { + return target.getPublicIpsHard(); + } - public long getPublicIpsSoft() - { - return target.getPublicIpsSoft(); - } + public long getPublicIpsSoft() { + return target.getPublicIpsSoft(); + } - public int getRamHardLimitInMb() - { - return target.getRamHardLimitInMb(); - } + public int getRamHardLimitInMb() { + return target.getRamHardLimitInMb(); + } - public int getRamSoftLimitInMb() - { - return target.getRamSoftLimitInMb(); - } + public int getRamSoftLimitInMb() { + return target.getRamSoftLimitInMb(); + } - public long getStorageHard() - { - return target.getStorageHard(); - } + public long getStorageHard() { + return target.getStorageHard(); + } - public long getStorageSoft() - { - return target.getStorageSoft(); - } + public long getStorageSoft() { + return target.getStorageSoft(); + } - public long getVlansHard() - { - return target.getVlansHard(); - } + public long getVlansHard() { + return target.getVlansHard(); + } - public long getVlansSoft() - { - return target.getVlansSoft(); - } + public long getVlansSoft() { + return target.getVlansSoft(); + } - public void setCpuCountHardLimit(final int cpuCountHardLimit) - { - target.setCpuCountHardLimit(cpuCountHardLimit); - } + public void setCpuCountHardLimit(final int cpuCountHardLimit) { + target.setCpuCountHardLimit(cpuCountHardLimit); + } - public void setCpuCountLimits(final int softLimit, final int hardLimit) - { - target.setCpuCountLimits(softLimit, hardLimit); - } + public void setCpuCountLimits(final int softLimit, final int hardLimit) { + target.setCpuCountLimits(softLimit, hardLimit); + } - public void setCpuCountSoftLimit(final int cpuCountSoftLimit) - { - target.setCpuCountSoftLimit(cpuCountSoftLimit); - } + public void setCpuCountSoftLimit(final int cpuCountSoftLimit) { + target.setCpuCountSoftLimit(cpuCountSoftLimit); + } - public void setHdHardLimitInMb(final long hdHardLimitInMb) - { - target.setHdHardLimitInMb(hdHardLimitInMb); - } + public void setHdHardLimitInMb(final long hdHardLimitInMb) { + target.setHdHardLimitInMb(hdHardLimitInMb); + } - public void setHdLimitsInMb(final long softLimit, final long hardLimit) - { - target.setHdLimitsInMb(softLimit, hardLimit); - } + public void setHdLimitsInMb(final long softLimit, final long hardLimit) { + target.setHdLimitsInMb(softLimit, hardLimit); + } - public void setHdSoftLimitInMb(final long hdSoftLimitInMb) - { - target.setHdSoftLimitInMb(hdSoftLimitInMb); - } + public void setHdSoftLimitInMb(final long hdSoftLimitInMb) { + target.setHdSoftLimitInMb(hdSoftLimitInMb); + } - public void setPublicIPLimits(final long softLimit, final long hardLimit) - { - target.setPublicIPLimits(softLimit, hardLimit); - } + public void setPublicIPLimits(final long softLimit, final long hardLimit) { + target.setPublicIPLimits(softLimit, hardLimit); + } - public void setPublicIpsHard(final long publicIpsHard) - { - target.setPublicIpsHard(publicIpsHard); - } + public void setPublicIpsHard(final long publicIpsHard) { + target.setPublicIpsHard(publicIpsHard); + } - public void setPublicIpsSoft(final long publicIpsSoft) - { - target.setPublicIpsSoft(publicIpsSoft); - } + public void setPublicIpsSoft(final long publicIpsSoft) { + target.setPublicIpsSoft(publicIpsSoft); + } - public void setRamHardLimitInMb(final int ramHardLimitInMb) - { - target.setRamHardLimitInMb(ramHardLimitInMb); - } + public void setRamHardLimitInMb(final int ramHardLimitInMb) { + target.setRamHardLimitInMb(ramHardLimitInMb); + } - public void setRamLimitsInMb(final int softLimit, final int hardLimit) - { - target.setRamLimitsInMb(softLimit, hardLimit); - } + public void setRamLimitsInMb(final int softLimit, final int hardLimit) { + target.setRamLimitsInMb(softLimit, hardLimit); + } - public void setRamSoftLimitInMb(final int ramSoftLimitInMb) - { - target.setRamSoftLimitInMb(ramSoftLimitInMb); - } + public void setRamSoftLimitInMb(final int ramSoftLimitInMb) { + target.setRamSoftLimitInMb(ramSoftLimitInMb); + } - public void setStorageHard(final long storageHard) - { - target.setStorageHard(storageHard); - } + public void setStorageHard(final long storageHard) { + target.setStorageHard(storageHard); + } - public void setStorageLimits(final long softLimit, final long hardLimit) - { - target.setStorageLimits(softLimit, hardLimit); - } + public void setStorageLimits(final long softLimit, final long hardLimit) { + target.setStorageLimits(softLimit, hardLimit); + } - public void setStorageSoft(final long storageSoft) - { - target.setStorageSoft(storageSoft); - } + public void setStorageSoft(final long storageSoft) { + target.setStorageSoft(storageSoft); + } - public void setVlansHard(final long vlansHard) - { - target.setVlansHard(vlansHard); - } + public void setVlansHard(final long vlansHard) { + target.setVlansHard(vlansHard); + } - public void setVlansLimits(final long softLimit, final long hardLimit) - { - target.setVlansLimits(softLimit, hardLimit); - } + public void setVlansLimits(final long softLimit, final long hardLimit) { + target.setVlansLimits(softLimit, hardLimit); + } - public void setVlansSoft(final long vlansSoft) - { - target.setVlansSoft(vlansSoft); - } + public void setVlansSoft(final long vlansSoft) { + target.setVlansSoft(vlansSoft); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java index 0a599e6423..26383ea14b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWithTasksWrapper.java @@ -39,45 +39,37 @@ import com.google.common.collect.Ordering; import com.google.common.primitives.Longs; /** - * This class is used to decorate transport objects that are owners of some {@link TaskDto} + * This class is used to decorate transport objects that are owners of some + * {@link TaskDto} * * @author Ignasi Barrera */ -public abstract class DomainWithTasksWrapper extends - DomainWrapper -{ +public abstract class DomainWithTasksWrapper extends DomainWrapper { - protected DomainWithTasksWrapper(final RestContext context, - final T target) - { - super(context, target); - } + protected DomainWithTasksWrapper(final RestContext context, final T target) { + super(context, target); + } - public List listTasks() - { - TasksDto result = context.getApi().getTaskApi().listTasks(target); - List tasks = wrap(context, AsyncTask.class, result.getCollection()); + public List listTasks() { + TasksDto result = context.getApi().getTaskApi().listTasks(target); + List tasks = wrap(context, AsyncTask.class, result.getCollection()); - // Return the most recent task first - Collections.sort(tasks, new Ordering() - { - @Override - public int compare(final AsyncTask left, final AsyncTask right) - { - return Longs.compare(left.getTimestamp(), right.getTimestamp()); - } - }.reverse()); + // Return the most recent task first + Collections.sort(tasks, new Ordering() { + @Override + public int compare(final AsyncTask left, final AsyncTask right) { + return Longs.compare(left.getTimestamp(), right.getTimestamp()); + } + }.reverse()); - return tasks; - } + return tasks; + } - public List listTasks(final Predicate filter) - { - return Lists.newLinkedList(filter(listTasks(), filter)); - } + public List listTasks(final Predicate filter) { + return Lists.newLinkedList(filter(listTasks(), filter)); + } - public AsyncTask findTask(final Predicate filter) - { - return Iterables.getFirst(filter(listTasks(), filter), null); - } + public AsyncTask findTask(final Predicate filter) { + return Iterables.getFirst(filter(listTasks(), filter), null); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWrapper.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWrapper.java index 7ae35dc626..baca65bc4a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWrapper.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/DomainWrapper.java @@ -44,198 +44,173 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; /** - * This class is used to decorate transport objects with high level functionality. + * This class is used to decorate transport objects with high level + * functionality. * * @author Francesc Montserrat * @author Ignasi Barrera */ -public abstract class DomainWrapper -{ - /** The rest context. */ - protected RestContext context; +public abstract class DomainWrapper { + /** The rest context. */ + protected RestContext context; - /** The wrapped object. */ - protected T target; + /** The wrapped object. */ + protected T target; - protected DomainWrapper(final RestContext context, - final T target) - { - super(); - this.context = checkNotNull(context, "context"); - this.target = checkNotNull(target, "target"); - } + protected DomainWrapper(final RestContext context, final T target) { + super(); + this.context = checkNotNull(context, "context"); + this.target = checkNotNull(target, "target"); + } - /** - * Returns the URI that identifies the transport object - * - * @return The URI identifying the transport object - */ - public URI getURI() - { - RESTLink link = LinkUtils.getSelfLink(target); - return link == null ? null : URI.create(link.getHref()); - } + /** + * Returns the URI that identifies the transport object + * + * @return The URI identifying the transport object + */ + public URI getURI() { + RESTLink link = LinkUtils.getSelfLink(target); + return link == null ? null : URI.create(link.getHref()); + } - /** - * Returns the wrapped object. - */ - public T unwrap() - { - return target; - } + /** + * Returns the wrapped object. + */ + public T unwrap() { + return target; + } - /** - * Read the ID of the parent resource from the given link. - * - * @param parentLinkRel The link to the parent resource. - * @return The ID of the parent resource. - */ - protected Integer getParentId(final String parentLinkRel) - { - return target.getIdFromLink(parentLinkRel); - } + /** + * Read the ID of the parent resource from the given link. + * + * @param parentLinkRel + * The link to the parent resource. + * @return The ID of the parent resource. + */ + protected Integer getParentId(final String parentLinkRel) { + return target.getIdFromLink(parentLinkRel); + } - /** - * Wraps an object in the given wrapper class. - */ - public static > W wrap( - final RestContext context, final Class wrapperClass, - final T target) - { - if (target == null) - { - return null; - } + /** + * Wraps an object in the given wrapper class. + */ + public static > W wrap( + final RestContext context, final Class wrapperClass, final T target) { + if (target == null) { + return null; + } - try - { - Constructor cons = - wrapperClass.getDeclaredConstructor(RestContext.class, target.getClass()); - if (!cons.isAccessible()) - { - cons.setAccessible(true); - } - return cons.newInstance(context, target); - } - catch (Exception ex) - { - throw new WrapperException(wrapperClass, target, ex); - } - } + try { + Constructor cons = wrapperClass.getDeclaredConstructor(RestContext.class, target.getClass()); + if (!cons.isAccessible()) { + cons.setAccessible(true); + } + return cons.newInstance(context, target); + } catch (Exception ex) { + throw new WrapperException(wrapperClass, target, ex); + } + } - /** - * Wrap a collection of objects to the given wrapper class. - */ - public static > List wrap( - final RestContext context, final Class wrapperClass, - final Iterable targets) - { - if (targets == null) - { - return null; - } + /** + * Wrap a collection of objects to the given wrapper class. + */ + public static > List wrap( + final RestContext context, final Class wrapperClass, final Iterable targets) { + if (targets == null) { + return null; + } - return Lists.newLinkedList(transform(targets, new Function() - { - @Override - public W apply(final T input) - { - return wrap(context, wrapperClass, input); - } - })); - } + return Lists.newLinkedList(transform(targets, new Function() { + @Override + public W apply(final T input) { + return wrap(context, wrapperClass, input); + } + })); + } - /** - * Unwrap a collection of objects. - */ - public static > List unwrap( - final Iterable targets) - { - return Lists.newLinkedList(transform(targets, new Function() - { - @Override - public T apply(final W input) - { - return input.unwrap(); - } - })); - } + /** + * Unwrap a collection of objects. + */ + public static > List unwrap( + final Iterable targets) { + return Lists.newLinkedList(transform(targets, new Function() { + @Override + public T apply(final W input) { + return input.unwrap(); + } + })); + } - /** - * Update or creates a link of "target" with the uri of a link from "source". - */ - protected void updateLink( - final T1 target, final String targetLinkRel, final T2 source, final String sourceLinkRel) - { - RESTLink parent = null; + /** + * Update or creates a link of "target" with the uri of a link from "source". + */ + protected void updateLink( + final T1 target, final String targetLinkRel, final T2 source, final String sourceLinkRel) { + RESTLink parent = null; - checkNotNull(source.searchLink(sourceLinkRel), ValidationErrors.MISSING_REQUIRED_LINK); + checkNotNull(source.searchLink(sourceLinkRel), ValidationErrors.MISSING_REQUIRED_LINK); - // Insert - if ((parent = target.searchLink(targetLinkRel)) == null) - { - target.addLink(new RESTLink(targetLinkRel, source.searchLink(sourceLinkRel).getHref())); - } - // Replace - else - { - parent.setHref(source.searchLink(sourceLinkRel).getHref()); - } - } + // Insert + if ((parent = target.searchLink(targetLinkRel)) == null) { + target.addLink(new RESTLink(targetLinkRel, source.searchLink(sourceLinkRel).getHref())); + } + // Replace + else { + parent.setHref(source.searchLink(sourceLinkRel).getHref()); + } + } - /** - * Join a collection of {@link WrapperDto} objects in a single collection with all the elements - * of each wrapper object. - */ - public static Iterable join( - final Iterable< ? extends WrapperDto> collection) - { - List dtos = Lists.newLinkedList(); - for (WrapperDto wrapper : collection) - { - dtos.addAll(wrapper.getCollection()); - } - return dtos; - } + /** + * Join a collection of {@link WrapperDto} objects in a single collection + * with all the elements of each wrapper object. + */ + public static Iterable join( + final Iterable> collection) { + List dtos = Lists.newLinkedList(); + for (WrapperDto wrapper : collection) { + dtos.addAll(wrapper.getCollection()); + } + return dtos; + } - /** - * Utility method to get an {@link AsyncTask} given an {@link AcceptedRequestDto}. - * - * @param acceptedRequest The accepted request dto. - * @return The async task. - */ - protected AsyncTask getTask(final AcceptedRequestDto acceptedRequest) - { - RESTLink taskLink = acceptedRequest.getStatusLink(); - checkNotNull(taskLink, ValidationErrors.MISSING_REQUIRED_LINK + AsyncTask.class); + /** + * Utility method to get an {@link AsyncTask} given an + * {@link AcceptedRequestDto}. + * + * @param acceptedRequest + * The accepted request dto. + * @return The async task. + */ + protected AsyncTask getTask(final AcceptedRequestDto acceptedRequest) { + RESTLink taskLink = acceptedRequest.getStatusLink(); + checkNotNull(taskLink, ValidationErrors.MISSING_REQUIRED_LINK + AsyncTask.class); - // This will return null on untrackable tasks - TaskDto task = context.getApi().getTaskApi().getTask(taskLink); - return wrap(context, AsyncTask.class, task); - } + // This will return null on untrackable tasks + TaskDto task = context.getApi().getTaskApi().getTask(taskLink); + return wrap(context, AsyncTask.class, task); + } - /** - * Utility method to get all {@link AsyncTask} related to an {@link AcceptedRequestDto}. - * - * @param acceptedRequest The accepted request dto. - * @return The async task array. - */ - protected AsyncTask[] getTasks(final AcceptedRequestDto acceptedRequest) - { - List tasks = new ArrayList(); + /** + * Utility method to get all {@link AsyncTask} related to an + * {@link AcceptedRequestDto}. + * + * @param acceptedRequest + * The accepted request dto. + * @return The async task array. + */ + protected AsyncTask[] getTasks(final AcceptedRequestDto acceptedRequest) { + List tasks = new ArrayList(); - for (RESTLink link : acceptedRequest.getLinks()) - { - // This will return null on untrackable tasks - TaskDto task = context.getApi().getTaskApi().getTask(link); - if (task != null) - { - tasks.add(wrap(context, AsyncTask.class, task)); - } - } + for (RESTLink link : acceptedRequest.getLinks()) { + // This will return null on untrackable tasks + TaskDto task = context.getApi().getTaskApi().getTask(link); + if (task != null) { + tasks.add(wrap(context, AsyncTask.class, task)); + } + } - AsyncTask[] taskArr = new AsyncTask[tasks.size()]; - return tasks.toArray(taskArr); - } + AsyncTask[] taskArr = new AsyncTask[tasks.size()]; + return tasks.toArray(taskArr); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/builder/LimitsBuilder.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/builder/LimitsBuilder.java index a3f045d57a..013e0a3c8c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/builder/LimitsBuilder.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/builder/LimitsBuilder.java @@ -23,82 +23,76 @@ package org.jclouds.abiquo.domain.builder; * Base class for all builders that represent limits. * * @author Ignasi Barrera - * @param The type of the target builder. + * @param + * The type of the target builder. */ -public abstract class LimitsBuilder> -{ - /** The default limits for enterprises (unlimited). */ - protected static final int DEFAULT_LIMITS = 0; +public abstract class LimitsBuilder> { + /** The default limits for enterprises (unlimited). */ + protected static final int DEFAULT_LIMITS = 0; - protected Integer ramSoftLimitInMb = DEFAULT_LIMITS; + protected Integer ramSoftLimitInMb = DEFAULT_LIMITS; - protected Integer ramHardLimitInMb = DEFAULT_LIMITS; + protected Integer ramHardLimitInMb = DEFAULT_LIMITS; - protected Integer cpuCountSoftLimit = DEFAULT_LIMITS; + protected Integer cpuCountSoftLimit = DEFAULT_LIMITS; - protected Integer cpuCountHardLimit = DEFAULT_LIMITS; + protected Integer cpuCountHardLimit = DEFAULT_LIMITS; - protected Long hdSoftLimitInMb = Long.valueOf(DEFAULT_LIMITS); + protected Long hdSoftLimitInMb = Long.valueOf(DEFAULT_LIMITS); - protected Long hdHardLimitInMb = Long.valueOf(DEFAULT_LIMITS); + protected Long hdHardLimitInMb = Long.valueOf(DEFAULT_LIMITS); - protected Long storageSoft = Long.valueOf(DEFAULT_LIMITS); + protected Long storageSoft = Long.valueOf(DEFAULT_LIMITS); - protected Long storageHard = Long.valueOf(DEFAULT_LIMITS); + protected Long storageHard = Long.valueOf(DEFAULT_LIMITS); - protected Long vlansSoft = Long.valueOf(DEFAULT_LIMITS); + protected Long vlansSoft = Long.valueOf(DEFAULT_LIMITS); - protected Long vlansHard = Long.valueOf(DEFAULT_LIMITS); + protected Long vlansHard = Long.valueOf(DEFAULT_LIMITS); - protected Long publicIpsSoft = Long.valueOf(DEFAULT_LIMITS); + protected Long publicIpsSoft = Long.valueOf(DEFAULT_LIMITS); - protected Long publicIpsHard = Long.valueOf(DEFAULT_LIMITS); + protected Long publicIpsHard = Long.valueOf(DEFAULT_LIMITS); - @SuppressWarnings("unchecked") - public T ramLimits(final int soft, final int hard) - { - this.ramSoftLimitInMb = soft; - this.ramHardLimitInMb = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T ramLimits(final int soft, final int hard) { + this.ramSoftLimitInMb = soft; + this.ramHardLimitInMb = hard; + return (T) this; + } - @SuppressWarnings("unchecked") - public T cpuCountLimits(final int soft, final int hard) - { - this.cpuCountSoftLimit = soft; - this.cpuCountHardLimit = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T cpuCountLimits(final int soft, final int hard) { + this.cpuCountSoftLimit = soft; + this.cpuCountHardLimit = hard; + return (T) this; + } - @SuppressWarnings("unchecked") - public T hdLimitsInMb(final long soft, final long hard) - { - this.hdSoftLimitInMb = soft; - this.hdHardLimitInMb = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T hdLimitsInMb(final long soft, final long hard) { + this.hdSoftLimitInMb = soft; + this.hdHardLimitInMb = hard; + return (T) this; + } - @SuppressWarnings("unchecked") - public T storageLimits(final long soft, final long hard) - { - this.storageSoft = soft; - this.storageHard = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T storageLimits(final long soft, final long hard) { + this.storageSoft = soft; + this.storageHard = hard; + return (T) this; + } - @SuppressWarnings("unchecked") - public T vlansLimits(final long soft, final long hard) - { - this.vlansSoft = soft; - this.vlansHard = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T vlansLimits(final long soft, final long hard) { + this.vlansSoft = soft; + this.vlansHard = hard; + return (T) this; + } - @SuppressWarnings("unchecked") - public T publicIpsLimits(final long soft, final long hard) - { - this.publicIpsSoft = soft; - this.publicIpsHard = hard; - return (T) this; - } + @SuppressWarnings("unchecked") + public T publicIpsLimits(final long soft, final long hard) { + this.publicIpsSoft = soft; + this.publicIpsHard = hard; + return (T) this; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Conversion.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Conversion.java index 1d8fbe3a7b..5564352624 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Conversion.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Conversion.java @@ -46,118 +46,100 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Conversion+Resource */ -public class Conversion extends DomainWithTasksWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Conversion(final RestContext context, - final ConversionDto target) - { - super(context, target); - } +public class Conversion extends DomainWithTasksWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Conversion(final RestContext context, final ConversionDto target) { + super(context, target); + } - // Domain methods + // Domain methods - public void refresh() - { - RESTLink link = - checkNotNull(target.searchLink("edit"), ValidationErrors.MISSING_REQUIRED_LINK + "edit"); + public void refresh() { + RESTLink link = checkNotNull(target.searchLink("edit"), ValidationErrors.MISSING_REQUIRED_LINK + "edit"); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = checkNotNull(utils.getAbiquoHttpClient().get(link), "conversion"); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = checkNotNull(utils.getAbiquoHttpClient().get(link), "conversion"); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(ConversionDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(ConversionDto.class)); - target = parser.apply(response); - } + target = parser.apply(response); + } - // Parent access + // Parent access - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource - */ - public VirtualMachineTemplate getVirtualMachineTemplate() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE), - ValidationErrors.MISSING_REQUIRED_LINK + " " - + ParentLinkName.VIRTUAL_MACHINE_TEMPLATE); + /** + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+ + * Resource + */ + public VirtualMachineTemplate getVirtualMachineTemplate() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.VIRTUAL_MACHINE_TEMPLATE); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VirtualMachineTemplateDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB( + utils.getXml(), TypeLiteral.get(VirtualMachineTemplateDto.class)); - return wrap(context, VirtualMachineTemplate.class, parser.apply(response)); - } + return wrap(context, VirtualMachineTemplate.class, parser.apply(response)); + } - /** - * Starts a new BPM task to regenerate a failed conversion. - * - * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource- - * UpdateConversion - * @return The task reference to track its progress - */ - public AsyncTask restartFailedConversion() - { - return getVirtualMachineTemplate().requestConversion(getTargetFormat()); - } + /** + * Starts a new BPM task to regenerate a failed conversion. + * + * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource# + * ConversionResource- UpdateConversion + * @return The task reference to track its progress + */ + public AsyncTask restartFailedConversion() { + return getVirtualMachineTemplate().requestConversion(getTargetFormat()); + } - // Delegate methods + // Delegate methods - public String getSourcePath() - { - return target.getSourcePath(); - } + public String getSourcePath() { + return target.getSourcePath(); + } - public ConversionState getState() - { - return target.getState(); - } + public ConversionState getState() { + return target.getState(); + } - public String getTargetPath() - { - return target.getTargetPath(); - } + public String getTargetPath() { + return target.getTargetPath(); + } - public Long getTargetSizeInBytes() - { - return target.getTargetSizeInBytes(); - } + public Long getTargetSizeInBytes() { + return target.getTargetSizeInBytes(); + } - public DiskFormatType getSourceFormat() - { - return target.getSourceFormat(); - } + public DiskFormatType getSourceFormat() { + return target.getSourceFormat(); + } - public DiskFormatType getTargetFormat() - { - return target.getTargetFormat(); - } + public DiskFormatType getTargetFormat() { + return target.getTargetFormat(); + } - public Date getStartTimestamp() - { - return target.getStartTimestamp(); - } + public Date getStartTimestamp() { + return target.getStartTimestamp(); + } - @Override - public String toString() - { - return "Conversion [sourcePath=" + getSourcePath() + ", sourceFormat=" + getSourceFormat() - + ", targetPath=" + getTargetPath() + ", targetFormat=" + getTargetFormat() - + ", targetSizeInBytes=" + getTargetSizeInBytes() + ", startTimestamp=" - + getStartTimestamp() + ", state=" + getState() + "]"; - } + @Override + public String toString() { + return "Conversion [sourcePath=" + getSourcePath() + ", sourceFormat=" + getSourceFormat() + ", targetPath=" + + getTargetPath() + ", targetFormat=" + getTargetFormat() + ", targetSizeInBytes=" + getTargetSizeInBytes() + + ", startTimestamp=" + getStartTimestamp() + ", state=" + getState() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/HardDisk.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/HardDisk.java index 7a4af28eb5..81d9af7072 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/HardDisk.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/HardDisk.java @@ -34,148 +34,131 @@ import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; /** * Represents a disk attached to a virtual machine. *

- * This disks will be created when a virtual machine is deployed, and will be destroyed when it is - * undeployed. If there is a need to use persistent storage, a persistent {@link Volume} should be - * used instead. + * This disks will be created when a virtual machine is deployed, and will be + * destroyed when it is undeployed. If there is a need to use persistent + * storage, a persistent {@link Volume} should be used instead. * * @author Ignasi Barrera - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Hard+Disks+Resource */ -public class HardDisk extends DomainWrapper -{ - /** The virtual datacenter where the hard disk belongs. */ - private VirtualDatacenter virtualDatacenter; +public class HardDisk extends DomainWrapper { + /** The virtual datacenter where the hard disk belongs. */ + private VirtualDatacenter virtualDatacenter; - /** - * Constructor to be used only by the builder. - */ - protected HardDisk(final RestContext context, - final DiskManagementDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected HardDisk(final RestContext context, final DiskManagementDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Creates the hard disk in the selected virtual datacenter. - *

- * Once the hard disk has been created it can be attached to a virtual machine of the virtual - * datacenter. - */ - public void save() - { - target = context.getApi().getCloudApi().createHardDisk(virtualDatacenter.unwrap(), target); - } + /** + * Creates the hard disk in the selected virtual datacenter. + *

+ * Once the hard disk has been created it can be attached to a virtual + * machine of the virtual datacenter. + */ + public void save() { + target = context.getApi().getCloudApi().createHardDisk(virtualDatacenter.unwrap(), target); + } - /** - * Deletes the hard disk. - */ - public void delete() - { - context.getApi().getCloudApi().deleteHardDisk(target); - target = null; - } + /** + * Deletes the hard disk. + */ + public void delete() { + context.getApi().getCloudApi().deleteHardDisk(target); + target = null; + } - // Parent access + // Parent access - /** - * Gets the virtual datacenter where the hard disk belongs to. - * - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-RetrieveaVirtualDatacenter - */ - public VirtualDatacenter getVirtualDatacenter() - { - Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); - VirtualDatacenterDto dto = - context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); - virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); - return virtualDatacenter; - } + /** + * Gets the virtual datacenter where the hard disk belongs to. + * + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter + */ + public VirtualDatacenter getVirtualDatacenter() { + Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); + VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); + virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); + return virtualDatacenter; + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) - { - return new Builder(context, virtualDatacenter); - } + public static Builder builder(final RestContext context, + final VirtualDatacenter virtualDatacenter) { + return new Builder(context, virtualDatacenter); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Long sizeInMb; + private Long sizeInMb; - private VirtualDatacenter virtualDatacenter; + private VirtualDatacenter virtualDatacenter; - public Builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) - { - super(); - checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE - + VirtualDatacenter.class); - this.context = context; - this.virtualDatacenter = virtualDatacenter; - } + public Builder(final RestContext context, final VirtualDatacenter virtualDatacenter) { + super(); + checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class); + this.context = context; + this.virtualDatacenter = virtualDatacenter; + } - public Builder sizeInMb(final long sizeInMb) - { - this.sizeInMb = sizeInMb; - return this; - } + public Builder sizeInMb(final long sizeInMb) { + this.sizeInMb = sizeInMb; + return this; + } - public HardDisk build() - { - DiskManagementDto dto = new DiskManagementDto(); - dto.setSizeInMb(sizeInMb); + public HardDisk build() { + DiskManagementDto dto = new DiskManagementDto(); + dto.setSizeInMb(sizeInMb); - HardDisk hardDisk = new HardDisk(context, dto); - hardDisk.virtualDatacenter = virtualDatacenter; + HardDisk hardDisk = new HardDisk(context, dto); + hardDisk.virtualDatacenter = virtualDatacenter; - return hardDisk; - } - } + return hardDisk; + } + } - // Delegate methods. Since a hard disk cannot be edited, setters are not visible + // Delegate methods. Since a hard disk cannot be edited, setters are not + // visible - /** - * Returns the id of the hard disk. - */ - public Integer getId() - { - // TODO: DiskManagementDto does not have an id field - return target.getEditLink() == null ? null : target.getIdFromLink("edit"); - } + /** + * Returns the id of the hard disk. + */ + public Integer getId() { + // TODO: DiskManagementDto does not have an id field + return target.getEditLink() == null ? null : target.getIdFromLink("edit"); + } - /** - * Returns the size of the hard disk in MB. - */ - public Long getSizeInMb() - { - return target.getSizeInMb(); - } + /** + * Returns the size of the hard disk in MB. + */ + public Long getSizeInMb() { + return target.getSizeInMb(); + } - /** - * Returns the sequence number of the hard disk. - *

- * It will be computed when attaching the hard disk to a virtual machine and will determine the - * attachment order of the disk in the virtual machine. - */ - public Integer getSequence() - { - return target.getSequence(); - } + /** + * Returns the sequence number of the hard disk. + *

+ * It will be computed when attaching the hard disk to a virtual machine and + * will determine the attachment order of the disk in the virtual machine. + */ + public Integer getSequence() { + return target.getSequence(); + } - @Override - public String toString() - { - return "HardDisk [id=" + getId() + ", sizeInMb=" + getSizeInMb() + ", sequence=" - + getSequence() + "]"; - } + @Override + public String toString() { + return "HardDisk [id=" + getId() + ", sizeInMb=" + getSizeInMb() + ", sequence=" + getSequence() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java index 2aaa34cd4b..3d52dadf31 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualAppliance.java @@ -50,364 +50,333 @@ import com.google.common.collect.Lists; /** * Represents a virtual appliance. *

- * A virtual appliance is a logic container for virtual machines that together make an appliance. + * A virtual appliance is a logic container for virtual machines that together + * make an appliance. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource */ -public class VirtualAppliance extends DomainWrapper -{ - /** The virtual datacenter where the virtual appliance belongs. */ - private VirtualDatacenter virtualDatacenter; +public class VirtualAppliance extends DomainWrapper { + /** The virtual datacenter where the virtual appliance belongs. */ + private VirtualDatacenter virtualDatacenter; - /** - * Constructor to be used only by the builder. - */ - protected VirtualAppliance(final RestContext context, - final VirtualApplianceDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected VirtualAppliance(final RestContext context, final VirtualApplianceDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Deletes the virtual appliance. - */ - public void delete() - { - context.getApi().getCloudApi().deleteVirtualAppliance(target); - target = null; - } + /** + * Deletes the virtual appliance. + */ + public void delete() { + context.getApi().getCloudApi().deleteVirtualAppliance(target); + target = null; + } - /** - * Creates the virtual appliance in the selected virtual datacenter. - */ - public void save() - { - target = - context.getApi().getCloudApi() - .createVirtualAppliance(virtualDatacenter.unwrap(), target); - } + /** + * Creates the virtual appliance in the selected virtual datacenter. + */ + public void save() { + target = context.getApi().getCloudApi().createVirtualAppliance(virtualDatacenter.unwrap(), target); + } - /** - * Updates the virtual appliance information when some of its properties have changed. - */ - public void update() - { - target = context.getApi().getCloudApi().updateVirtualAppliance(target); - } + /** + * Updates the virtual appliance information when some of its properties have + * changed. + */ + public void update() { + target = context.getApi().getCloudApi().updateVirtualAppliance(target); + } - // Parent access + // Parent access - /** - * Gets the virtual datacenter where the virtual appliance belongs to. - * - * @resturn The virtual datacenter where the virtual appliance belongs to. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-RetrieveaVirtualDatacenter - */ - public VirtualDatacenter getVirtualDatacenter() - { - Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); - VirtualDatacenterDto dto = - context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); - virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); - return virtualDatacenter; - } + /** + * Gets the virtual datacenter where the virtual appliance belongs to. + * + * @resturn The virtual datacenter where the virtual appliance belongs to. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter + */ + public VirtualDatacenter getVirtualDatacenter() { + Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); + VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); + virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); + return virtualDatacenter; + } - /** - * Gets the enterprise where the virtual appliance belongs to. - * - * @return The enterprise where the virtual appliance belongs to. - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * RetrieveaEnterprise - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); - return wrap(context, Enterprise.class, dto); - } + /** + * Gets the enterprise where the virtual appliance belongs to. + * + * @return The enterprise where the virtual appliance belongs to. + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- RetrieveaEnterprise + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); + return wrap(context, Enterprise.class, dto); + } - /** - * Gets the current state of the virtual appliance. - * - * @return The current state of the virtual appliance. - */ - public VirtualApplianceState getState() - { - VirtualApplianceStateDto stateDto = - context.getApi().getCloudApi().getVirtualApplianceState(target); - return stateDto.getPower(); - } + /** + * Gets the current state of the virtual appliance. + * + * @return The current state of the virtual appliance. + */ + public VirtualApplianceState getState() { + VirtualApplianceStateDto stateDto = context.getApi().getCloudApi().getVirtualApplianceState(target); + return stateDto.getPower(); + } - // Children access + // Children access - /** - * Gets the list of virtual machines in the virtual appliance. - * - * @return The list of virtual machines in the virtual appliance. - * @see API: - * http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource - * -RetrievethelistofVirtualMachines. - */ - public List listVirtualMachines() - { - return listVirtualMachines(VirtualMachineOptions.builder().disablePagination().build()); - } + /** + * Gets the list of virtual machines in the virtual appliance. + * + * @return The list of virtual machines in the virtual appliance. + * @see API: http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource# + * VirtualMachineResource -RetrievethelistofVirtualMachines. + */ + public List listVirtualMachines() { + return listVirtualMachines(VirtualMachineOptions.builder().disablePagination().build()); + } - /** - * Gets the list of virtual machines in the virtual appliance. - * - * @return The list of virtual machines in the virtual appliance. - * @see API: - * http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource#VirtualMachineResource - * -RetrievethelistofVirtualMachines. - */ - public List listVirtualMachines(final VirtualMachineOptions options) - { - VirtualMachinesWithNodeExtendedDto vms = - context.getApi().getCloudApi().listVirtualMachines(target, options); - return wrap(context, VirtualMachine.class, vms.getCollection()); - } + /** + * Gets the list of virtual machines in the virtual appliance. + * + * @return The list of virtual machines in the virtual appliance. + * @see API: http://community.abiquo.com/display/ABI18/Virtual+Machine+Resource# + * VirtualMachineResource -RetrievethelistofVirtualMachines. + */ + public List listVirtualMachines(final VirtualMachineOptions options) { + VirtualMachinesWithNodeExtendedDto vms = context.getApi().getCloudApi().listVirtualMachines(target, options); + return wrap(context, VirtualMachine.class, vms.getCollection()); + } - /** - * Gets the list of virtual machines in the virtual appliance matching the given filter. - * - * @param filter The filter to apply. - * @return The list of virtual machines in the virtual appliance matching the given filter. - */ - public List listVirtualMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualMachines(), filter)); - } + /** + * Gets the list of virtual machines in the virtual appliance matching the + * given filter. + * + * @param filter + * The filter to apply. + * @return The list of virtual machines in the virtual appliance matching the + * given filter. + */ + public List listVirtualMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualMachines(), filter)); + } - /** - * Gets a single virtual machine in the virtual appliance matching the given filter. - * - * @param filter The filter to apply. - * @return The virtual machine or null if none matched the given filter. - */ - public VirtualMachine findVirtualMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } + /** + * Gets a single virtual machine in the virtual appliance matching the given + * filter. + * + * @param filter + * The filter to apply. + * @return The virtual machine or null if none matched the given + * filter. + */ + public VirtualMachine findVirtualMachine(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualMachines(), filter), null); + } - /** - * Gets a concrete virtual machine in the virtual appliance. - * - * @param id The id of the virtual machine. - * @return The requested virtual machine. - */ - public VirtualMachine getVirtualMachine(final Integer id) - { - VirtualMachineWithNodeExtendedDto vm = - context.getApi().getCloudApi().getVirtualMachine(target, id); - return wrap(context, VirtualMachine.class, vm); - } + /** + * Gets a concrete virtual machine in the virtual appliance. + * + * @param id + * The id of the virtual machine. + * @return The requested virtual machine. + */ + public VirtualMachine getVirtualMachine(final Integer id) { + VirtualMachineWithNodeExtendedDto vm = context.getApi().getCloudApi().getVirtualMachine(target, id); + return wrap(context, VirtualMachine.class, vm); + } - // Actions + // Actions - /** - * Deploys the virtual appliance. - *

- * This method will start the deployment of all the virtual machines in the virtual appliance, - * and will return an {@link AsyncTask} reference for each deployment operation. The deployment - * will finish when all individual tasks finish. - * - * @return The list of tasks corresponding to the deploy process of each virtual machine in the - * appliance. - */ - public AsyncTask[] deploy() - { - return deploy(false); - } + /** + * Deploys the virtual appliance. + *

+ * This method will start the deployment of all the virtual machines in the + * virtual appliance, and will return an {@link AsyncTask} reference for each + * deployment operation. The deployment will finish when all individual tasks + * finish. + * + * @return The list of tasks corresponding to the deploy process of each + * virtual machine in the appliance. + */ + public AsyncTask[] deploy() { + return deploy(false); + } - /** - * Deploys the virtual appliance. - *

- * This method will start the deployment of all the virtual machines in the virtual appliance, - * and will return an {@link AsyncTask} reference for each deploy operation. The deployment will - * finish when all individual tasks finish. - * - * @param forceEnterpriseSoftLimits Boolean indicating if the deployment must be executed even - * if the enterprise soft limits are reached. - * @return The list of tasks corresponding to the deploy process of each virtual machine in the - * appliance. - */ - public AsyncTask[] deploy(final boolean forceEnterpriseSoftLimits) - { - VirtualMachineTaskDto force = new VirtualMachineTaskDto(); - force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits); + /** + * Deploys the virtual appliance. + *

+ * This method will start the deployment of all the virtual machines in the + * virtual appliance, and will return an {@link AsyncTask} reference for each + * deploy operation. The deployment will finish when all individual tasks + * finish. + * + * @param forceEnterpriseSoftLimits + * Boolean indicating if the deployment must be executed even if + * the enterprise soft limits are reached. + * @return The list of tasks corresponding to the deploy process of each + * virtual machine in the appliance. + */ + public AsyncTask[] deploy(final boolean forceEnterpriseSoftLimits) { + VirtualMachineTaskDto force = new VirtualMachineTaskDto(); + force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits); - AcceptedRequestDto response = - context.getApi().getCloudApi().deployVirtualAppliance(unwrap(), force); + AcceptedRequestDto response = context.getApi().getCloudApi().deployVirtualAppliance(unwrap(), force); - return getTasks(response); - } + return getTasks(response); + } - /** - * Undeploys the virtual appliance. - *

- * This method will start the undeploy of all the virtual machines in the virtual appliance, and - * will return an {@link AsyncTask} reference for each undeploy operation. The undeploy will - * finish when all individual tasks finish. - * - * @return The list of tasks corresponding to the undeploy process of each virtual machine in - * the appliance. - */ - public AsyncTask[] undeploy() - { - return undeploy(false); - } + /** + * Undeploys the virtual appliance. + *

+ * This method will start the undeploy of all the virtual machines in the + * virtual appliance, and will return an {@link AsyncTask} reference for each + * undeploy operation. The undeploy will finish when all individual tasks + * finish. + * + * @return The list of tasks corresponding to the undeploy process of each + * virtual machine in the appliance. + */ + public AsyncTask[] undeploy() { + return undeploy(false); + } - /** - * Undeploys the virtual appliance. - *

- * This method will start the undeploy of all the virtual machines in the virtual appliance, and - * will return an {@link AsyncTask} reference for each undeploy operation. The undeploy will - * finish when all individual tasks finish. - * - * @param forceUndeploy Boolean flag to force the undeploy even if the virtual appliance - * contains imported virtual machines. - * @return The list of tasks corresponding to the undeploy process of each virtual machine in - * the appliance. - */ - public AsyncTask[] undeploy(final boolean forceUndeploy) - { - VirtualMachineTaskDto force = new VirtualMachineTaskDto(); - force.setForceUndeploy(forceUndeploy); + /** + * Undeploys the virtual appliance. + *

+ * This method will start the undeploy of all the virtual machines in the + * virtual appliance, and will return an {@link AsyncTask} reference for each + * undeploy operation. The undeploy will finish when all individual tasks + * finish. + * + * @param forceUndeploy + * Boolean flag to force the undeploy even if the virtual appliance + * contains imported virtual machines. + * @return The list of tasks corresponding to the undeploy process of each + * virtual machine in the appliance. + */ + public AsyncTask[] undeploy(final boolean forceUndeploy) { + VirtualMachineTaskDto force = new VirtualMachineTaskDto(); + force.setForceUndeploy(forceUndeploy); - AcceptedRequestDto response = - context.getApi().getCloudApi().undeployVirtualAppliance(unwrap(), force); + AcceptedRequestDto response = context.getApi().getCloudApi().undeployVirtualAppliance(unwrap(), force); - return getTasks(response); - } + return getTasks(response); + } - /** - * Returns a String message with the price info of the virtual appliance. - * - * @return The price of the virtual appliance - */ - public String getPrice() - { - return context.getApi().getCloudApi().getVirtualAppliancePrice(target); - } + /** + * Returns a String message with the price info of the virtual appliance. + * + * @return The price of the virtual appliance + */ + public String getPrice() { + return context.getApi().getCloudApi().getVirtualAppliancePrice(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) - { - return new Builder(context, virtualDatacenter); - } + public static Builder builder(final RestContext context, + final VirtualDatacenter virtualDatacenter) { + return new Builder(context, virtualDatacenter); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private VirtualDatacenter virtualDatacenter; + private VirtualDatacenter virtualDatacenter; - public Builder(final RestContext context, - final VirtualDatacenter virtualDatacenter) - { - super(); - checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE - + VirtualDatacenter.class); - this.virtualDatacenter = virtualDatacenter; - this.context = context; - } + public Builder(final RestContext context, final VirtualDatacenter virtualDatacenter) { + super(); + checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class); + this.virtualDatacenter = virtualDatacenter; + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) - { - checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE - + VirtualDatacenter.class); - this.virtualDatacenter = virtualDatacenter; - return this; - } + public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) { + checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class); + this.virtualDatacenter = virtualDatacenter; + return this; + } - public VirtualAppliance build() - { - VirtualApplianceDto dto = new VirtualApplianceDto(); - dto.setName(name); + public VirtualAppliance build() { + VirtualApplianceDto dto = new VirtualApplianceDto(); + dto.setName(name); - VirtualAppliance virtualAppliance = new VirtualAppliance(context, dto); - virtualAppliance.virtualDatacenter = virtualDatacenter; + VirtualAppliance virtualAppliance = new VirtualAppliance(context, dto); + virtualAppliance.virtualDatacenter = virtualDatacenter; - return virtualAppliance; - } + return virtualAppliance; + } - public static Builder fromVirtualAppliance(final VirtualAppliance in) - { - return VirtualAppliance.builder(in.context, in.virtualDatacenter).name(in.getName()); - } - } + public static Builder fromVirtualAppliance(final VirtualAppliance in) { + return VirtualAppliance.builder(in.context, in.virtualDatacenter).name(in.getName()); + } + } - // Delegate methods + // Delegate methods - public int getError() - { - return target.getError(); - } + public int getError() { + return target.getError(); + } - public int getHighDisponibility() - { - return target.getHighDisponibility(); - } + public int getHighDisponibility() { + return target.getHighDisponibility(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public int getPublicApp() - { - return target.getPublicApp(); - } + public int getPublicApp() { + return target.getPublicApp(); + } - public void setHighDisponibility(final int highDisponibility) - { - target.setHighDisponibility(highDisponibility); - } + public void setHighDisponibility(final int highDisponibility) { + target.setHighDisponibility(highDisponibility); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setPublicApp(final int publicApp) - { - target.setPublicApp(publicApp); - } + public void setPublicApp(final int publicApp) { + target.setPublicApp(publicApp); + } - @Override - public String toString() - { - return "VirtualAppliance [id=" + getId() + ", name=" + getName() + "]"; - } + @Override + public String toString() { + return "VirtualAppliance [id=" + getId() + ", name=" + getName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java index af9363bab8..d43a61414f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenter.java @@ -66,615 +66,564 @@ import com.google.common.collect.Lists; /** * Represents a virtual datacenter. *

- * Virtual datacenters expose a set of compute, storage and networking resources that can be - * consumed by the tenants. + * Virtual datacenters expose a set of compute, storage and networking resources + * that can be consumed by the tenants. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource + * @see API: + * http + * ://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource */ -public class VirtualDatacenter extends DomainWithLimitsWrapper -{ - /** The enterprise where the rack belongs. */ - private Enterprise enterprise; +public class VirtualDatacenter extends DomainWithLimitsWrapper { + /** The enterprise where the rack belongs. */ + private Enterprise enterprise; - /** The dataceter where the virtual datacenter will be deployed. */ - private Datacenter datacenter; + /** The dataceter where the virtual datacenter will be deployed. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected VirtualDatacenter(final RestContext context, - final VirtualDatacenterDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected VirtualDatacenter(final RestContext context, final VirtualDatacenterDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the virtual datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-DeleteanexistingVirtualDatacenter - */ - public void delete() - { - context.getApi().getCloudApi().deleteVirtualDatacenter(target); - target = null; - } + /** + * Delete the virtual datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# + * VirtualDatacenterResource-DeleteanexistingVirtualDatacenter + */ + public void delete() { + context.getApi().getCloudApi().deleteVirtualDatacenter(target); + target = null; + } - /** - * Creates the virtual datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-CreateanewVirtualDatacenter - */ - public void save() - { - target = - context.getApi().getCloudApi() - .createVirtualDatacenter(target, datacenter.unwrap(), enterprise.unwrap()); - } + /** + * Creates the virtual datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-CreateanewVirtualDatacenter + */ + public void save() { + target = context.getApi().getCloudApi().createVirtualDatacenter(target, datacenter.unwrap(), enterprise.unwrap()); + } - /** - * Updates the virtual datacenter information when some of its properties have changed. - * - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-UpdatesanexistingVirtualDatacenter - */ - public void update() - { - target = context.getApi().getCloudApi().updateVirtualDatacenter(target); - } + /** + * Updates the virtual datacenter information when some of its properties + * have changed. + * + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# + * VirtualDatacenterResource-UpdatesanexistingVirtualDatacenter + */ + public void update() { + target = context.getApi().getCloudApi().updateVirtualDatacenter(target); + } - // Parent access + // Parent access - /** - * Gets the datacenter where this virtual datacenter is assigned. - * - * @return The datacenter where this virtual datacenter is assigned. - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource- - * RetrieveaDatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - datacenter = getEnterprise().findAllowedDatacenter(DatacenterPredicates.id(datacenterId)); - return datacenter; - } + /** + * Gets the datacenter where this virtual datacenter is assigned. + * + * @return The datacenter where this virtual datacenter is assigned. + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource# + * DatacenterResource- RetrieveaDatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + datacenter = getEnterprise().findAllowedDatacenter(DatacenterPredicates.id(datacenterId)); + return datacenter; + } - /** - * Gets the enterprise that owns this virtual datacenter. - * - * @return The enterprise that owns this virtual datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * RetrieveanEnterprise - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - enterprise = - wrap(context, Enterprise.class, - context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); - return enterprise; - } + /** + * Gets the enterprise that owns this virtual datacenter. + * + * @return The enterprise that owns this virtual datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- RetrieveanEnterprise + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + enterprise = wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); + return enterprise; + } - // Children access + // Children access - /** - * Lists all the virtual appliances in the virtual datacenter. - * - * @return The list of virtual appliances in the virtual datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource# - * VirtualApplianceResource-RetrievethelistofVirtualAppliances - */ - public List listVirtualAppliances() - { - VirtualAppliancesDto vapps = context.getApi().getCloudApi().listVirtualAppliances(target); - return wrap(context, VirtualAppliance.class, vapps.getCollection()); - } + /** + * Lists all the virtual appliances in the virtual datacenter. + * + * @return The list of virtual appliances in the virtual datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource + * # VirtualApplianceResource-RetrievethelistofVirtualAppliances + */ + public List listVirtualAppliances() { + VirtualAppliancesDto vapps = context.getApi().getCloudApi().listVirtualAppliances(target); + return wrap(context, VirtualAppliance.class, vapps.getCollection()); + } - /** - * Lists all the virtual appliances in the virtual datacenter that match the given filter. - * - * @param filter The filter to apply. - * @return The list of virtual appliances in the virtual datacenter that match the given filter. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource# - * VirtualApplianceResource-RetrievethelistofVirtualAppliances - */ - public List listVirtualAppliances(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualAppliances(), filter)); - } + /** + * Lists all the virtual appliances in the virtual datacenter that match the + * given filter. + * + * @param filter + * The filter to apply. + * @return The list of virtual appliances in the virtual datacenter that + * match the given filter. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource + * # VirtualApplianceResource-RetrievethelistofVirtualAppliances + */ + public List listVirtualAppliances(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualAppliances(), filter)); + } - /** - * Gets the first virtual appliance in the virtual datacenter that match the given filter. - * - * @param filter The filter to apply. - * @return the first virtual appliance in the virtual datacenter that match the given filter or - * null if none is found. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource# - * VirtualApplianceResource-RetrievethelistofVirtualAppliances - */ - public VirtualAppliance findVirtualAppliance(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualAppliances(), filter), null); - } + /** + * Gets the first virtual appliance in the virtual datacenter that match the + * given filter. + * + * @param filter + * The filter to apply. + * @return the first virtual appliance in the virtual datacenter that match + * the given filter or null if none is found. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Appliance+Resource + * # VirtualApplianceResource-RetrievethelistofVirtualAppliances + */ + public VirtualAppliance findVirtualAppliance(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualAppliances(), filter), null); + } - /** - * Gets the virtual appliance with the given id in the current virtual datacenter. - * - * @param id The id of the virtual appliance to get. - * @return The virtual appliance. - */ - public VirtualAppliance getVirtualAppliance(final Integer id) - { - VirtualApplianceDto vapp = context.getApi().getCloudApi().getVirtualAppliance(target, id); - return wrap(context, VirtualAppliance.class, vapp); - } + /** + * Gets the virtual appliance with the given id in the current virtual + * datacenter. + * + * @param id + * The id of the virtual appliance to get. + * @return The virtual appliance. + */ + public VirtualAppliance getVirtualAppliance(final Integer id) { + VirtualApplianceDto vapp = context.getApi().getCloudApi().getVirtualAppliance(target, id); + return wrap(context, VirtualAppliance.class, vapp); + } - /** - * Lists the storage tiers that are available to the virtual datacenter. - * - * @return The list of storage tiers that are available to the virtual datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-Retrieveenabledtiers - */ - public List listStorageTiers() - { - TiersDto tiers = context.getApi().getCloudApi().listStorageTiers(target); - return wrap(context, Tier.class, tiers.getCollection()); - } + /** + * Lists the storage tiers that are available to the virtual datacenter. + * + * @return The list of storage tiers that are available to the virtual + * datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-Retrieveenabledtiers + */ + public List listStorageTiers() { + TiersDto tiers = context.getApi().getCloudApi().listStorageTiers(target); + return wrap(context, Tier.class, tiers.getCollection()); + } - /** - * Lists the storage tiers that are available to the virtual datacenter and match the given - * filter. - * - * @param filter The filter to apply. - * @return The list of storage tiers that are available to the virtual datacenter and match the - * given filter. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-Retrieveenabledtiers - */ - public List listStorageTiers(final Predicate filter) - { - return Lists.newLinkedList(filter(listStorageTiers(), filter)); - } + /** + * Lists the storage tiers that are available to the virtual datacenter and + * match the given filter. + * + * @param filter + * The filter to apply. + * @return The list of storage tiers that are available to the virtual + * datacenter and match the given filter. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-Retrieveenabledtiers + */ + public List listStorageTiers(final Predicate filter) { + return Lists.newLinkedList(filter(listStorageTiers(), filter)); + } - /** - * Finds the first the storage tier that is available to the virtual datacenter and matches the - * given filter. - * - * @param filter The filter to apply. - * @return The first the storage tier that is available to the virtual datacenter and matches - * the given filter. - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-Retrieveenabledtiers - */ - public Tier findStorageTier(final Predicate filter) - { - return Iterables.getFirst(filter(listStorageTiers(), filter), null); - } + /** + * Finds the first the storage tier that is available to the virtual + * datacenter and matches the given filter. + * + * @param filter + * The filter to apply. + * @return The first the storage tier that is available to the virtual + * datacenter and matches the given filter. + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-Retrieveenabledtiers + */ + public Tier findStorageTier(final Predicate filter) { + return Iterables.getFirst(filter(listStorageTiers(), filter), null); + } - /** - * Gets the storage tier with the given id from the current virtual datacenter. - * - * @param id The id of the storage tier. - * @return The sotrage tier. - */ - public Tier getStorageTier(final Integer id) - { - TierDto tier = context.getApi().getCloudApi().getStorageTier(target, id); - return wrap(context, Tier.class, tier); - } + /** + * Gets the storage tier with the given id from the current virtual + * datacenter. + * + * @param id + * The id of the storage tier. + * @return The sotrage tier. + */ + public Tier getStorageTier(final Integer id) { + TierDto tier = context.getApi().getCloudApi().getStorageTier(target, id); + return wrap(context, Tier.class, tier); + } - /** - * Lists all persistent volumes in the virtual datacenter. - * - * @return The list of all persistent volumes in the virtual datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource#VolumeResource- - * Retrievethelistofvolumes - */ - public List listVolumes() - { - VolumesManagementDto volumes = context.getApi().getCloudApi().listVolumes(target); - return wrap(context, Volume.class, volumes.getCollection()); - } + /** + * Lists all persistent volumes in the virtual datacenter. + * + * @return The list of all persistent volumes in the virtual datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource# + * VolumeResource- Retrievethelistofvolumes + */ + public List listVolumes() { + VolumesManagementDto volumes = context.getApi().getCloudApi().listVolumes(target); + return wrap(context, Volume.class, volumes.getCollection()); + } - /** - * Lists all persistent volumes in the virtual datacenter that match the given filter. - * - * @param filter The filter to apply. - * @return The list of all persistent volumes in the virtual datacenter that match the given - * filter. - * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource#VolumeResource- - * Retrievethelistofvolumes - */ - public List listVolumes(final Predicate filter) - { - return Lists.newLinkedList(filter(listVolumes(), filter)); - } + /** + * Lists all persistent volumes in the virtual datacenter that match the + * given filter. + * + * @param filter + * The filter to apply. + * @return The list of all persistent volumes in the virtual datacenter that + * match the given filter. + * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource# + * VolumeResource- Retrievethelistofvolumes + */ + public List listVolumes(final Predicate filter) { + return Lists.newLinkedList(filter(listVolumes(), filter)); + } - /** - * Finds the first persistent volume in the virtual datacenter that matches the given filter. - * - * @param filter The filter to apply. - * @return The first persistent volumes in the virtual datacenter that matches the given filter. - * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource#VolumeResource- - * Retrievethelistofvolumes - */ - public Volume findVolume(final Predicate filter) - { - return Iterables.getFirst(filter(listVolumes(), filter), null); - } + /** + * Finds the first persistent volume in the virtual datacenter that matches + * the given filter. + * + * @param filter + * The filter to apply. + * @return The first persistent volumes in the virtual datacenter that + * matches the given filter. + * @see API: http://community.abiquo.com/display/ABI20/Volume+Resource# + * VolumeResource- Retrievethelistofvolumes + */ + public Volume findVolume(final Predicate filter) { + return Iterables.getFirst(filter(listVolumes(), filter), null); + } - public Volume getVolume(final Integer id) - { - VolumeManagementDto volume = context.getApi().getCloudApi().getVolume(target, id); - return wrap(context, Volume.class, volume); - } + public Volume getVolume(final Integer id) { + VolumeManagementDto volume = context.getApi().getCloudApi().getVolume(target, id); + return wrap(context, Volume.class, volume); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Hard+Disks+Resource#HardDisksResource- - * GetthelistofHardDisksofaVirtualDatacenter - */ - public List listHardDisks() - { - DisksManagementDto hardDisks = context.getApi().getCloudApi().listHardDisks(target); - return wrap(context, HardDisk.class, hardDisks.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Hard+Disks+Resource# + * HardDisksResource- GetthelistofHardDisksofaVirtualDatacenter + */ + public List listHardDisks() { + DisksManagementDto hardDisks = context.getApi().getCloudApi().listHardDisks(target); + return wrap(context, HardDisk.class, hardDisks.getCollection()); + } - public List listHardDisks(final Predicate filter) - { - return Lists.newLinkedList(filter(listHardDisks(), filter)); - } + public List listHardDisks(final Predicate filter) { + return Lists.newLinkedList(filter(listHardDisks(), filter)); + } - public HardDisk findHardDisk(final Predicate filter) - { - return Iterables.getFirst(filter(listHardDisks(), filter), null); - } + public HardDisk findHardDisk(final Predicate filter) { + return Iterables.getFirst(filter(listHardDisks(), filter), null); + } - public HardDisk getHardDisk(final Integer id) - { - DiskManagementDto hardDisk = context.getApi().getCloudApi().getHardDisk(target, id); - return wrap(context, HardDisk.class, hardDisk); - } + public HardDisk getHardDisk(final Integer id) { + DiskManagementDto hardDisk = context.getApi().getCloudApi().getHardDisk(target, id); + return wrap(context, HardDisk.class, hardDisk); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-GetdefaultVLANusedbydefaultinVirtualDatacenter - */ - public Network< ? > getDefaultNetwork() - { - VLANNetworkDto network = context.getApi().getCloudApi().getDefaultNetwork(target); - return wrap(context, network.getType() == NetworkType.INTERNAL ? PrivateNetwork.class - : ExternalNetwork.class, network); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# + * VirtualDatacenterResource-GetdefaultVLANusedbydefaultinVirtualDatacenter + * + */ + public Network getDefaultNetwork() { + VLANNetworkDto network = context.getApi().getCloudApi().getDefaultNetwork(target); + return wrap(context, network.getType() == NetworkType.INTERNAL ? PrivateNetwork.class : ExternalNetwork.class, + network); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource - * -RetrievealistofPrivateNetworks - */ - public List listPrivateNetworks() - { - VLANNetworksDto networks = context.getApi().getCloudApi().listPrivateNetworks(target); - return wrap(context, PrivateNetwork.class, networks.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource# + * PrivateNetworkResource -RetrievealistofPrivateNetworks + */ + public List listPrivateNetworks() { + VLANNetworksDto networks = context.getApi().getCloudApi().listPrivateNetworks(target); + return wrap(context, PrivateNetwork.class, networks.getCollection()); + } - public List listPrivateNetworks(final Predicate> filter) - { - return Lists.newLinkedList(filter(listPrivateNetworks(), filter)); - } + public List listPrivateNetworks(final Predicate> filter) { + return Lists.newLinkedList(filter(listPrivateNetworks(), filter)); + } - public PrivateNetwork findPrivateNetwork(final Predicate> filter) - { - return Iterables.getFirst(filter(listPrivateNetworks(), filter), null); - } + public PrivateNetwork findPrivateNetwork(final Predicate> filter) { + return Iterables.getFirst(filter(listPrivateNetworks(), filter), null); + } - public PrivateNetwork getPrivateNetwork(final Integer id) - { - VLANNetworkDto network = context.getApi().getCloudApi().getPrivateNetwork(target, id); - return wrap(context, PrivateNetwork.class, network); - } + public PrivateNetwork getPrivateNetwork(final Integer id) { + VLANNetworkDto network = context.getApi().getCloudApi().getPrivateNetwork(target, id); + return wrap(context, PrivateNetwork.class, network); + } - /** - * TODO needs to be in the wiki - */ - public List listAvailableTemplates() - { - VirtualMachineTemplatesDto templates = - context.getApi().getCloudApi().listAvailableTemplates(target); + /** + * TODO needs to be in the wiki + */ + public List listAvailableTemplates() { + VirtualMachineTemplatesDto templates = context.getApi().getCloudApi().listAvailableTemplates(target); - return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); - } + return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); + } - public List listAvailableTemplates( - final VirtualMachineTemplateOptions options) - { - VirtualMachineTemplatesDto templates = - context.getApi().getCloudApi().listAvailableTemplates(target, options); + public List listAvailableTemplates(final VirtualMachineTemplateOptions options) { + VirtualMachineTemplatesDto templates = context.getApi().getCloudApi().listAvailableTemplates(target, options); - return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); - } + return wrap(context, VirtualMachineTemplate.class, templates.getCollection()); + } - public List listAvailableTemplates( - final Predicate filter) - { - return Lists.newLinkedList(filter(listAvailableTemplates(), filter)); - } + public List listAvailableTemplates(final Predicate filter) { + return Lists.newLinkedList(filter(listAvailableTemplates(), filter)); + } - public VirtualMachineTemplate findAvailableTemplate( - final Predicate filter) - { - return Iterables.getFirst(filter(listAvailableTemplates(), filter), null); - } + public VirtualMachineTemplate findAvailableTemplate(final Predicate filter) { + return Iterables.getFirst(filter(listAvailableTemplates(), filter), null); + } - public VirtualMachineTemplate getAvailableTemplate(final Integer id) - { - VirtualMachineTemplatesDto templates = - context - .getApi() - .getCloudApi() - .listAvailableTemplates(target, - VirtualMachineTemplateOptions.builder().idTemplate(id).build()); + public VirtualMachineTemplate getAvailableTemplate(final Integer id) { + VirtualMachineTemplatesDto templates = context.getApi().getCloudApi() + .listAvailableTemplates(target, VirtualMachineTemplateOptions.builder().idTemplate(id).build()); - return templates.getCollection().isEmpty() ? null : // + return templates.getCollection().isEmpty() ? null : // wrap(context, VirtualMachineTemplate.class, templates.getCollection().get(0)); - } + } - public VirtualMachineTemplate getAvailablePersistentTemplate(final Integer id) - { - VirtualMachineTemplatesDto templates = - context - .getApi() - .getCloudApi() - .listAvailableTemplates( - target, - VirtualMachineTemplateOptions.builder().idTemplate(id) - .persistent(StatefulInclusion.ALL).build()); + public VirtualMachineTemplate getAvailablePersistentTemplate(final Integer id) { + VirtualMachineTemplatesDto templates = context + .getApi() + .getCloudApi() + .listAvailableTemplates(target, + VirtualMachineTemplateOptions.builder().idTemplate(id).persistent(StatefulInclusion.ALL).build()); - return templates.getCollection().isEmpty() ? null : // + return templates.getCollection().isEmpty() ? null : // wrap(context, VirtualMachineTemplate.class, templates.getCollection().get(0)); - } + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-ListofPublicIPstopurchasebyVirtualDatacenter - */ - public List listAvailablePublicIps() - { - IpOptions options = IpOptions.builder().build(); + /** + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# + * VirtualDatacenterResource-ListofPublicIPstopurchasebyVirtualDatacenter + * + */ + public List listAvailablePublicIps() { + IpOptions options = IpOptions.builder().build(); - PublicIpsDto ips = context.getApi().getCloudApi().listAvailablePublicIps(target, options); + PublicIpsDto ips = context.getApi().getCloudApi().listAvailablePublicIps(target, options); - return wrap(context, PublicIp.class, ips.getCollection()); - } + return wrap(context, PublicIp.class, ips.getCollection()); + } - public List listAvailablePublicIps(final Predicate filter) - { - return Lists.newLinkedList(filter(listAvailablePublicIps(), filter)); - } + public List listAvailablePublicIps(final Predicate filter) { + return Lists.newLinkedList(filter(listAvailablePublicIps(), filter)); + } - public PublicIp findAvailablePublicIp(final Predicate filter) - { - return Iterables.getFirst(filter(listAvailablePublicIps(), filter), null); - } + public PublicIp findAvailablePublicIp(final Predicate filter) { + return Iterables.getFirst(filter(listAvailablePublicIps(), filter), null); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-ListofpurchasedPublicIPsbyVirtualDatacenter - */ - public List listPurchasedPublicIps() - { - IpOptions options = IpOptions.builder().build(); + /** + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# + * VirtualDatacenterResource-ListofpurchasedPublicIPsbyVirtualDatacenter + * + */ + public List listPurchasedPublicIps() { + IpOptions options = IpOptions.builder().build(); - PublicIpsDto ips = context.getApi().getCloudApi().listPurchasedPublicIps(target, options); + PublicIpsDto ips = context.getApi().getCloudApi().listPurchasedPublicIps(target, options); - return wrap(context, PublicIp.class, ips.getCollection()); - } + return wrap(context, PublicIp.class, ips.getCollection()); + } - public List listPurchasedPublicIps(final Predicate filter) - { - return Lists.newLinkedList(filter(listPurchasedPublicIps(), filter)); - } + public List listPurchasedPublicIps(final Predicate filter) { + return Lists.newLinkedList(filter(listPurchasedPublicIps(), filter)); + } - public PublicIp findPurchasedPublicIp(final Predicate filter) - { - return Iterables.getFirst(filter(listPurchasedPublicIps(), filter), null); - } + public PublicIp findPurchasedPublicIp(final Predicate filter) { + return Iterables.getFirst(filter(listPurchasedPublicIps(), filter), null); + } - public void purchasePublicIp(final PublicIp ip) - { - checkNotNull(ip.unwrap().searchLink("purchase"), ValidationErrors.MISSING_REQUIRED_LINK); - context.getApi().getCloudApi().purchasePublicIp(ip.unwrap()); - } + public void purchasePublicIp(final PublicIp ip) { + checkNotNull(ip.unwrap().searchLink("purchase"), ValidationErrors.MISSING_REQUIRED_LINK); + context.getApi().getCloudApi().purchasePublicIp(ip.unwrap()); + } - public void releaseePublicIp(final PublicIp ip) - { - checkNotNull(ip.unwrap().searchLink("release"), ValidationErrors.MISSING_REQUIRED_LINK); - context.getApi().getCloudApi().releasePublicIp(ip.unwrap()); - } + public void releaseePublicIp(final PublicIp ip) { + checkNotNull(ip.unwrap().searchLink("release"), ValidationErrors.MISSING_REQUIRED_LINK); + context.getApi().getCloudApi().releasePublicIp(ip.unwrap()); + } - // Actions + // Actions - public void setDefaultNetwork(final Network< ? > network) - { - context.getApi().getCloudApi().setDefaultNetwork(target, network.unwrap()); - } + public void setDefaultNetwork(final Network network) { + context.getApi().getCloudApi().setDefaultNetwork(target, network.unwrap()); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - return new Builder(context, datacenter, enterprise); - } + public static Builder builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + return new Builder(context, datacenter, enterprise); + } - public static class Builder extends LimitsBuilder - { - private RestContext context; + public static class Builder extends LimitsBuilder { + private RestContext context; - private String name; + private String name; - private HypervisorType hypervisorType; + private HypervisorType hypervisorType; - private Enterprise enterprise; + private Enterprise enterprise; - private Datacenter datacenter; + private Datacenter datacenter; - private PrivateNetwork network; + private PrivateNetwork network; - public Builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.enterprise = enterprise; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + super(); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.enterprise = enterprise; + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder hypervisorType(final HypervisorType hypervisorType) - { - this.hypervisorType = hypervisorType; - return this; - } + public Builder hypervisorType(final HypervisorType hypervisorType) { + this.hypervisorType = hypervisorType; + return this; + } - public Builder datacenter(final Datacenter datacenter) - { - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + return this; + } - public Builder enterprise(final Enterprise enterprise) - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.enterprise = enterprise; - return this; - } + public Builder enterprise(final Enterprise enterprise) { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.enterprise = enterprise; + return this; + } - public Builder network(final PrivateNetwork network) - { - checkNotNull(network, ValidationErrors.NULL_RESOURCE + PrivateNetwork.class); - this.network = network; - return this; - } + public Builder network(final PrivateNetwork network) { + checkNotNull(network, ValidationErrors.NULL_RESOURCE + PrivateNetwork.class); + this.network = network; + return this; + } - public VirtualDatacenter build() - { - VirtualDatacenterDto dto = new VirtualDatacenterDto(); - dto.setName(name); - dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); - dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); - dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); - dto.setStorageLimits(storageSoft, storageHard); - dto.setVlansLimits(vlansSoft, vlansHard); - dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); - dto.setName(name); - dto.setHypervisorType(hypervisorType); - dto.setVlan(network.unwrap()); + public VirtualDatacenter build() { + VirtualDatacenterDto dto = new VirtualDatacenterDto(); + dto.setName(name); + dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); + dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); + dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); + dto.setStorageLimits(storageSoft, storageHard); + dto.setVlansLimits(vlansSoft, vlansHard); + dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); + dto.setName(name); + dto.setHypervisorType(hypervisorType); + dto.setVlan(network.unwrap()); - VirtualDatacenter virtualDatacenter = new VirtualDatacenter(context, dto); - virtualDatacenter.datacenter = datacenter; - virtualDatacenter.enterprise = enterprise; + VirtualDatacenter virtualDatacenter = new VirtualDatacenter(context, dto); + virtualDatacenter.datacenter = datacenter; + virtualDatacenter.enterprise = enterprise; - return virtualDatacenter; - } + return virtualDatacenter; + } - public static Builder fromVirtualDatacenter(final VirtualDatacenter in) - { - return VirtualDatacenter.builder(in.context, in.datacenter, in.enterprise) - .name(in.getName()).ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) - .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) - .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) - .storageLimits(in.getStorageSoft(), in.getStorageHard()) - .vlansLimits(in.getVlansSoft(), in.getVlansHard()) - .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) - .hypervisorType(in.getHypervisorType()); - } - } + public static Builder fromVirtualDatacenter(final VirtualDatacenter in) { + return VirtualDatacenter.builder(in.context, in.datacenter, in.enterprise).name(in.getName()) + .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) + .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) + .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) + .storageLimits(in.getStorageSoft(), in.getStorageHard()) + .vlansLimits(in.getVlansSoft(), in.getVlansHard()) + .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()).hypervisorType(in.getHypervisorType()); + } + } - // Delegate methods + // Delegate methods - public HypervisorType getHypervisorType() - { - return target.getHypervisorType(); - } + public HypervisorType getHypervisorType() { + return target.getHypervisorType(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setHypervisorType(final HypervisorType hypervisorType) - { - target.setHypervisorType(hypervisorType); - } + public void setHypervisorType(final HypervisorType hypervisorType) { + target.setHypervisorType(hypervisorType); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - @Override - public String toString() - { - return "VirtualDatacenter [id=" + getId() + ", type=" + getHypervisorType() + ", name=" - + getName() + "]"; - } + @Override + public String toString() { + return "VirtualDatacenter [id=" + getId() + ", type=" + getHypervisorType() + ", name=" + getName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java index 24d9a684d8..b29bc4da57 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachine.java @@ -76,969 +76,835 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/VirtualMachineResource */ -public class VirtualMachine extends DomainWithTasksWrapper -{ - /** The virtual appliance where the virtual machine belongs. */ - private VirtualAppliance virtualAppliance; - - /** The virtual machine template of the virtual machine. */ - private VirtualMachineTemplate template; - - /** - * Constructor to be used only by the builder. - */ - protected VirtualMachine(final RestContext context, - final VirtualMachineWithNodeExtendedDto target) - { - super(context, target); - } - - // Domain operations - - /** - * Delete the virtual machine. - * - * @see API: - * http://community.abiquo.com/display/ABI20/VirtualMachineResource#VirtualMachineResource - * -Deleteavirtualmachine - */ - public void delete() - { - context.getApi().getCloudApi().deleteVirtualMachine(target); - target = null; - } - - /** - * Create a new virtual machine in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# - * VirtualMachineResource-Createavirtualmachine - */ - public void save() - { - checkNotNull(template, ValidationErrors.NULL_RESOURCE + VirtualMachineTemplate.class); - checkNotNull(template.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + VirtualMachineTemplate.class); - - this.updateLink(target, ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, template.unwrap(), "edit"); - - target = - context.getApi().getCloudApi().createVirtualMachine(virtualAppliance.unwrap(), target); - } - - /** - * Update virtual machine information in the server with the data from this virtual machine. - * This is an asynchronous call. This method returns a - * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track of the task - * completion. Please refer to the documentation for details. - * - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# - * VirtualMachineResource-Modifyavirtualmachine - * @see github: - * https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example - * @return The task reference or null if the operation completed synchronously. - */ - public AsyncTask update() - { - AcceptedRequestDto taskRef = - context.getApi().getCloudApi().updateVirtualMachine(target); - return taskRef == null ? null : getTask(taskRef); - } - - /** - * Update virtual machine information in the server with the data from this virtual machine. - * This is an asynchronous call. This method returns a - * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track of the task - * completion. Please refer to the documentation for details. - * - * @param force Force update. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# - * VirtualMachineResource-Modifyavirtualmachine - * @see github: - * https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example - * @return The task reference or null if the operation completed synchronously. - */ - public AsyncTask update(final boolean force) - { - AcceptedRequestDto taskRef = - context.getApi().getCloudApi() - .updateVirtualMachine(target, VirtualMachineOptions.builder().force(force).build()); - return taskRef == null ? null : getTask(taskRef); - } - - /** - * Change the state of the virtual machine. This is an asynchronous call. This method returns a - * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track of the task - * completion. Please refer to the documentation for details. - * - * @param state The new state of the virtual machine. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# - * VirtualMachineResource-Changethestateofavirtualmachine - * @see github: - * https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example - * @return The task reference or null if the operation completed synchronously. - */ - public AsyncTask changeState(final VirtualMachineState state) - { - VirtualMachineStateDto dto = new VirtualMachineStateDto(); - dto.setState(state); - - AcceptedRequestDto taskRef = - context.getApi().getCloudApi().changeVirtualMachineState(target, dto); - - return getTask(taskRef); - } - - /** - * Retrieve the state of the virtual machine. - * - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# - * VirtualMachineResource-Retrievethestateofthevirtualmachine - * @return Current state of the virtual machine. - */ - public VirtualMachineState getState() - { - VirtualMachineStateDto stateDto = - context.getApi().getCloudApi().getVirtualMachineState(target); - VirtualMachineState state = stateDto.getState(); - target.setState(state); - target.setIdState(state.id()); - return state; - } - - public void refresh() - { - RESTLink link = - checkNotNull(target.getEditLink(), ValidationErrors.MISSING_REQUIRED_LINK + " edit"); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VirtualMachineWithNodeExtendedDto.class)); - - target = parser.apply(response); - } - - // Parent access - - /** - * Retrieve the virtual appliance where this virtual machine is. - * - * @see API: http://community.abiquo.com/display/ABI20/VirtualApplianceResource# - * VirtualApplianceResource-Retrieveavirtualappliance - * @return The virtual appliance where this virtual machine is. - */ - public VirtualAppliance getVirtualAppliance() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_APPLIANCE), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.VIRTUAL_APPLIANCE); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VirtualApplianceDto.class)); - - return wrap(context, VirtualAppliance.class, parser.apply(response)); - } - - /** - * Retrieve the virtual datacenter where this virtual machine is. - * - * @see API: http://community.abiquo.com/display/ABI20/VirtualDatacenterResource# - * VirtualDatacenterResource-Retireveavirtualdatacenter - * @return The virtual datacenter where this virtual machine is. - */ - public VirtualDatacenter getVirtualDatacenter() - { - Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); - VirtualDatacenterDto dto = - context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); - return wrap(context, VirtualDatacenter.class, dto); - } - - /** - * Retrieve the enterprise of this virtual machine. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrieveanEnterprise - * @return Enterprise of this virtual machine. - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); - return wrap(context, Enterprise.class, dto); - } - - /** - * Retrieve the template of this virtual machine. - * - * @return Template of this virtual machine. - */ - public VirtualMachineTemplate getTemplate() - { - VirtualMachineTemplateDto dto = - context.getApi().getCloudApi().getVirtualMachineTemplate(target); - return wrap(context, VirtualMachineTemplate.class, dto); - } - - // Children access - - public List listAttachedHardDisks() - { - refresh(); - DisksManagementDto hardDisks = context.getApi().getCloudApi().listAttachedHardDisks(target); - return wrap(context, HardDisk.class, hardDisks.getCollection()); - } - - public List listAttachedHardDisks(final Predicate filter) - { - return Lists.newLinkedList(filter(listAttachedHardDisks(), filter)); - } - - public HardDisk findAttachedHardDisk(final Predicate filter) - { - return Iterables.getFirst(filter(listAttachedHardDisks(), filter), null); - } - - public List listAttachedVolumes() - { - refresh(); - VolumesManagementDto volumes = context.getApi().getCloudApi().listAttachedVolumes(target); - return wrap(context, Volume.class, volumes.getCollection()); - } - - public List listAttachedVolumes(final Predicate filter) - { - return Lists.newLinkedList(filter(listAttachedVolumes(), filter)); - } - - public Volume findAttachedVolume(final Predicate filter) - { - return Iterables.getFirst(filter(listAttachedVolumes(), filter), null); - } - - public List> listAttachedNics() - { - // The strategy will refresh the vm. There is no need to do it here - ListAttachedNics strategy = - context.getUtils().getInjector().getInstance(ListAttachedNics.class); - return Lists.newLinkedList(strategy.execute(this)); - } - - public List> listAttachedNics(final Predicate> filter) - { - return Lists.newLinkedList(filter(listAttachedNics(), filter)); - } - - public Ip< ? , ? > findAttachedNic(final Predicate> filter) - { - return Iterables.getFirst(filter(listAttachedNics(), filter), null); - } - - // Actions - - public AsyncTask deploy() - { - return deploy(false); - } - - public AsyncTask deploy(final boolean forceEnterpriseSoftLimits) - { - VirtualMachineTaskDto force = new VirtualMachineTaskDto(); - force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits); - - AcceptedRequestDto response = - context.getApi().getCloudApi().deployVirtualMachine(unwrap(), force); - - return getTask(response); - } - - public AsyncTask undeploy() - { - return undeploy(false); - } - - public AsyncTask undeploy(final boolean forceUndeploy) - { - VirtualMachineTaskDto force = new VirtualMachineTaskDto(); - force.setForceUndeploy(forceUndeploy); - - AcceptedRequestDto response = - context.getApi().getCloudApi().undeployVirtualMachine(unwrap(), force); - - return getTask(response); - } - - /** - * Reboot a virtual machine. This is an asynchronous call. This method returns a - * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track of the task - * completion. Please refer to the documentation for details. - * - * @see API: http://community.abiquo.com/display/ABI20/Rack+Resource#/VirtualMachineResource# - * VirtualMachineResource-Resetavirtualmachine - * @see github: - * https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor-example - * @return The task reference or null if the operation completed synchronously. - */ - public AsyncTask reboot() - { - AcceptedRequestDto response = - context.getApi().getCloudApi().rebootVirtualMachine(unwrap()); - - return getTask(response); - } - - public AsyncTask attachHardDisks(final HardDisk... hardDisks) - { - List expected = listAttachedHardDisks(); - expected.addAll(Arrays.asList(hardDisks)); - - HardDisk[] disks = new HardDisk[expected.size()]; - return setHardDisks(expected.toArray(disks)); - } - - public AsyncTask detachAllHardDisks() - { - AcceptedRequestDto taskRef = - context.getApi().getCloudApi().detachAllHardDisks(target); - return taskRef == null ? null : getTask(taskRef); - } - - public AsyncTask detachHardDisks(final HardDisk... hardDisks) - { - List expected = listAttachedHardDisks(); - Iterables.removeIf(expected, hardDiskIdIn(hardDisks)); - - HardDisk[] disks = new HardDisk[expected.size()]; - return setHardDisks(expected.toArray(disks)); - } - - public AsyncTask setHardDisks(final HardDisk... hardDisks) - { - AcceptedRequestDto taskRef = - context.getApi().getCloudApi().replaceHardDisks(target, toHardDiskDto(hardDisks)); - return taskRef == null ? null : getTask(taskRef); - } - - public AsyncTask attachVolumes(final Volume... volumes) - { - List expected = listAttachedVolumes(); - expected.addAll(Arrays.asList(volumes)); - - Volume[] vols = new Volume[expected.size()]; - return setVolumes(true, expected.toArray(vols)); - } - - public AsyncTask detachAllVolumes() - { - AcceptedRequestDto taskRef = - context.getApi().getCloudApi().detachAllVolumes(target); - return taskRef == null ? null : getTask(taskRef); - } - - public AsyncTask detachVolumes(final Volume... volumes) - { - List expected = listAttachedVolumes(); - Iterables.removeIf(expected, volumeIdIn(volumes)); - - Volume[] vols = new Volume[expected.size()]; - return setVolumes(true, expected.toArray(vols)); - } - - public AsyncTask setVolumes(final Boolean forceSoftLimits, final Volume... volumes) - { - AcceptedRequestDto taskRef = - context - .getApi() - .getCloudApi() - .replaceVolumes(target, - VirtualMachineOptions.builder().force(forceSoftLimits).build(), - toVolumeDto(volumes)); - - return taskRef == null ? null : getTask(taskRef); - } - - public AsyncTask setVolumes(final Volume... volumes) - { - return setVolumes(true, volumes); - } - - public AsyncTask setNics(final List< ? extends Ip< ? , ? >> ips) - { - // By default the network of the first ip will be used as a gateway - return setNics(ips != null && !ips.isEmpty() ? ips.get(0).getNetwork() : null, ips, null); - } - - public AsyncTask setNics(final List< ? extends Ip< ? , ? >> ips, - final List unmanagetNetworks) - { - // By default the network of the first ip will be used as a gateway - Network< ? > gateway = null; - if (ips != null && !ips.isEmpty()) - { - gateway = ips.get(0).getNetwork(); - } - else if (unmanagetNetworks != null && !unmanagetNetworks.isEmpty()) - { - gateway = unmanagetNetworks.get(0); - } - - return setNics(gateway, ips, unmanagetNetworks); - } - - public AsyncTask setNics(final Network< ? > gatewayNetwork, - final List< ? extends Ip< ? , ? >> ips) - { - return setNics(gatewayNetwork, ips, null); - } - - public AsyncTask setNics(final Network< ? > gatewayNetwork, - final List< ? extends Ip< ? , ? >> ips, final List unmanagetNetworks) - { - // Remove the gateway configuration and the current nics - Iterables.removeIf( - target.getLinks(), - Predicates.or(LinkPredicates.isNic(), - LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY))); - - // Add the given nics in the appropriate order - int i = 0; - if (ips != null) - { - for (i = 0; i < ips.size(); i++) - { - RESTLink source = LinkUtils.getSelfLink(ips.get(i).unwrap()); - RESTLink link = new RESTLink("nic" + i, source.getHref()); - link.setType(ips.get(i).unwrap().getBaseMediaType()); - target.addLink(link); - } - } - - // Add unmanaged network references, if given - if (unmanagetNetworks != null) - { - for (UnmanagedNetwork unmanaged : unmanagetNetworks) - { - RESTLink source = - checkNotNull(unmanaged.unwrap().searchLink("ips"), - ValidationErrors.MISSING_REQUIRED_LINK + "ips"); - - RESTLink link = new RESTLink("nic" + i, source.getHref()); - link.setType(UnmanagedIpDto.BASE_MEDIA_TYPE); - target.addLink(link); - i++; - } - } - - AsyncTask task = update(true); - if (gatewayNetwork == null) - { - return task; - } - - // If there is a gateway network, we have to wait until the network configuration links are - // available - if (task != null) - { - VirtualMachineState originalState = target.getState(); - VirtualMachineMonitor monitor = - context.getUtils().getInjector().getInstance(MonitoringService.class) - .getVirtualMachineMonitor(); - monitor.awaitState(originalState, this); - } - - // Set the new network configuration - - // Refresh virtual machine, to get the new configuration links - refresh(); - - VMNetworkConfigurationsDto configs = - context.getApi().getCloudApi().listNetworkConfigurations(target); - - Iterables.removeIf(target.getLinks(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY)); - for (VMNetworkConfigurationDto config : configs.getCollection()) - { - if (config.getGateway().equalsIgnoreCase(gatewayNetwork.getGateway())) - { - target.addLink(new RESTLink(ParentLinkName.NETWORK_GATEWAY, config.getEditLink() - .getHref())); - break; - } - } - - return update(true); - } - - // TODO: Get current gateway network - - public void setGatewayNetwork(final Network< ? > network) - { - context.getApi().getCloudApi().setGatewayNetwork(target, network.unwrap()); - refresh(); // First refresh the target and its links - } - - /** - * Checks if the virtual machine is persistent. - *

- * Persistent virtual machines have the system disc in an external volume. This way, when the - * virtual machine is undeployed, the contents of the system disk remain in the storage device - * and the user can deploy the virtual machine again without losing the data in the system disk. - * - * @return Boolean indicating if the virtual machine is persistent. - */ - public boolean isPersistent() - { - return getTemplate().unwrap().searchLink("volume") != null; - } - - public boolean hasDvd() - { - return target.getDvd() != null; - } - - public void attachDvd() - { - DvdManagementDto dvd = new DvdManagementDto(); - RESTLink link = new RESTLink("image", ""); - dvd.addLink(link); - target.setDvd(dvd); - } - - public void detachDvd() - { - target.setDvd(null); - } - - // Builder - - public static Builder builder(final RestContext context, - final VirtualAppliance virtualAppliance, final VirtualMachineTemplate template) - { - return new Builder(context, virtualAppliance, template); - } - - public static class Builder - { - private final RestContext context; - - private VirtualAppliance virtualAppliance; - - private final VirtualMachineTemplate template; - - private String nameLabel; - - private String internalName; - - private String description; - - private Integer ram; - - private Integer cpu; - - private Integer vncPort; - - private String vncAddress; - - private Integer idState; - - private Integer idType; - - private String password; - - private String keymap; - - private String uuid; - - private boolean dvd; - - public Builder(final RestContext context, - final VirtualAppliance virtualAppliance, final VirtualMachineTemplate template) - { - super(); - checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class); - this.virtualAppliance = virtualAppliance; - this.template = template; - this.context = context; - } - - public Builder nameLabel(final String nameLabel) - { - this.nameLabel = nameLabel; - return this; - } - - public Builder description(final String description) - { - this.description = description; - return this; - } - - public Builder ram(final int ram) - { - this.ram = ram; - return this; - } - - public Builder cpu(final int cpu) - { - this.cpu = cpu; - return this; - } - - public Builder password(final String password) - { - this.password = password; - return this; - } - - public Builder keymap(final String keymap) - { - this.keymap = keymap; - return this; - } - - public Builder dvd(final boolean dvd) - { - this.dvd = dvd; - return this; - } - - // This methods are used only to build a builder from an existing VirtualMachine but should - // never be used by the user. This fields are set automatically by Abiquo - - private Builder vncPort(final int vdrpPort) - { - this.vncPort = vdrpPort; - return this; - } - - private Builder vncAddress(final String vdrpIP) - { - this.vncAddress = vdrpIP; - return this; - } - - private Builder idState(final int idState) - { - this.idState = idState; - return this; - } - - private Builder idType(final int idType) - { - this.idType = idType; - return this; - } - - private Builder internalName(final String internalName) - { - this.internalName = internalName; - return this; - } - - public Builder virtualAppliance(final VirtualAppliance virtualAppliance) - { - checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class); - this.virtualAppliance = virtualAppliance; - return this; - } - - public VirtualMachine build() - { - VirtualMachineWithNodeExtendedDto dto = new VirtualMachineWithNodeExtendedDto(); - dto.setNodeName(nameLabel); - dto.setDescription(description); - dto.setHdInBytes(template.getHdRequired()); - dto.setVdrpIP(vncAddress); - - if (cpu != null) - { - dto.setCpu(cpu); - } - - if (ram != null) - { - dto.setRam(ram); - } - - if (vncPort != null) - { - dto.setVdrpPort(vncPort); - } - - if (idState != null) - { - dto.setIdState(idState); - } - - if (idType != null) - { - dto.setIdType(idType); - } - - if (internalName != null) - { - dto.setName(internalName); - } - - dto.setPassword(password); - dto.setKeymap(keymap); - dto.setUuid(uuid); - - // DVD - if (dvd) - { - DvdManagementDto dvd = new DvdManagementDto(); - RESTLink link = new RESTLink("image", ""); - dvd.addLink(link); - dto.setDvd(dvd); - } - - VirtualMachine virtualMachine = new VirtualMachine(context, dto); - virtualMachine.virtualAppliance = virtualAppliance; - virtualMachine.template = template; - - return virtualMachine; - } - - public static Builder fromVirtualMachine(final VirtualMachine in) - { - return VirtualMachine.builder(in.context, in.virtualAppliance, in.template) - .internalName(in.getInternalName()).nameLabel(in.getNameLabel()) - .description(in.getDescription()).ram(in.getRam()).cpu(in.getCpu()) - .vncAddress(in.getVncAddress()).vncPort(in.getVncPort()).idState(in.getIdState()) - .idType(in.getIdType()).password(in.getPassword()).keymap(in.getKeymap()) - .dvd(in.hasDvd()); - } - } - - // Delegate methods - - public int getCpu() - { - return target.getCpu(); - } - - public String getDescription() - { - return target.getDescription(); - } - - // Read-only field. This value is computed from the size of the Template - public long getHdInBytes() - { - return target.getHdInBytes(); - } - - public Integer getId() - { - return target.getId(); - } - - public int getIdState() - { - return target.getIdState(); - } - - public int getIdType() - { - return target.getIdType(); - } - - public String getNameLabel() - { - return target.getNodeName(); - } - - public String getOwnerName() - { - return target.getUserName() + " " + target.getUserSurname(); - } - - public String getInternalName() - { - return target.getName(); - } - - public String getPassword() - { - return target.getPassword(); - } - - public int getRam() - { - return target.getRam(); - } - - public String getUuid() - { - return target.getUuid(); - } - - public String getVncAddress() - { - return target.getVdrpIP(); - } - - public int getVncPort() - { - return target.getVdrpPort(); - } - - public String getKeymap() - { - return target.getKeymap(); - } - - public void setCpu(final int cpu) - { - target.setCpu(cpu); - } - - public void setDescription(final String description) - { - target.setDescription(description); - } - - public void setNameLabel(final String nameLabel) - { - target.setNodeName(nameLabel); - } - - public void setPassword(final String password) - { - target.setPassword(password); - } - - public void setRam(final int ram) - { - target.setRam(ram); - } - - public void setKeymap(final String keymap) - { - target.setKeymap(keymap); - } - - private static VolumeManagementDto[] toVolumeDto(final Volume... volumes) - { - checkNotNull(volumes, "must provide at least one volume"); - - VolumeManagementDto[] dtos = new VolumeManagementDto[volumes.length]; - for (int i = 0; i < volumes.length; i++) - { - dtos[i] = volumes[i].unwrap(); - } - - return dtos; - } - - private static DiskManagementDto[] toHardDiskDto(final HardDisk... hardDisks) - { - checkNotNull(hardDisks, "must provide at least one hard disk"); - - DiskManagementDto[] dtos = new DiskManagementDto[hardDisks.length]; - for (int i = 0; i < hardDisks.length; i++) - { - dtos[i] = hardDisks[i].unwrap(); - } - - return dtos; - } - - private static Predicate volumeIdIn(final Volume... volumes) - { - return new Predicate() - { - List ids = volumeIds(Arrays.asList(volumes)); - - @Override - public boolean apply(final Volume input) - { - return ids.contains(input.getId()); - } - }; - } - - private static Predicate hardDiskIdIn(final HardDisk... hardDisks) - { - return new Predicate() - { - List ids = hardDisksIds(Arrays.asList(hardDisks)); - - @Override - public boolean apply(final HardDisk input) - { - return ids.contains(input.getId()); - } - }; - } - - private static List volumeIds(final List volumes) - { - return Lists.transform(volumes, new Function() - { - @Override - public Integer apply(final Volume input) - { - return input.getId(); - } - }); - } - - private static List hardDisksIds(final List HardDisk) - { - return Lists.transform(HardDisk, new Function() - { - @Override - public Integer apply(final HardDisk input) - { - return input.getId(); - } - }); - } - - @Override - public String toString() - { - return "VirtualMachine [id=" + getId() + ", state=" + target.getState().name() + ", cpu=" - + getCpu() + ", description=" + getDescription() + ", hdInBytes=" + getHdInBytes() - + ", idType=" + getIdType() + ", nameLabel=" + getNameLabel() + ", internalName=" - + getInternalName() + ", password=" + getPassword() + ", ram=" + getRam() + ", uuid=" - + getUuid() + ", vncAddress=" + getVncAddress() + ", vncPort=" + getVncPort() - + ", keymap=" + getKeymap() + ", dvd=" + hasDvd() + "]"; - } +public class VirtualMachine extends DomainWithTasksWrapper { + /** The virtual appliance where the virtual machine belongs. */ + private VirtualAppliance virtualAppliance; + + /** The virtual machine template of the virtual machine. */ + private VirtualMachineTemplate template; + + /** + * Constructor to be used only by the builder. + */ + protected VirtualMachine(final RestContext context, + final VirtualMachineWithNodeExtendedDto target) { + super(context, target); + } + + // Domain operations + + /** + * Delete the virtual machine. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource -Deleteavirtualmachine + */ + public void delete() { + context.getApi().getCloudApi().deleteVirtualMachine(target); + target = null; + } + + /** + * Create a new virtual machine in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource-Createavirtualmachine + */ + public void save() { + checkNotNull(template, ValidationErrors.NULL_RESOURCE + VirtualMachineTemplate.class); + checkNotNull(template.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + VirtualMachineTemplate.class); + + this.updateLink(target, ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, template.unwrap(), "edit"); + + target = context.getApi().getCloudApi().createVirtualMachine(virtualAppliance.unwrap(), target); + } + + /** + * Update virtual machine information in the server with the data from this + * virtual machine. This is an asynchronous call. This method returns a + * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track + * of the task completion. Please refer to the documentation for details. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource-Modifyavirtualmachine + * @see github: https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor- + * example + * @return The task reference or null if the operation completed + * synchronously. + */ + public AsyncTask update() { + AcceptedRequestDto taskRef = context.getApi().getCloudApi().updateVirtualMachine(target); + return taskRef == null ? null : getTask(taskRef); + } + + /** + * Update virtual machine information in the server with the data from this + * virtual machine. This is an asynchronous call. This method returns a + * {@link org.jclouds.abiquo.domain.task.AsyncTask} object that keeps track + * of the task completion. Please refer to the documentation for details. + * + * @param force + * Force update. + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource-Modifyavirtualmachine + * @see github: https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor- + * example + * @return The task reference or null if the operation completed + * synchronously. + */ + public AsyncTask update(final boolean force) { + AcceptedRequestDto taskRef = context.getApi().getCloudApi() + .updateVirtualMachine(target, VirtualMachineOptions.builder().force(force).build()); + return taskRef == null ? null : getTask(taskRef); + } + + /** + * Change the state of the virtual machine. This is an asynchronous call. + * This method returns a {@link org.jclouds.abiquo.domain.task.AsyncTask} + * object that keeps track of the task completion. Please refer to the + * documentation for details. + * + * @param state + * The new state of the virtual machine. + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource-Changethestateofavirtualmachine + * @see github: https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor- + * example + * @return The task reference or null if the operation completed + * synchronously. + */ + public AsyncTask changeState(final VirtualMachineState state) { + VirtualMachineStateDto dto = new VirtualMachineStateDto(); + dto.setState(state); + + AcceptedRequestDto taskRef = context.getApi().getCloudApi().changeVirtualMachineState(target, dto); + + return getTask(taskRef); + } + + /** + * Retrieve the state of the virtual machine. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineResource# + * VirtualMachineResource-Retrievethestateofthevirtualmachine + * @return Current state of the virtual machine. + */ + public VirtualMachineState getState() { + VirtualMachineStateDto stateDto = context.getApi().getCloudApi().getVirtualMachineState(target); + VirtualMachineState state = stateDto.getState(); + target.setState(state); + target.setIdState(state.id()); + return state; + } + + public void refresh() { + RESTLink link = checkNotNull(target.getEditLink(), ValidationErrors.MISSING_REQUIRED_LINK + " edit"); + + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); + + ParseXMLWithJAXB parser = new ParseXMLWithJAXB( + utils.getXml(), TypeLiteral.get(VirtualMachineWithNodeExtendedDto.class)); + + target = parser.apply(response); + } + + // Parent access + + /** + * Retrieve the virtual appliance where this virtual machine is. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualApplianceResource# + * VirtualApplianceResource-Retrieveavirtualappliance + * @return The virtual appliance where this virtual machine is. + */ + public VirtualAppliance getVirtualAppliance() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.VIRTUAL_APPLIANCE), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.VIRTUAL_APPLIANCE); + + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); + + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VirtualApplianceDto.class)); + + return wrap(context, VirtualAppliance.class, parser.apply(response)); + } + + /** + * Retrieve the virtual datacenter where this virtual machine is. + * + * @see API: http://community.abiquo.com/display/ABI20/VirtualDatacenterResource + * # VirtualDatacenterResource-Retireveavirtualdatacenter + * @return The virtual datacenter where this virtual machine is. + */ + public VirtualDatacenter getVirtualDatacenter() { + Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); + VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); + return wrap(context, VirtualDatacenter.class, dto); + } + + /** + * Retrieve the enterprise of this virtual machine. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- RetrieveanEnterprise + * @return Enterprise of this virtual machine. + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + EnterpriseDto dto = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); + return wrap(context, Enterprise.class, dto); + } + + /** + * Retrieve the template of this virtual machine. + * + * @return Template of this virtual machine. + */ + public VirtualMachineTemplate getTemplate() { + VirtualMachineTemplateDto dto = context.getApi().getCloudApi().getVirtualMachineTemplate(target); + return wrap(context, VirtualMachineTemplate.class, dto); + } + + // Children access + + public List listAttachedHardDisks() { + refresh(); + DisksManagementDto hardDisks = context.getApi().getCloudApi().listAttachedHardDisks(target); + return wrap(context, HardDisk.class, hardDisks.getCollection()); + } + + public List listAttachedHardDisks(final Predicate filter) { + return Lists.newLinkedList(filter(listAttachedHardDisks(), filter)); + } + + public HardDisk findAttachedHardDisk(final Predicate filter) { + return Iterables.getFirst(filter(listAttachedHardDisks(), filter), null); + } + + public List listAttachedVolumes() { + refresh(); + VolumesManagementDto volumes = context.getApi().getCloudApi().listAttachedVolumes(target); + return wrap(context, Volume.class, volumes.getCollection()); + } + + public List listAttachedVolumes(final Predicate filter) { + return Lists.newLinkedList(filter(listAttachedVolumes(), filter)); + } + + public Volume findAttachedVolume(final Predicate filter) { + return Iterables.getFirst(filter(listAttachedVolumes(), filter), null); + } + + public List> listAttachedNics() { + // The strategy will refresh the vm. There is no need to do it here + ListAttachedNics strategy = context.getUtils().getInjector().getInstance(ListAttachedNics.class); + return Lists.newLinkedList(strategy.execute(this)); + } + + public List> listAttachedNics(final Predicate> filter) { + return Lists.newLinkedList(filter(listAttachedNics(), filter)); + } + + public Ip findAttachedNic(final Predicate> filter) { + return Iterables.getFirst(filter(listAttachedNics(), filter), null); + } + + // Actions + + public AsyncTask deploy() { + return deploy(false); + } + + public AsyncTask deploy(final boolean forceEnterpriseSoftLimits) { + VirtualMachineTaskDto force = new VirtualMachineTaskDto(); + force.setForceEnterpriseSoftLimits(forceEnterpriseSoftLimits); + + AcceptedRequestDto response = context.getApi().getCloudApi().deployVirtualMachine(unwrap(), force); + + return getTask(response); + } + + public AsyncTask undeploy() { + return undeploy(false); + } + + public AsyncTask undeploy(final boolean forceUndeploy) { + VirtualMachineTaskDto force = new VirtualMachineTaskDto(); + force.setForceUndeploy(forceUndeploy); + + AcceptedRequestDto response = context.getApi().getCloudApi().undeployVirtualMachine(unwrap(), force); + + return getTask(response); + } + + /** + * Reboot a virtual machine. This is an asynchronous call. This method + * returns a {@link org.jclouds.abiquo.domain.task.AsyncTask} object that + * keeps track of the task completion. Please refer to the documentation for + * details. + * + * @see API: http://community.abiquo.com/display/ABI20/Rack+Resource#/ + * VirtualMachineResource# + * VirtualMachineResource-Resetavirtualmachine + * @see github: https://github.com/abiquo/jclouds-abiquo/wiki/Asynchronous-monitor- + * example + * @return The task reference or null if the operation completed + * synchronously. + */ + public AsyncTask reboot() { + AcceptedRequestDto response = context.getApi().getCloudApi().rebootVirtualMachine(unwrap()); + + return getTask(response); + } + + public AsyncTask attachHardDisks(final HardDisk... hardDisks) { + List expected = listAttachedHardDisks(); + expected.addAll(Arrays.asList(hardDisks)); + + HardDisk[] disks = new HardDisk[expected.size()]; + return setHardDisks(expected.toArray(disks)); + } + + public AsyncTask detachAllHardDisks() { + AcceptedRequestDto taskRef = context.getApi().getCloudApi().detachAllHardDisks(target); + return taskRef == null ? null : getTask(taskRef); + } + + public AsyncTask detachHardDisks(final HardDisk... hardDisks) { + List expected = listAttachedHardDisks(); + Iterables.removeIf(expected, hardDiskIdIn(hardDisks)); + + HardDisk[] disks = new HardDisk[expected.size()]; + return setHardDisks(expected.toArray(disks)); + } + + public AsyncTask setHardDisks(final HardDisk... hardDisks) { + AcceptedRequestDto taskRef = context.getApi().getCloudApi() + .replaceHardDisks(target, toHardDiskDto(hardDisks)); + return taskRef == null ? null : getTask(taskRef); + } + + public AsyncTask attachVolumes(final Volume... volumes) { + List expected = listAttachedVolumes(); + expected.addAll(Arrays.asList(volumes)); + + Volume[] vols = new Volume[expected.size()]; + return setVolumes(true, expected.toArray(vols)); + } + + public AsyncTask detachAllVolumes() { + AcceptedRequestDto taskRef = context.getApi().getCloudApi().detachAllVolumes(target); + return taskRef == null ? null : getTask(taskRef); + } + + public AsyncTask detachVolumes(final Volume... volumes) { + List expected = listAttachedVolumes(); + Iterables.removeIf(expected, volumeIdIn(volumes)); + + Volume[] vols = new Volume[expected.size()]; + return setVolumes(true, expected.toArray(vols)); + } + + public AsyncTask setVolumes(final Boolean forceSoftLimits, final Volume... volumes) { + AcceptedRequestDto taskRef = context + .getApi() + .getCloudApi() + .replaceVolumes(target, VirtualMachineOptions.builder().force(forceSoftLimits).build(), + toVolumeDto(volumes)); + + return taskRef == null ? null : getTask(taskRef); + } + + public AsyncTask setVolumes(final Volume... volumes) { + return setVolumes(true, volumes); + } + + public AsyncTask setNics(final List> ips) { + // By default the network of the first ip will be used as a gateway + return setNics(ips != null && !ips.isEmpty() ? ips.get(0).getNetwork() : null, ips, null); + } + + public AsyncTask setNics(final List> ips, final List unmanagetNetworks) { + // By default the network of the first ip will be used as a gateway + Network gateway = null; + if (ips != null && !ips.isEmpty()) { + gateway = ips.get(0).getNetwork(); + } else if (unmanagetNetworks != null && !unmanagetNetworks.isEmpty()) { + gateway = unmanagetNetworks.get(0); + } + + return setNics(gateway, ips, unmanagetNetworks); + } + + public AsyncTask setNics(final Network gatewayNetwork, final List> ips) { + return setNics(gatewayNetwork, ips, null); + } + + public AsyncTask setNics(final Network gatewayNetwork, final List> ips, + final List unmanagetNetworks) { + // Remove the gateway configuration and the current nics + Iterables.removeIf(target.getLinks(), + Predicates.or(LinkPredicates.isNic(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY))); + + // Add the given nics in the appropriate order + int i = 0; + if (ips != null) { + for (i = 0; i < ips.size(); i++) { + RESTLink source = LinkUtils.getSelfLink(ips.get(i).unwrap()); + RESTLink link = new RESTLink("nic" + i, source.getHref()); + link.setType(ips.get(i).unwrap().getBaseMediaType()); + target.addLink(link); + } + } + + // Add unmanaged network references, if given + if (unmanagetNetworks != null) { + for (UnmanagedNetwork unmanaged : unmanagetNetworks) { + RESTLink source = checkNotNull(unmanaged.unwrap().searchLink("ips"), ValidationErrors.MISSING_REQUIRED_LINK + + "ips"); + + RESTLink link = new RESTLink("nic" + i, source.getHref()); + link.setType(UnmanagedIpDto.BASE_MEDIA_TYPE); + target.addLink(link); + i++; + } + } + + AsyncTask task = update(true); + if (gatewayNetwork == null) { + return task; + } + + // If there is a gateway network, we have to wait until the network + // configuration links are + // available + if (task != null) { + VirtualMachineState originalState = target.getState(); + VirtualMachineMonitor monitor = context.getUtils().getInjector().getInstance(MonitoringService.class) + .getVirtualMachineMonitor(); + monitor.awaitState(originalState, this); + } + + // Set the new network configuration + + // Refresh virtual machine, to get the new configuration links + refresh(); + + VMNetworkConfigurationsDto configs = context.getApi().getCloudApi().listNetworkConfigurations(target); + + Iterables.removeIf(target.getLinks(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY)); + for (VMNetworkConfigurationDto config : configs.getCollection()) { + if (config.getGateway().equalsIgnoreCase(gatewayNetwork.getGateway())) { + target.addLink(new RESTLink(ParentLinkName.NETWORK_GATEWAY, config.getEditLink().getHref())); + break; + } + } + + return update(true); + } + + // TODO: Get current gateway network + + public void setGatewayNetwork(final Network network) { + context.getApi().getCloudApi().setGatewayNetwork(target, network.unwrap()); + refresh(); // First refresh the target and its links + } + + /** + * Checks if the virtual machine is persistent. + *

+ * Persistent virtual machines have the system disc in an external volume. + * This way, when the virtual machine is undeployed, the contents of the + * system disk remain in the storage device and the user can deploy the + * virtual machine again without losing the data in the system disk. + * + * @return Boolean indicating if the virtual machine is persistent. + */ + public boolean isPersistent() { + return getTemplate().unwrap().searchLink("volume") != null; + } + + public boolean hasDvd() { + return target.getDvd() != null; + } + + public void attachDvd() { + DvdManagementDto dvd = new DvdManagementDto(); + RESTLink link = new RESTLink("image", ""); + dvd.addLink(link); + target.setDvd(dvd); + } + + public void detachDvd() { + target.setDvd(null); + } + + // Builder + + public static Builder builder(final RestContext context, + final VirtualAppliance virtualAppliance, final VirtualMachineTemplate template) { + return new Builder(context, virtualAppliance, template); + } + + public static class Builder { + private final RestContext context; + + private VirtualAppliance virtualAppliance; + + private final VirtualMachineTemplate template; + + private String nameLabel; + + private String internalName; + + private String description; + + private Integer ram; + + private Integer cpu; + + private Integer vncPort; + + private String vncAddress; + + private Integer idState; + + private Integer idType; + + private String password; + + private String keymap; + + private String uuid; + + private boolean dvd; + + public Builder(final RestContext context, final VirtualAppliance virtualAppliance, + final VirtualMachineTemplate template) { + super(); + checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class); + this.virtualAppliance = virtualAppliance; + this.template = template; + this.context = context; + } + + public Builder nameLabel(final String nameLabel) { + this.nameLabel = nameLabel; + return this; + } + + public Builder description(final String description) { + this.description = description; + return this; + } + + public Builder ram(final int ram) { + this.ram = ram; + return this; + } + + public Builder cpu(final int cpu) { + this.cpu = cpu; + return this; + } + + public Builder password(final String password) { + this.password = password; + return this; + } + + public Builder keymap(final String keymap) { + this.keymap = keymap; + return this; + } + + public Builder dvd(final boolean dvd) { + this.dvd = dvd; + return this; + } + + // This methods are used only to build a builder from an existing + // VirtualMachine but should + // never be used by the user. This fields are set automatically by Abiquo + + private Builder vncPort(final int vdrpPort) { + this.vncPort = vdrpPort; + return this; + } + + private Builder vncAddress(final String vdrpIP) { + this.vncAddress = vdrpIP; + return this; + } + + private Builder idState(final int idState) { + this.idState = idState; + return this; + } + + private Builder idType(final int idType) { + this.idType = idType; + return this; + } + + private Builder internalName(final String internalName) { + this.internalName = internalName; + return this; + } + + public Builder virtualAppliance(final VirtualAppliance virtualAppliance) { + checkNotNull(virtualAppliance, ValidationErrors.NULL_RESOURCE + VirtualAppliance.class); + this.virtualAppliance = virtualAppliance; + return this; + } + + public VirtualMachine build() { + VirtualMachineWithNodeExtendedDto dto = new VirtualMachineWithNodeExtendedDto(); + dto.setNodeName(nameLabel); + dto.setDescription(description); + dto.setHdInBytes(template.getHdRequired()); + dto.setVdrpIP(vncAddress); + + if (cpu != null) { + dto.setCpu(cpu); + } + + if (ram != null) { + dto.setRam(ram); + } + + if (vncPort != null) { + dto.setVdrpPort(vncPort); + } + + if (idState != null) { + dto.setIdState(idState); + } + + if (idType != null) { + dto.setIdType(idType); + } + + if (internalName != null) { + dto.setName(internalName); + } + + dto.setPassword(password); + dto.setKeymap(keymap); + dto.setUuid(uuid); + + // DVD + if (dvd) { + DvdManagementDto dvd = new DvdManagementDto(); + RESTLink link = new RESTLink("image", ""); + dvd.addLink(link); + dto.setDvd(dvd); + } + + VirtualMachine virtualMachine = new VirtualMachine(context, dto); + virtualMachine.virtualAppliance = virtualAppliance; + virtualMachine.template = template; + + return virtualMachine; + } + + public static Builder fromVirtualMachine(final VirtualMachine in) { + return VirtualMachine.builder(in.context, in.virtualAppliance, in.template).internalName(in.getInternalName()) + .nameLabel(in.getNameLabel()).description(in.getDescription()).ram(in.getRam()).cpu(in.getCpu()) + .vncAddress(in.getVncAddress()).vncPort(in.getVncPort()).idState(in.getIdState()).idType(in.getIdType()) + .password(in.getPassword()).keymap(in.getKeymap()).dvd(in.hasDvd()); + } + } + + // Delegate methods + + public int getCpu() { + return target.getCpu(); + } + + public String getDescription() { + return target.getDescription(); + } + + // Read-only field. This value is computed from the size of the Template + public long getHdInBytes() { + return target.getHdInBytes(); + } + + public Integer getId() { + return target.getId(); + } + + public int getIdState() { + return target.getIdState(); + } + + public int getIdType() { + return target.getIdType(); + } + + public String getNameLabel() { + return target.getNodeName(); + } + + public String getOwnerName() { + return target.getUserName() + " " + target.getUserSurname(); + } + + public String getInternalName() { + return target.getName(); + } + + public String getPassword() { + return target.getPassword(); + } + + public int getRam() { + return target.getRam(); + } + + public String getUuid() { + return target.getUuid(); + } + + public String getVncAddress() { + return target.getVdrpIP(); + } + + public int getVncPort() { + return target.getVdrpPort(); + } + + public String getKeymap() { + return target.getKeymap(); + } + + public void setCpu(final int cpu) { + target.setCpu(cpu); + } + + public void setDescription(final String description) { + target.setDescription(description); + } + + public void setNameLabel(final String nameLabel) { + target.setNodeName(nameLabel); + } + + public void setPassword(final String password) { + target.setPassword(password); + } + + public void setRam(final int ram) { + target.setRam(ram); + } + + public void setKeymap(final String keymap) { + target.setKeymap(keymap); + } + + private static VolumeManagementDto[] toVolumeDto(final Volume... volumes) { + checkNotNull(volumes, "must provide at least one volume"); + + VolumeManagementDto[] dtos = new VolumeManagementDto[volumes.length]; + for (int i = 0; i < volumes.length; i++) { + dtos[i] = volumes[i].unwrap(); + } + + return dtos; + } + + private static DiskManagementDto[] toHardDiskDto(final HardDisk... hardDisks) { + checkNotNull(hardDisks, "must provide at least one hard disk"); + + DiskManagementDto[] dtos = new DiskManagementDto[hardDisks.length]; + for (int i = 0; i < hardDisks.length; i++) { + dtos[i] = hardDisks[i].unwrap(); + } + + return dtos; + } + + private static Predicate volumeIdIn(final Volume... volumes) { + return new Predicate() { + List ids = volumeIds(Arrays.asList(volumes)); + + @Override + public boolean apply(final Volume input) { + return ids.contains(input.getId()); + } + }; + } + + private static Predicate hardDiskIdIn(final HardDisk... hardDisks) { + return new Predicate() { + List ids = hardDisksIds(Arrays.asList(hardDisks)); + + @Override + public boolean apply(final HardDisk input) { + return ids.contains(input.getId()); + } + }; + } + + private static List volumeIds(final List volumes) { + return Lists.transform(volumes, new Function() { + @Override + public Integer apply(final Volume input) { + return input.getId(); + } + }); + } + + private static List hardDisksIds(final List HardDisk) { + return Lists.transform(HardDisk, new Function() { + @Override + public Integer apply(final HardDisk input) { + return input.getId(); + } + }); + } + + @Override + public String toString() { + return "VirtualMachine [id=" + getId() + ", state=" + target.getState().name() + ", cpu=" + getCpu() + + ", description=" + getDescription() + ", hdInBytes=" + getHdInBytes() + ", idType=" + getIdType() + + ", nameLabel=" + getNameLabel() + ", internalName=" + getInternalName() + ", password=" + getPassword() + + ", ram=" + getRam() + ", uuid=" + getUuid() + ", vncAddress=" + getVncAddress() + ", vncPort=" + + getVncPort() + ", keymap=" + getKeymap() + ", dvd=" + hasDvd() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java index 924f28a9f5..4f0f4832d9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplate.java @@ -65,353 +65,316 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource + * @see API: + * http://community.abiquo.com/display/ABI20/Virtual+Machine+Template+Resource + * */ -public class VirtualMachineTemplate extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected VirtualMachineTemplate(final RestContext context, - final VirtualMachineTemplateDto target) - { - super(context, target); - } +public class VirtualMachineTemplate extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected VirtualMachineTemplate(final RestContext context, + final VirtualMachineTemplateDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void delete() - { - context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target); - target = null; - } + public void delete() { + context.getApi().getVirtualMachineTemplateApi().deleteVirtualMachineTemplate(target); + target = null; + } - public void update() - { - target = - context.getApi().getVirtualMachineTemplateApi().updateVirtualMachineTemplate(target); - } + public void update() { + target = context.getApi().getVirtualMachineTemplateApi().updateVirtualMachineTemplate(target); + } - /** - * TODO - * - * @param vdc - * @param volume - * @param persistentTemplateName - * @param persistentVolumeName - * @return - */ - public AsyncTask makePersistent(final VirtualDatacenter vdc, final Volume volume, - final String persistentTemplateName) - { - RESTLink storageLink = volume.unwrap().getEditLink(); - storageLink.setRel("volume"); - return makePeristent(vdc, storageLink, persistentTemplateName, null); - } + /** + * TODO + * + * @param vdc + * @param volume + * @param persistentTemplateName + * @param persistentVolumeName + * @return + */ + public AsyncTask makePersistent(final VirtualDatacenter vdc, final Volume volume, final String persistentTemplateName) { + RESTLink storageLink = volume.unwrap().getEditLink(); + storageLink.setRel("volume"); + return makePeristent(vdc, storageLink, persistentTemplateName, null); + } - public AsyncTask makePersistent(final VirtualDatacenter vdc, final Tier tier, - final String persistentTemplateName, final String persistentVolumeName) - { - // infrastructure - RESTLink storageLink = tier.unwrap().getEditLink(); - if (storageLink == null) - { - // cloud - storageLink = tier.unwrap().searchLink("self"); - } - storageLink.setRel(ParentLinkName.TIER); - return makePeristent(vdc, storageLink, persistentTemplateName, persistentVolumeName); - } + public AsyncTask makePersistent(final VirtualDatacenter vdc, final Tier tier, final String persistentTemplateName, + final String persistentVolumeName) { + // infrastructure + RESTLink storageLink = tier.unwrap().getEditLink(); + if (storageLink == null) { + // cloud + storageLink = tier.unwrap().searchLink("self"); + } + storageLink.setRel(ParentLinkName.TIER); + return makePeristent(vdc, storageLink, persistentTemplateName, persistentVolumeName); + } - private AsyncTask makePeristent(final VirtualDatacenter vdc, final RESTLink storageLink, - final String persistentTemplateName, final String persistentVolumeName) - { - VirtualMachineTemplatePersistentDto persistentData = - new VirtualMachineTemplatePersistentDto(); - persistentData.setPersistentTemplateName(persistentTemplateName); - persistentData.setPersistentVolumeName(persistentVolumeName); - RESTLink vdcLink = - new RESTLink(ParentLinkName.VIRTUAL_DATACENTER, vdc.unwrap().getEditLink().getHref()); - RESTLink templateLink = - new RESTLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, target.getEditLink().getHref()); + private AsyncTask makePeristent(final VirtualDatacenter vdc, final RESTLink storageLink, + final String persistentTemplateName, final String persistentVolumeName) { + VirtualMachineTemplatePersistentDto persistentData = new VirtualMachineTemplatePersistentDto(); + persistentData.setPersistentTemplateName(persistentTemplateName); + persistentData.setPersistentVolumeName(persistentVolumeName); + RESTLink vdcLink = new RESTLink(ParentLinkName.VIRTUAL_DATACENTER, vdc.unwrap().getEditLink().getHref()); + RESTLink templateLink = new RESTLink(ParentLinkName.VIRTUAL_MACHINE_TEMPLATE, target.getEditLink().getHref()); - persistentData.addLink(vdcLink); - persistentData.addLink(storageLink); - persistentData.addLink(templateLink); + persistentData.addLink(vdcLink); + persistentData.addLink(storageLink); + persistentData.addLink(templateLink); - // SCG: - // A simple user should not have permissions to obtain a datacenter repository, but at this - // point we have the datacenter repository and enterprise ids in the own target uri. So we - // can obtain the path where do the POST - // Assumption that to create a new object a user needs to get the parent object cannot be - // applied in this case - String editUri = getURI().getPath(); - Pattern p = Pattern.compile("\\d+"); - Matcher m = p.matcher(editUri); - m.find(); - Integer idEnt = new Integer(m.group()); - m.find(); - Integer idDcRepo = new Integer(m.group()); + // SCG: + // A simple user should not have permissions to obtain a datacenter + // repository, but at this + // point we have the datacenter repository and enterprise ids in the own + // target uri. So we + // can obtain the path where do the POST + // Assumption that to create a new object a user needs to get the parent + // object cannot be + // applied in this case + String editUri = getURI().getPath(); + Pattern p = Pattern.compile("\\d+"); + Matcher m = p.matcher(editUri); + m.find(); + Integer idEnt = new Integer(m.group()); + m.find(); + Integer idDcRepo = new Integer(m.group()); - AcceptedRequestDto response = - context.getApi().getVirtualMachineTemplateApi() - .createPersistentVirtualMachineTemplate(idEnt, idDcRepo, persistentData); + AcceptedRequestDto response = context.getApi().getVirtualMachineTemplateApi() + .createPersistentVirtualMachineTemplate(idEnt, idDcRepo, persistentData); - return getTask(response); - } + return getTask(response); + } - // Children access + // Children access - /** - * @see API: http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource- - * Retrieveacategory - */ - public Category getCategory() - { - Integer categoryId = target.getIdFromLink(ParentLinkName.CATEGORY); - CategoryDto category = context.getApi().getConfigApi().getCategory(categoryId); - return wrap(context, Category.class, category); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Category+Resource# + * CategoryResource- Retrieveacategory + */ + public Category getCategory() { + Integer categoryId = target.getIdFromLink(ParentLinkName.CATEGORY); + CategoryDto category = context.getApi().getConfigApi().getCategory(categoryId); + return wrap(context, Category.class, category); + } - /** - * @see API: http://community.abiquo.com/display/Abiquo/Volume+Resource#VolumeResource- - * Retrieveavolume - */ - public Volume getVolume() - { - if (this.isPersistent()) - { - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse rp = - checkNotNull(utils.getAbiquoHttpClient().get(target.searchLink("volume")), "volume"); + /** + * @see API: http://community.abiquo.com/display/Abiquo/Volume+Resource# + * VolumeResource- Retrieveavolume + */ + public Volume getVolume() { + if (this.isPersistent()) { + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse rp = checkNotNull(utils.getAbiquoHttpClient().get(target.searchLink("volume")), "volume"); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VolumeManagementDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VolumeManagementDto.class)); - VolumeManagementDto dto = parser.apply(rp); - return new Volume(context, dto); - } - return null; - } + VolumeManagementDto dto = parser.apply(rp); + return new Volume(context, dto); + } + return null; + } - public boolean isPersistent() - { - return target.searchLink("volume") != null; - } + public boolean isPersistent() { + return target.searchLink("volume") != null; + } - // Parent access + // Parent access - /** - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * RetrieveanEnterprise - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - return wrap(context, Enterprise.class, - context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- RetrieveanEnterprise + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource- - * RetrieveaDatacenter - */ - public Datacenter getDatacenter() - { - Integer repositoryId = target.getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY); - return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi() - .getDatacenter(repositoryId)); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource# + * DatacenterResource- RetrieveaDatacenter + */ + public Datacenter getDatacenter() { + Integer repositoryId = target.getIdFromLink(ParentLinkName.DATACENTER_REPOSITORY); + return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(repositoryId)); + } - /** - * List all the conversions for the virtual machine template. - * - * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource- - * ListConversions - * @return all the conversions of the virtual machine template - */ - public List listConversions() - { - ConversionsDto convs = - context.getApi().getVirtualMachineTemplateApi().listConversions(target); - return wrap(context, Conversion.class, convs.getCollection()); - } + /** + * List all the conversions for the virtual machine template. + * + * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource# + * ConversionResource- ListConversions + * @return all the conversions of the virtual machine template + */ + public List listConversions() { + ConversionsDto convs = context.getApi().getVirtualMachineTemplateApi().listConversions(target); + return wrap(context, Conversion.class, convs.getCollection()); + } - /** - * List all the conversions for the virtual machine template matching the given filter. - * - * @param filter The filter to apply. - * @return The list all the conversions for the virtual machine template matching the given - * filter. - */ - public List listConversions(final Predicate filter) - { - return Lists.newLinkedList(filter(listConversions(), filter)); - } + /** + * List all the conversions for the virtual machine template matching the + * given filter. + * + * @param filter + * The filter to apply. + * @return The list all the conversions for the virtual machine template + * matching the given filter. + */ + public List listConversions(final Predicate filter) { + return Lists.newLinkedList(filter(listConversions(), filter)); + } - /** - * Gets a single conversion in the virtual machine template matching the given filter. - * - * @param filter The filter to apply. - * @return The conversion or null if none matched the given filter. - */ - public Conversion findConversion(final Predicate filter) - { - return Iterables.getFirst(filter(listConversions(), filter), null); - } + /** + * Gets a single conversion in the virtual machine template matching the + * given filter. + * + * @param filter + * The filter to apply. + * @return The conversion or null if none matched the given + * filter. + */ + public Conversion findConversion(final Predicate filter) { + return Iterables.getFirst(filter(listConversions(), filter), null); + } - /** - * List conversions for a virtual machine template. - * - * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource- - * ListConversions - * @param hypervisor, Optionally filter conversions compatible with the provided hypervisor - * @param state, Optionally filter conversions with the desired state - * @return all the conversions of the virtual machine template applying the constrains - */ - public List listConversions(final HypervisorType hypervisor, - final ConversionState state) - { - ConversionsDto convs = - context - .getApi() - .getVirtualMachineTemplateApi() - .listConversions( - target, - ConversionOptions.builder().hypervisorType(hypervisor).conversionState(state) - .build()); - return wrap(context, Conversion.class, convs.getCollection()); - } + /** + * List conversions for a virtual machine template. + * + * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource# + * ConversionResource- ListConversions + * @param hypervisor + * , Optionally filter conversions compatible with the provided + * hypervisor + * @param state + * , Optionally filter conversions with the desired state + * @return all the conversions of the virtual machine template applying the + * constrains + */ + public List listConversions(final HypervisorType hypervisor, final ConversionState state) { + ConversionsDto convs = context + .getApi() + .getVirtualMachineTemplateApi() + .listConversions(target, + ConversionOptions.builder().hypervisorType(hypervisor).conversionState(state).build()); + return wrap(context, Conversion.class, convs.getCollection()); + } - /** - * Starts a new conversion for a virtual machine template. - * - * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource#ConversionResource- - * RequestConversion - * @param diskFormat, desired target format for the request template - * @return The task reference to track its progress - */ - public AsyncTask requestConversion(final DiskFormatType diskFormat) - { - ConversionDto request = new ConversionDto(); - request.setTargetFormat(diskFormat); + /** + * Starts a new conversion for a virtual machine template. + * + * @see API: http://community.abiquo.com/display/ABI20/Conversion+Resource# + * ConversionResource- RequestConversion + * @param diskFormat + * , desired target format for the request template + * @return The task reference to track its progress + */ + public AsyncTask requestConversion(final DiskFormatType diskFormat) { + ConversionDto request = new ConversionDto(); + request.setTargetFormat(diskFormat); - AcceptedRequestDto taskRef = - context.getApi().getVirtualMachineTemplateApi() - .requestConversion(target, diskFormat, request); + AcceptedRequestDto taskRef = context.getApi().getVirtualMachineTemplateApi() + .requestConversion(target, diskFormat, request); - return taskRef == null ? null : getTask(taskRef); - } + return taskRef == null ? null : getTask(taskRef); + } - public CostCode getCostCode() - { - Integer costcodeId = target.getIdFromLink(ParentLinkName.COST_CODE); - CostCodeDto costcode = context.getApi().getPricingApi().getCostCode(costcodeId); - return wrap(context, CostCode.class, costcode); - } + public CostCode getCostCode() { + Integer costcodeId = target.getIdFromLink(ParentLinkName.COST_CODE); + CostCodeDto costcode = context.getApi().getPricingApi().getCostCode(costcodeId); + return wrap(context, CostCode.class, costcode); + } - // Delegate methods + // Delegate methods - public int getCpuRequired() - { - return target.getCpuRequired(); - } + public int getCpuRequired() { + return target.getCpuRequired(); + } - public Date getCreationDate() - { - return target.getCreationDate(); - } + public Date getCreationDate() { + return target.getCreationDate(); + } - public String getCreationUser() - { - return target.getCreationUser(); - } + public String getCreationUser() { + return target.getCreationUser(); + } - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public long getDiskFileSize() - { - return target.getDiskFileSize(); - } + public long getDiskFileSize() { + return target.getDiskFileSize(); + } - public DiskFormatType getDiskFormatType() - { - return DiskFormatType.valueOf(target.getDiskFormatType()); - } + public DiskFormatType getDiskFormatType() { + return DiskFormatType.valueOf(target.getDiskFormatType()); + } - public long getHdRequired() - { - return target.getHdRequired(); - } + public long getHdRequired() { + return target.getHdRequired(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getPath() - { - return target.getPath(); - } + public String getPath() { + return target.getPath(); + } - public int getRamRequired() - { - return target.getRamRequired(); - } + public int getRamRequired() { + return target.getRamRequired(); + } - public boolean isChefEnabled() - { - return target.isChefEnabled(); - } + public boolean isChefEnabled() { + return target.isChefEnabled(); + } - public void setChefEnabled(final boolean chefEnabled) - { - target.setChefEnabled(chefEnabled); - } + public void setChefEnabled(final boolean chefEnabled) { + target.setChefEnabled(chefEnabled); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getIconUrl() - { - return target.getIconUrl(); - } + public String getIconUrl() { + return target.getIconUrl(); + } - @Override - public String toString() - { - return "VirtualMachineTemplate [id=" + getId() + ", cpuRequired=" + getCpuRequired() - + ", creationDate=" + getCreationDate() + ", creationUser=" + getCreationUser() - + ", description=" + getDescription() + ", diskFileSize=" + getDiskFileSize() - + ", diskFormatType=" + getDiskFormatType() + ", hdRequired=" + getHdRequired() - + ", name=" + getName() + ", path=" + getPath() + ", ramRequired=" + getRamRequired() + @Override + public String toString() { + return "VirtualMachineTemplate [id=" + getId() + ", cpuRequired=" + getCpuRequired() + ", creationDate=" + + getCreationDate() + ", creationUser=" + getCreationUser() + ", description=" + getDescription() + + ", diskFileSize=" + getDiskFileSize() + ", diskFormatType=" + getDiskFormatType() + ", hdRequired=" + + getHdRequired() + ", name=" + getName() + ", path=" + getPath() + ", ramRequired=" + getRamRequired() + ", chefEnabled=" + isChefEnabled() + "]"; - } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java index 049123ed72..e5bb53053c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateInVirtualDatacenter.java @@ -21,33 +21,28 @@ package org.jclouds.abiquo.domain.cloud; import static com.google.common.base.Preconditions.checkNotNull; /** - * Wrapper to hold the information of a virtual machine template scoped to a concrete hypervisor - * type. + * Wrapper to hold the information of a virtual machine template scoped to a + * concrete hypervisor type. * * @author Ignasi Barrera */ -public class VirtualMachineTemplateInVirtualDatacenter -{ - private VirtualMachineTemplate template; +public class VirtualMachineTemplateInVirtualDatacenter { + private VirtualMachineTemplate template; - private VirtualDatacenter zone; + private VirtualDatacenter zone; - public VirtualMachineTemplateInVirtualDatacenter(final VirtualMachineTemplate template, - final VirtualDatacenter zone) - { - super(); - this.template = checkNotNull(template, "template"); - this.zone = checkNotNull(zone, "zone"); - } + public VirtualMachineTemplateInVirtualDatacenter(final VirtualMachineTemplate template, final VirtualDatacenter zone) { + super(); + this.template = checkNotNull(template, "template"); + this.zone = checkNotNull(zone, "zone"); + } - public VirtualMachineTemplate getTemplate() - { - return template; - } + public VirtualMachineTemplate getTemplate() { + return template; + } - public VirtualDatacenter getZone() - { - return zone; - } + public VirtualDatacenter getZone() { + return zone; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java index a8d4f4d1fe..9315d37feb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/Volume.java @@ -42,209 +42,183 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * Adds high level functionality to {@link VolumeManagementDto}. * * @author Ignasi Barrera - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Volume+Resource */ @EnterpriseEdition -public class Volume extends DomainWrapper -{ - /** The default state for folumes. */ - public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED; +public class Volume extends DomainWrapper { + /** The default state for folumes. */ + public static final VolumeState DEFAULT_STATE = VolumeState.DETACHED; - /** The virtual datacenter where the volume belongs. */ - private VirtualDatacenter virtualDatacenter; + /** The virtual datacenter where the volume belongs. */ + private VirtualDatacenter virtualDatacenter; - /** The tier where the volume belongs. */ - private Tier tier; + /** The tier where the volume belongs. */ + private Tier tier; - /** - * Constructor to be used only by the builder. - */ - protected Volume(final RestContext context, final VolumeManagementDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Volume(final RestContext context, final VolumeManagementDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void delete() - { - context.getApi().getCloudApi().deleteVolume(target); - target = null; - } + public void delete() { + context.getApi().getCloudApi().deleteVolume(target); + target = null; + } - public void save() - { - target = context.getApi().getCloudApi().createVolume(virtualDatacenter.unwrap(), target); - } + public void save() { + target = context.getApi().getCloudApi().createVolume(virtualDatacenter.unwrap(), target); + } - public AsyncTask update() - { - AcceptedRequestDto taskRef = context.getApi().getCloudApi().updateVolume(target); - return taskRef == null ? null : getTask(taskRef); - } + public AsyncTask update() { + AcceptedRequestDto taskRef = context.getApi().getCloudApi().updateVolume(target); + return taskRef == null ? null : getTask(taskRef); + } - // Parent access + // Parent access - /** - * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+Resource# - * VirtualDatacenterResource-RetrieveaVirtualDatacenter - */ - public VirtualDatacenter getVirtualDatacenter() - { - Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); - VirtualDatacenterDto dto = - context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); - virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); - return virtualDatacenter; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Virtual+Datacenter+ + * Resource# VirtualDatacenterResource-RetrieveaVirtualDatacenter + */ + public VirtualDatacenter getVirtualDatacenter() { + Integer virtualDatacenterId = target.getIdFromLink(ParentLinkName.VIRTUAL_DATACENTER); + VirtualDatacenterDto dto = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); + virtualDatacenter = wrap(context, VirtualDatacenter.class, dto); + return virtualDatacenter; + } - /** - * TODO javadoc link - */ - public Tier getTier() - { - Integer tierId = target.getIdFromLink(ParentLinkName.TIER); - TierDto dto = - context.getApi().getCloudApi().getStorageTier(virtualDatacenter.unwrap(), tierId); - tier = wrap(context, Tier.class, dto); - return tier; - } + /** + * TODO javadoc link + */ + public Tier getTier() { + Integer tierId = target.getIdFromLink(ParentLinkName.TIER); + TierDto dto = context.getApi().getCloudApi().getStorageTier(virtualDatacenter.unwrap(), tierId); + tier = wrap(context, Tier.class, dto); + return tier; + } - // Actions + // Actions - /** - * Move the volume to the given virtual datacenter. - * - * @param newVirtualDatacenter The destination virtual datacenter. - */ - public void moveTo(final VirtualDatacenter newVirtualDatacenter) - { - target = - context.getApi().getCloudApi().moveVolume(unwrap(), newVirtualDatacenter.unwrap()); - } + /** + * Move the volume to the given virtual datacenter. + * + * @param newVirtualDatacenter + * The destination virtual datacenter. + */ + public void moveTo(final VirtualDatacenter newVirtualDatacenter) { + target = context.getApi().getCloudApi().moveVolume(unwrap(), newVirtualDatacenter.unwrap()); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final VirtualDatacenter virtualDatacenter, final Tier tier) - { - return new Builder(context, virtualDatacenter, tier); - } + public static Builder builder(final RestContext context, + final VirtualDatacenter virtualDatacenter, final Tier tier) { + return new Builder(context, virtualDatacenter, tier); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private String description; + private String description; - private Long sizeInMb; + private Long sizeInMb; - private VirtualDatacenter virtualDatacenter; + private VirtualDatacenter virtualDatacenter; - private Tier tier; + private Tier tier; - public Builder(final RestContext context, final VirtualDatacenter virtualDatacenter, - final Tier tier) - { - super(); - checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE - + VirtualDatacenter.class); - checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class); - this.context = context; - this.virtualDatacenter = virtualDatacenter; - this.tier = tier; - } + public Builder(final RestContext context, final VirtualDatacenter virtualDatacenter, + final Tier tier) { + super(); + checkNotNull(virtualDatacenter, ValidationErrors.NULL_RESOURCE + VirtualDatacenter.class); + checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class); + this.context = context; + this.virtualDatacenter = virtualDatacenter; + this.tier = tier; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder description(final String description) - { - this.description = description; - return this; - } + public Builder description(final String description) { + this.description = description; + return this; + } - public Builder sizeInMb(final long sizeInMb) - { - this.sizeInMb = sizeInMb; - return this; - } + public Builder sizeInMb(final long sizeInMb) { + this.sizeInMb = sizeInMb; + return this; + } - public Volume build() - { - VolumeManagementDto dto = new VolumeManagementDto(); - dto.setName(name); - dto.setDescription(description); - dto.setSizeInMB(sizeInMb); - dto.setState(DEFAULT_STATE.name()); + public Volume build() { + VolumeManagementDto dto = new VolumeManagementDto(); + dto.setName(name); + dto.setDescription(description); + dto.setSizeInMB(sizeInMb); + dto.setState(DEFAULT_STATE.name()); - RESTLink link = tier.unwrap().searchLink("self"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - dto.addLink(new RESTLink("tier", link.getHref())); + RESTLink link = tier.unwrap().searchLink("self"); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + dto.addLink(new RESTLink("tier", link.getHref())); - Volume volume = new Volume(context, dto); - volume.virtualDatacenter = virtualDatacenter; - volume.tier = tier; + Volume volume = new Volume(context, dto); + volume.virtualDatacenter = virtualDatacenter; + volume.tier = tier; - return volume; - } - } + return volume; + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getState() - { - return target.getState(); - } + public String getState() { + return target.getState(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public long getSizeInMB() - { - return target.getSizeInMB(); - } + public long getSizeInMB() { + return target.getSizeInMB(); + } - public void setSizeInMB(final long sizeInMB) - { - target.setSizeInMB(sizeInMB); - } + public void setSizeInMB(final long sizeInMB) { + target.setSizeInMB(sizeInMB); + } - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public void setDescription(final String description) - { - target.setDescription(description); - } + public void setDescription(final String description) { + target.setDescription(description); + } - @Override - public String toString() - { - return "Volume [id=" + getId() + ", state=" + getState() + ", name=" + getName() - + ", sizeInMB=" + getSizeInMB() + ", description=" + getDescription() + "]"; - } + @Override + public String toString() { + return "Volume [id=" + getId() + ", state=" + getState() + ", name=" + getName() + ", sizeInMB=" + getSizeInMB() + + ", description=" + getDescription() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java index 1d97f03333..e074f9e4b9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/ConversionOptions.java @@ -27,56 +27,47 @@ import com.abiquo.model.enumerator.HypervisorType; /** * Available options to filter virtual machine template conversions */ -public class ConversionOptions extends BaseHttpRequestOptions -{ +public class ConversionOptions extends BaseHttpRequestOptions { - public static Builder builder() - { - return new Builder(); - } + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - ConversionOptions options = new ConversionOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + ConversionOptions options = new ConversionOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private HypervisorType hypervisorType; + public static class Builder { + private HypervisorType hypervisorType; - private ConversionState conversionState; + private ConversionState conversionState; - /** Only conversions compatible with this hypervisor */ - public Builder hypervisorType(final HypervisorType hypervisorType) - { - this.hypervisorType = hypervisorType; - return this; - } + /** Only conversions compatible with this hypervisor */ + public Builder hypervisorType(final HypervisorType hypervisorType) { + this.hypervisorType = hypervisorType; + return this; + } - /** Only conversions with the provided state */ - public Builder conversionState(final ConversionState conversionState) - { - this.conversionState = conversionState; - return this; - } + /** Only conversions with the provided state */ + public Builder conversionState(final ConversionState conversionState) { + this.conversionState = conversionState; + return this; + } - public ConversionOptions build() - { - ConversionOptions options = new ConversionOptions(); + public ConversionOptions build() { + ConversionOptions options = new ConversionOptions(); - if (hypervisorType != null) - { - options.queryParameters.put("hypervisor", hypervisorType.name()); - } - if (conversionState != null) - { - options.queryParameters.put("state", conversionState.name()); - } + if (hypervisorType != null) { + options.queryParameters.put("hypervisor", hypervisorType.name()); + } + if (conversionState != null) { + options.queryParameters.put("state", conversionState.name()); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java index 50420618ee..3fdf07a646 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualApplianceOptions.java @@ -27,42 +27,35 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * @author Francesc Montserrat * @author Ignasi Barrera */ -public class VirtualApplianceOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class VirtualApplianceOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - VirtualApplianceOptions options = new VirtualApplianceOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + VirtualApplianceOptions options = new VirtualApplianceOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { + public static class Builder { - private Boolean available; + private Boolean available; - public Builder available(final boolean available) - { - this.available = available; - return this; - } + public Builder available(final boolean available) { + this.available = available; + return this; + } - public VirtualApplianceOptions build() - { - VirtualApplianceOptions options = new VirtualApplianceOptions(); + public VirtualApplianceOptions build() { + VirtualApplianceOptions options = new VirtualApplianceOptions(); - if (available != null) - { - options.queryParameters.put("available", String.valueOf(available)); - } + if (available != null) { + options.queryParameters.put("available", String.valueOf(available)); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java index 783478fe87..27bea5d092 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualDatacenterOptions.java @@ -26,59 +26,50 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class VirtualDatacenterOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class VirtualDatacenterOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - VirtualDatacenterOptions options = new VirtualDatacenterOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + VirtualDatacenterOptions options = new VirtualDatacenterOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private Integer datacenterId; + public static class Builder { + private Integer datacenterId; - private Integer enterpriseId; + private Integer enterpriseId; - /** - * Set the optional datacenter. - */ - public Builder datacenterId(final int datacenterId) - { - this.datacenterId = datacenterId; - return this; - } + /** + * Set the optional datacenter. + */ + public Builder datacenterId(final int datacenterId) { + this.datacenterId = datacenterId; + return this; + } - /** - * Set the optional enterprise. - */ - public Builder enterpriseId(final int enterpriseId) - { - this.enterpriseId = enterpriseId; - return this; - } + /** + * Set the optional enterprise. + */ + public Builder enterpriseId(final int enterpriseId) { + this.enterpriseId = enterpriseId; + return this; + } - public VirtualDatacenterOptions build() - { - VirtualDatacenterOptions options = new VirtualDatacenterOptions(); + public VirtualDatacenterOptions build() { + VirtualDatacenterOptions options = new VirtualDatacenterOptions(); - if (datacenterId != null) - { - options.queryParameters.put("datacenter", datacenterId.toString()); - } + if (datacenterId != null) { + options.queryParameters.put("datacenter", datacenterId.toString()); + } - if (enterpriseId != null) - { - options.queryParameters.put("enterprise", enterpriseId.toString()); - } - return options; - } - } + if (enterpriseId != null) { + options.queryParameters.put("enterprise", enterpriseId.toString()); + } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java index 86758418f8..e78c02baac 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineOptions.java @@ -27,41 +27,34 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Alessia Prete */ -public class VirtualMachineOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class VirtualMachineOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - VirtualMachineOptions options = new VirtualMachineOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + VirtualMachineOptions options = new VirtualMachineOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder extends BaseFilterOptionsBuilder - { - private Boolean force; + public static class Builder extends BaseFilterOptionsBuilder { + private Boolean force; - public Builder force(final Boolean force) - { - this.force = force; - return this; - } + public Builder force(final Boolean force) { + this.force = force; + return this; + } - public VirtualMachineOptions build() - { - VirtualMachineOptions options = new VirtualMachineOptions(); + public VirtualMachineOptions build() { + VirtualMachineOptions options = new VirtualMachineOptions(); - if (force != null) - { - options.queryParameters.put("force", String.valueOf(force)); - } + if (force != null) { + options.queryParameters.put("force", String.valueOf(force)); + } - return addFilterOptions(options); - } - } + return addFilterOptions(options); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java index 6b6d2f1f08..7f587187d9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VirtualMachineTemplateOptions.java @@ -30,91 +30,76 @@ import com.abiquo.model.enumerator.StatefulInclusion; * * @author Ignasi Barrera */ -public class VirtualMachineTemplateOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class VirtualMachineTemplateOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private StatefulInclusion persistent; + public static class Builder { + private StatefulInclusion persistent; - private HypervisorType hypervisorType; + private HypervisorType hypervisorType; - private Category category; + private Category category; - private String categoryName; + private String categoryName; - private Integer idTemplate; + private Integer idTemplate; - public Builder persistent(final StatefulInclusion persistent) - { - this.persistent = persistent; - return this; - } + public Builder persistent(final StatefulInclusion persistent) { + this.persistent = persistent; + return this; + } - public Builder hypervisorType(final HypervisorType hypervisorType) - { - this.hypervisorType = hypervisorType; - return this; - } + public Builder hypervisorType(final HypervisorType hypervisorType) { + this.hypervisorType = hypervisorType; + return this; + } - public Builder category(final Category category) - { - this.category = category; - return this; - } + public Builder category(final Category category) { + this.category = category; + return this; + } - public Builder categoryName(final String categoryName) - { - this.categoryName = categoryName; - return this; - } + public Builder categoryName(final String categoryName) { + this.categoryName = categoryName; + return this; + } - public Builder idTemplate(final Integer idTemplate) - { - this.idTemplate = idTemplate; - return this; - } + public Builder idTemplate(final Integer idTemplate) { + this.idTemplate = idTemplate; + return this; + } - public VirtualMachineTemplateOptions build() - { - VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions(); + public VirtualMachineTemplateOptions build() { + VirtualMachineTemplateOptions options = new VirtualMachineTemplateOptions(); - if (persistent != null) - { - options.queryParameters.put("stateful", persistent.name()); - } - if (hypervisorType != null) - { - options.queryParameters.put("hypervisorTypeName", hypervisorType.name()); - } - if (category != null) - { - options.queryParameters.put("categoryName", category.getName()); - } + if (persistent != null) { + options.queryParameters.put("stateful", persistent.name()); + } + if (hypervisorType != null) { + options.queryParameters.put("hypervisorTypeName", hypervisorType.name()); + } + if (category != null) { + options.queryParameters.put("categoryName", category.getName()); + } - if (category == null && categoryName != null) - { - options.queryParameters.put("categoryName", categoryName); - } + if (category == null && categoryName != null) { + options.queryParameters.put("categoryName", categoryName); + } - if (idTemplate != null) - { - options.queryParameters.put("idTemplate", String.valueOf(idTemplate)); - } + if (idTemplate != null) { + options.queryParameters.put("idTemplate", String.valueOf(idTemplate)); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java index 66bc390956..9048da61bf 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/cloud/options/VolumeOptions.java @@ -29,41 +29,34 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * @author Ignasi Barrera */ @EnterpriseEdition -public class VolumeOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class VolumeOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - VolumeOptions options = new VolumeOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + VolumeOptions options = new VolumeOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder extends BaseFilterOptionsBuilder - { - private Boolean onlyAvailable; + public static class Builder extends BaseFilterOptionsBuilder { + private Boolean onlyAvailable; - public Builder onlyAvailable(final boolean onlyAvailable) - { - this.onlyAvailable = onlyAvailable; - return this; - } + public Builder onlyAvailable(final boolean onlyAvailable) { + this.onlyAvailable = onlyAvailable; + return this; + } - public VolumeOptions build() - { - VolumeOptions options = new VolumeOptions(); + public VolumeOptions build() { + VolumeOptions options = new VolumeOptions(); - if (onlyAvailable != null) - { - options.queryParameters.put("available", String.valueOf(onlyAvailable)); - } + if (onlyAvailable != null) { + options.queryParameters.put("available", String.valueOf(onlyAvailable)); + } - return addFilterOptions(options); - } - } + return addFilterOptions(options); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java index 25ef1b2d55..f0206d67d3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Category.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.config; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -32,155 +31,139 @@ import com.abiquo.server.core.appslibrary.CategoryDto; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Category+Resource */ -public class Category extends DomainWrapper -{ - /** The default value for the default category flag. */ - private static final boolean DEFAULT_DEFAULT_CATEGORY = false; +public class Category extends DomainWrapper { + /** The default value for the default category flag. */ + private static final boolean DEFAULT_DEFAULT_CATEGORY = false; - /** The default value for the erasable flag. */ - private static final boolean DEFAULT_ERASABLE = true; + /** The default value for the erasable flag. */ + private static final boolean DEFAULT_ERASABLE = true; - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private Category(final RestContext context, final CategoryDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private Category(final RestContext context, final CategoryDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Deleteacategory - */ - public void delete() - { - context.getApi().getConfigApi().deleteCategory(target); - target = null; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Category+Resource# + * CategoryResource-Deleteacategory + */ + public void delete() { + context.getApi().getConfigApi().deleteCategory(target); + target = null; + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Createacategory - */ - public void save() - { - target = context.getApi().getConfigApi().createCategory(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Category+Resource# + * CategoryResource-Createacategory + */ + public void save() { + target = context.getApi().getConfigApi().createCategory(target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Category+Resource#CategoryResource-Updateanexistingcategory - */ - public void update() - { - target = context.getApi().getConfigApi().updateCategory(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Category+Resource# + * CategoryResource-Updateanexistingcategory + */ + public void update() { + target = context.getApi().getConfigApi().updateCategory(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private Boolean erasable = DEFAULT_ERASABLE; + private Boolean erasable = DEFAULT_ERASABLE; - private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY; + private Boolean defaultCategory = DEFAULT_DEFAULT_CATEGORY; - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder defaultCategory(final boolean defaultCategory) - { - this.defaultCategory = defaultCategory; - return this; - } + public Builder defaultCategory(final boolean defaultCategory) { + this.defaultCategory = defaultCategory; + return this; + } - public Builder erasable(final boolean erasable) - { - this.erasable = erasable; - return this; - } + public Builder erasable(final boolean erasable) { + this.erasable = erasable; + return this; + } - public Category build() - { - CategoryDto dto = new CategoryDto(); - dto.setErasable(erasable); - dto.setDefaultCategory(defaultCategory); - dto.setName(name); - Category category = new Category(context, dto); + public Category build() { + CategoryDto dto = new CategoryDto(); + dto.setErasable(erasable); + dto.setDefaultCategory(defaultCategory); + dto.setName(name); + Category category = new Category(context, dto); - return category; - } + return category; + } - public static Builder fromCategory(final Category in) - { - Builder builder = - Category.builder(in.context).name(in.getName()).erasable(in.isErasable()) - .defaultCategory(in.isDefaultCategory()); + public static Builder fromCategory(final Category in) { + Builder builder = Category.builder(in.context).name(in.getName()).erasable(in.isErasable()) + .defaultCategory(in.isDefaultCategory()); - return builder; - } - } + return builder; + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public boolean isDefaultCategory() - { - return target.isDefaultCategory(); - } + public boolean isDefaultCategory() { + return target.isDefaultCategory(); + } - public boolean isErasable() - { - return target.isErasable(); - } + public boolean isErasable() { + return target.isErasable(); + } - public void setDefaultCategory(final boolean defaultCategory) - { - target.setDefaultCategory(defaultCategory); - } + public void setDefaultCategory(final boolean defaultCategory) { + target.setDefaultCategory(defaultCategory); + } - public void setErasable(final boolean erasable) - { - target.setErasable(erasable); - } + public void setErasable(final boolean erasable) { + target.setErasable(erasable); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java index 82b3e3c63d..2963a7d83e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCode.java @@ -36,164 +36,139 @@ import com.google.common.collect.Lists; /** * A cost code is a kind of label where concrete prices can be assigned. *

- * Cloud administrators can create several cost codes and assign a price to each one, to have a - * flexible way to configure custom billings for each resource. + * Cloud administrators can create several cost codes and assign a price to each + * one, to have a flexible way to configure custom billings for each resource. *

- * Cost codes can be assigned to {@link VirtualMachineTemplate}s and other resources to provide - * pricing information about them. + * Cost codes can be assigned to {@link VirtualMachineTemplate}s and other + * resources to provide pricing information about them. * * @author Ignasi Barrera * @author Susana Acedo */ -public class CostCode extends DomainWrapper -{ +public class CostCode extends DomainWrapper { - private List defaultPrices; + private List defaultPrices; - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private CostCode(final RestContext context, final CostCodeDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private CostCode(final RestContext context, final CostCodeDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void delete() - { - context.getApi().getPricingApi().deleteCostCode(target); - target = null; - } + public void delete() { + context.getApi().getPricingApi().deleteCostCode(target); + target = null; + } - public void save() - { - target = context.getApi().getPricingApi().createCostCode(target); + public void save() { + target = context.getApi().getPricingApi().createCostCode(target); - if (defaultPrices != null && !defaultPrices.isEmpty()) - { - CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto(); - for (CostCodePrice ccp : defaultPrices) - { - CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto(); - Currency currency = ccp.getCurrency(); + if (defaultPrices != null && !defaultPrices.isEmpty()) { + CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto(); + for (CostCodePrice ccp : defaultPrices) { + CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto(); + Currency currency = ccp.getCurrency(); - costcodecurrency.addLink(new RESTLink("currency", currency.unwrap().getEditLink() - .getHref())); - costcodecurrency.setPrice(ccp.getPrice()); - costcodecurrencies.add(costcodecurrency); - } - context.getApi().getPricingApi().updateCostCodeCurrencies(getId(), costcodecurrencies); - } + costcodecurrency.addLink(new RESTLink("currency", currency.unwrap().getEditLink().getHref())); + costcodecurrency.setPrice(ccp.getPrice()); + costcodecurrencies.add(costcodecurrency); + } + context.getApi().getPricingApi().updateCostCodeCurrencies(getId(), costcodecurrencies); + } - } + } - public void update() - { - target = context.getApi().getPricingApi().updateCostCode(target); - } + public void update() { + target = context.getApi().getPricingApi().updateCostCode(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private String description; + private String description; - private List defaultPrices = Lists.newArrayList(); + private List defaultPrices = Lists.newArrayList(); - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder description(final String description) - { - this.description = description; - return this; - } + public Builder description(final String description) { + this.description = description; + return this; + } - public Builder defaultPrices(final List prices) - { - this.defaultPrices.addAll(prices); - return this; - } + public Builder defaultPrices(final List prices) { + this.defaultPrices.addAll(prices); + return this; + } - public CostCode build() - { - CostCodeDto dto = new CostCodeDto(); - dto.setName(name); - dto.setDescription(description); - CostCode costcode = new CostCode(context, dto); - costcode.setDefaultPrices(defaultPrices); - return costcode; - } + public CostCode build() { + CostCodeDto dto = new CostCodeDto(); + dto.setName(name); + dto.setDescription(description); + CostCode costcode = new CostCode(context, dto); + costcode.setDefaultPrices(defaultPrices); + return costcode; + } - public static Builder fromCostCode(final CostCode in) - { - Builder builder = - CostCode.builder(in.context).name(in.getName()).description(in.getDescription()) - .defaultPrices(in.getDefaultPrices()); - return builder; - } - } + public static Builder fromCostCode(final CostCode in) { + Builder builder = CostCode.builder(in.context).name(in.getName()).description(in.getDescription()) + .defaultPrices(in.getDefaultPrices()); + return builder; + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public void setDescription(final String description) - { - target.setDescription(description); - } + public void setDescription(final String description) { + target.setDescription(description); + } - public List getDefaultPrices() - { - return defaultPrices; - } + public List getDefaultPrices() { + return defaultPrices; + } - public void setDefaultPrices(final List defaultPrices) - { - this.defaultPrices = defaultPrices; - } + public void setDefaultPrices(final List defaultPrices) { + this.defaultPrices = defaultPrices; + } - @Override - public String toString() - { - return "CostCode [id=" + getId() + ", name=" + getName() + ", description=" - + getDescription() + "]"; - } + @Override + public String toString() { + return "CostCode [id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java index 66492a0df3..f0a63dfefb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodeCurrency.java @@ -27,30 +27,24 @@ import org.jclouds.rest.RestContext; import com.abiquo.server.core.pricing.CostCodeCurrencyDto; -public class CostCodeCurrency extends DomainWrapper -{ +public class CostCodeCurrency extends DomainWrapper { - protected CostCodeCurrency(final RestContext context, - final CostCodeCurrencyDto target) - { - super(context, target); - } + protected CostCodeCurrency(final RestContext context, final CostCodeCurrencyDto target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public BigDecimal getPrice() - { - return target.getPrice(); - } + public BigDecimal getPrice() { + return target.getPrice(); + } - @Override - public String toString() - { - return "CostCodeCurrency [id=" + getId() + ", price=" + getPrice() + "]"; - } + @Override + public String toString() { + return "CostCodeCurrency [id=" + getId() + ", price=" + getPrice() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java index b2caf5bdbe..324d11ea78 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/CostCodePrice.java @@ -25,43 +25,36 @@ import java.math.BigDecimal; * * @author Susana Acedo */ -public class CostCodePrice -{ - private Currency currency; +public class CostCodePrice { + private Currency currency; - private BigDecimal price; + private BigDecimal price; - public CostCodePrice(final Currency currency, final BigDecimal price) - { - super(); - this.currency = currency; - this.price = price; - } + public CostCodePrice(final Currency currency, final BigDecimal price) { + super(); + this.currency = currency; + this.price = price; + } - public Currency getCurrency() - { - return currency; - } + public Currency getCurrency() { + return currency; + } - public void setCurrency(final Currency currency) - { - this.currency = currency; - } + public void setCurrency(final Currency currency) { + this.currency = currency; + } - public BigDecimal getPrice() - { - return price; - } + public BigDecimal getPrice() { + return price; + } - public void setPrice(final BigDecimal price) - { - this.price = price; - } + public void setPrice(final BigDecimal price) { + this.price = price; + } - @Override - public String toString() - { - return "CostCodePrice [currency=" + currency + ", price=" + price + "]"; - } + @Override + public String toString() { + return "CostCodePrice [currency=" + currency + ", price=" + price + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java index 691a93562a..1e0aa35568 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Currency.java @@ -32,138 +32,117 @@ import com.abiquo.server.core.pricing.CurrencyDto; * @author Ignasi Barrera * @author Susana Acedo */ -public class Currency extends DomainWrapper -{ +public class Currency extends DomainWrapper { - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private Currency(final RestContext context, final CurrencyDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private Currency(final RestContext context, final CurrencyDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void delete() - { - context.getApi().getPricingApi().deleteCurrency(target); - target = null; - } + public void delete() { + context.getApi().getPricingApi().deleteCurrency(target); + target = null; + } - public void save() - { - target = context.getApi().getPricingApi().createCurrency(target); - } + public void save() { + target = context.getApi().getPricingApi().createCurrency(target); + } - public void update() - { - target = context.getApi().getPricingApi().updateCurrency(target); - } + public void update() { + target = context.getApi().getPricingApi().updateCurrency(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private String symbol; + private String symbol; - private int digits; + private int digits; - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder symbol(final String symbol) - { - this.symbol = symbol; - return this; - } + public Builder symbol(final String symbol) { + this.symbol = symbol; + return this; + } - public Builder digits(final int digits) - { - this.digits = digits; - return this; - } + public Builder digits(final int digits) { + this.digits = digits; + return this; + } - public Currency build() - { - CurrencyDto dto = new CurrencyDto(); - dto.setName(name); - dto.setSymbol(symbol); - dto.setDigits(digits); - Currency currency = new Currency(context, dto); + public Currency build() { + CurrencyDto dto = new CurrencyDto(); + dto.setName(name); + dto.setSymbol(symbol); + dto.setDigits(digits); + Currency currency = new Currency(context, dto); - return currency; - } + return currency; + } - public static Builder fromCurrency(final Currency in) - { - Builder builder = - Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol()) - .digits(in.getDigits()); + public static Builder fromCurrency(final Currency in) { + Builder builder = Currency.builder(in.context).name(in.getName()).symbol(in.getSymbol()) + .digits(in.getDigits()); - return builder; - } - } + return builder; + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public String getSymbol() - { - return target.getSymbol(); - } + public String getSymbol() { + return target.getSymbol(); + } - public void setSymbol(final String symbol) - { - target.setSymbol(symbol); - } + public void setSymbol(final String symbol) { + target.setSymbol(symbol); + } - public int getDigits() - { - return target.getDigits(); - } + public int getDigits() { + return target.getDigits(); + } - public void setDigits(final int digits) - { - target.setDigits(digits); - } + public void setDigits(final int digits) { + target.setDigits(digits); + } - @Override - public String toString() - { - return "Currency [id=" + getId() + ", name=" + getName() + ", symbol=" + getSymbol() - + ", digits=" + getDigits() + "]"; - } + @Override + public String toString() { + return "Currency [id=" + getId() + ", name=" + getName() + ", symbol=" + getSymbol() + ", digits=" + getDigits() + + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java index f1c9d84b64..d7f1c29f2c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/License.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.config; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -35,108 +34,90 @@ import com.abiquo.server.core.config.LicenseDto; * @author Francesc Montserrat */ @EnterpriseEdition -public class License extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected License(final RestContext context, final LicenseDto target) - { - super(context, target); - } +public class License extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected License(final RestContext context, final LicenseDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void remove() - { - context.getApi().getConfigApi().removeLicense(target); - target = null; - } + public void remove() { + context.getApi().getConfigApi().removeLicense(target); + target = null; + } - public void add() - { - target = context.getApi().getConfigApi().addLicense(target); - } + public void add() { + target = context.getApi().getConfigApi().addLicense(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context, final String code) - { - return new Builder(context, code); - } + public static Builder builder(final RestContext context, final String code) { + return new Builder(context, code); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String code; + private String code; - public Builder(final RestContext context, final String code) - { - super(); - this.context = context; - this.code = code; - } + public Builder(final RestContext context, final String code) { + super(); + this.context = context; + this.code = code; + } - public Builder code(final String code) - { - this.code = code; - return this; - } + public Builder code(final String code) { + this.code = code; + return this; + } - public License build() - { - LicenseDto dto = new LicenseDto(); - dto.setCode(code); + public License build() { + LicenseDto dto = new LicenseDto(); + dto.setCode(code); - License license = new License(context, dto); - return license; - } + License license = new License(context, dto); + return license; + } - public static Builder fromLicense(final License in) - { - return License.builder(in.context, in.getCode()); - } - } + public static Builder fromLicense(final License in) { + return License.builder(in.context, in.getCode()); + } + } - // Delegate methods + // Delegate methods - public String getCode() - { - return target.getCode(); - } + public String getCode() { + return target.getCode(); + } - public String getCustomerId() - { - return target.getCustomerid(); - } + public String getCustomerId() { + return target.getCustomerid(); + } - public String getEnabledIp() - { - return target.getEnabledip(); - } + public String getEnabledIp() { + return target.getEnabledip(); + } - public String getExpiration() - { - return target.getExpiration(); - } + public String getExpiration() { + return target.getExpiration(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public Integer getNumCores() - { - return target.getNumcores(); - } + public Integer getNumCores() { + return target.getNumcores(); + } - @Override - public String toString() - { - return "License [id=" + getId() + ", code=" + getCode() + ", customerId=" + getCustomerId() - + ", enabledIp=" + getEnabledIp() + ", expiration=" + getExpiration() + ", numCores=" - + getNumCores() + "]"; - } + @Override + public String toString() { + return "License [id=" + getId() + ", code=" + getCode() + ", customerId=" + getCustomerId() + ", enabledIp=" + + getEnabledIp() + ", expiration=" + getExpiration() + ", numCores=" + getNumCores() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java index ff0d1b5123..397f03a74d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingCostCode.java @@ -36,95 +36,80 @@ import com.abiquo.server.core.pricing.PricingCostCodeDto; * * @author Susana Acedo */ -public class PricingCostCode extends DomainWrapper -{ - private CostCode costcode; +public class PricingCostCode extends DomainWrapper { + private CostCode costcode; - private PricingTemplate pricingTemplate; + private PricingTemplate pricingTemplate; - protected PricingCostCode(final RestContext context, - final PricingCostCodeDto target) - { - super(context, target); - } + protected PricingCostCode(final RestContext context, final PricingCostCodeDto target) { + super(context, target); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final PricingTemplate pricingtemplate, final CostCode costcode) - { - return new Builder(context, pricingtemplate, costcode); - } + public static Builder builder(final RestContext context, + final PricingTemplate pricingtemplate, final CostCode costcode) { + return new Builder(context, pricingtemplate, costcode); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Integer id; + private Integer id; - private PricingTemplate pricingTemplate; + private PricingTemplate pricingTemplate; - private CostCode costcode; + private CostCode costcode; - private BigDecimal price; + private BigDecimal price; - public Builder(final RestContext context, - final PricingTemplate pricingTemplate, final CostCode costcode) - { - super(); - this.pricingTemplate = - checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE - + PricingTemplate.class); - this.costcode = checkNotNull(costcode, ValidationErrors.NULL_RESOURCE + CostCode.class); - this.context = context; - } + public Builder(final RestContext context, final PricingTemplate pricingTemplate, + final CostCode costcode) { + super(); + this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class); + this.costcode = checkNotNull(costcode, ValidationErrors.NULL_RESOURCE + CostCode.class); + this.context = context; + } - public Builder price(final BigDecimal price) - { - this.price = price; - return this; - } + public Builder price(final BigDecimal price) { + this.price = price; + return this; + } - public PricingCostCode build() - { - PricingCostCodeDto dto = new PricingCostCodeDto(); - dto.setId(id); - dto.setPrice(price); + public PricingCostCode build() { + PricingCostCodeDto dto = new PricingCostCodeDto(); + dto.setId(id); + dto.setPrice(price); - RESTLink link = costcode.unwrap().searchLink("edit"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - dto.addLink(new RESTLink("costcode", link.getHref())); + RESTLink link = costcode.unwrap().searchLink("edit"); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + dto.addLink(new RESTLink("costcode", link.getHref())); - PricingCostCode pricingcostcode = new PricingCostCode(context, dto); - pricingcostcode.pricingTemplate = pricingTemplate; - pricingcostcode.costcode = costcode; + PricingCostCode pricingcostcode = new PricingCostCode(context, dto); + pricingcostcode.pricingTemplate = pricingTemplate; + pricingcostcode.costcode = costcode; - return pricingcostcode; - } + return pricingcostcode; + } - public static Builder fromPricingCostCode(final PricingCostCode in) - { - return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price( - in.getPrice()); - } - } + public static Builder fromPricingCostCode(final PricingCostCode in) { + return PricingCostCode.builder(in.context, in.pricingTemplate, in.costcode).price(in.getPrice()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public BigDecimal getPrice() - { - return target.getPrice(); - } + public BigDecimal getPrice() { + return target.getPrice(); + } - @Override - public String toString() - { - return "PricingCostCode [id=" + getId() + ", price=" + getPrice() + "]"; - } + @Override + public String toString() { + return "PricingCostCode [id=" + getId() + ", price=" + getPrice() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java index 379724417c..a31623fcde 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTemplate.java @@ -36,408 +36,344 @@ import com.abiquo.model.rest.RESTLink; import com.abiquo.server.core.pricing.PricingTemplateDto; /** - * A pricing template is a complete pricing schema that can be assigned to an {@link Enterprise}. + * A pricing template is a complete pricing schema that can be assigned to an + * {@link Enterprise}. *

- * This pricing schema will provide detailed billing information for each resource consumed by the - * users of the enterprise. + * This pricing schema will provide detailed billing information for each + * resource consumed by the users of the enterprise. * * @author Ignasi Barrera * @author Susana Acedo */ -public class PricingTemplate extends DomainWrapper -{ +public class PricingTemplate extends DomainWrapper { - /** The currency used by the pricing template. */ - protected Currency currency; + /** The currency used by the pricing template. */ + protected Currency currency; - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private PricingTemplate(final RestContext context, - final PricingTemplateDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private PricingTemplate(final RestContext context, final PricingTemplateDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public void delete() - { - context.getApi().getPricingApi().deletePricingTemplate(target); - target = null; - } + public void delete() { + context.getApi().getPricingApi().deletePricingTemplate(target); + target = null; + } - public void save() - { - target = context.getApi().getPricingApi().createPricingTemplate(target); - } + public void save() { + target = context.getApi().getPricingApi().createPricingTemplate(target); + } - public void update() - { - target = context.getApi().getPricingApi().updatePricingTemplate(target); - } + public void update() { + target = context.getApi().getPricingApi().updatePricingTemplate(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Currency currency) - { - return new Builder(context, currency); - } + public static Builder builder(final RestContext context, final Currency currency) { + return new Builder(context, currency); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Currency currency; + private Currency currency; - private String name; + private String name; - private String description; + private String description; - private BigDecimal hdGB; + private BigDecimal hdGB; - private BigDecimal standingChargePeriod; + private BigDecimal standingChargePeriod; - private BigDecimal vlan; + private BigDecimal vlan; - private PricingPeriod chargingPeriod; + private PricingPeriod chargingPeriod; - private BigDecimal minimumChargePeriod; - - private boolean showChangesBefore; + private BigDecimal minimumChargePeriod; - private boolean showMinimumCharge; - - private PricingPeriod minimumCharge; - - private BigDecimal publicIp; - - private BigDecimal vcpu; - - private BigDecimal memoryGB; - - private boolean defaultTemplate; - - private Date lastUpdate; - - public Builder(final RestContext context, final Currency currency) - { - super(); - this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class); - this.context = context; - } - - public Builder name(final String name) - { - this.name = name; - return this; - } - - public Builder description(final String description) - { - this.description = description; - return this; - } - - public Builder hdGB(final BigDecimal hdGB) - { - this.hdGB = hdGB; - return this; - } - - public Builder standingChargePeriod(final BigDecimal standingChargePeriod) - { - this.standingChargePeriod = standingChargePeriod; - return this; - } - - public Builder chargingPeriod(final PricingPeriod chargingPeriod) - { - this.chargingPeriod = chargingPeriod; - return this; - } - - public Builder vlan(final BigDecimal vlan) - { - this.vlan = vlan; - return this; - } - - public Builder minimumChargePeriod(final BigDecimal minimumChargePeriod) - { - this.minimumChargePeriod = minimumChargePeriod; - return this; - } - - public Builder minimumCharge(final PricingPeriod minimumCharge) - { - this.minimumCharge = minimumCharge; - return this; - } - - public Builder showChangesBefore(final boolean showChangesBefore) - { - this.showChangesBefore = showChangesBefore; - return this; - } - - public Builder showMinimumCharge(final boolean showMinimumCharge) - { - this.showMinimumCharge = showMinimumCharge; - return this; - } - - public Builder publicIp(final BigDecimal publicIp) - { - this.publicIp = publicIp; - return this; - } - - public Builder vcpu(final BigDecimal vcpu) - { - this.vcpu = vcpu; - return this; - } - - public Builder memoryGB(final BigDecimal memoryGB) - { - this.memoryGB = memoryGB; - return this; - } - - public Builder defaultTemplate(final boolean defaultTemplate) - { - this.defaultTemplate = defaultTemplate; - return this; - } - - public Builder lastUpdate(final Date lastUpdate) - { - this.lastUpdate = lastUpdate; - return this; - } - - public Builder currency(final Currency currency) - { - this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class); - return this; - } - - public PricingTemplate build() - { - PricingTemplateDto dto = new PricingTemplateDto(); - dto.setName(name); - dto.setDescription(description); - dto.setHdGB(hdGB); - dto.setStandingChargePeriod(standingChargePeriod); - dto.setVlan(vlan); - dto.setChargingPeriod(chargingPeriod.ordinal()); - dto.setMinimumCharge(minimumCharge.ordinal()); - dto.setMinimumChargePeriod(minimumChargePeriod); - dto.setShowChangesBefore(showChangesBefore); - dto.setShowMinimumCharge(showMinimumCharge); - dto.setPublicIp(publicIp); - dto.setVcpu(vcpu); - dto.setMemoryGB(memoryGB); - dto.setDefaultTemplate(defaultTemplate); - dto.setLastUpdate(lastUpdate); - - RESTLink link = currency.unwrap().searchLink("edit"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - dto.addLink(new RESTLink("currency", link.getHref())); - - PricingTemplate pricingTemplate = new PricingTemplate(context, dto); - pricingTemplate.currency = currency; - - return pricingTemplate; - } - - public static Builder fromPricingTemplate(final PricingTemplate in) - { - Builder builder = - PricingTemplate.builder(in.context, in.currency).name(in.getName()) - .description(in.getDescription()).hdGB(in.getHdGB()) - .standingChargePeriod(in.getStandingChargePeriod()).vcpu(in.getVlan()) - .chargingPeriod(in.getChargingPeriod()).minimumCharge(in.getMinimumCharge()) - .minimumChargePeriod(in.getMinimumChargePeriod()) - .showChangesBefore(in.isShowChangesBefore()) - .showMinimumCharge(in.isShowMinimumCharge()).publicIp(in.getPublicIp()) - .vcpu(in.getVcpu()).memoryGB(in.getMemoryGB()) - .defaultTemplate(in.isDefaultTemplate()).lastUpdate(in.getLastUpdate()); - return builder; - } - } - - // Delegate methods - - public Integer getId() - { - return target.getId(); - } - - public String getName() - { - return target.getName(); - } - - public void setName(final String name) - { - target.setName(name); - } - - public String getDescription() - { - return target.getDescription(); - } - - public void setDescription(final String description) - { - target.setDescription(description); - } - - public BigDecimal getHdGB() - { - return target.getHdGB(); - } - - public void setHdGB(final BigDecimal hdGB) - { - target.setHdGB(hdGB); - } - - public BigDecimal getStandingChargePeriod() - { - return target.getStandingChargePeriod(); - } - - public void setStandingChargePeriod(final BigDecimal standingChargePeriod) - { - target.setStandingChargePeriod(standingChargePeriod); - } - - public BigDecimal getVlan() - { - return target.getVlan(); - } - - public void setVlan(final BigDecimal vlan) - { - target.getVlan(); - } - - public BigDecimal getMinimumChargePeriod() - { - return target.getMinimumChargePeriod(); - } - - public void setMinimumChargePeriod(final BigDecimal minimumChargePeriod) - { - target.setMinimumChargePeriod(minimumChargePeriod); - } - - public boolean isShowChangesBefore() - { - return target.isShowChangesBefore(); - } - - public void setShowChangesBefore(final boolean showChangesBefore) - { - target.setShowChangesBefore(showChangesBefore); - } - - public boolean isShowMinimumCharge() - { - return target.isShowMinimumCharge(); - } - - public void setShowMinimumCharge(final boolean showMinimumCharge) - { - target.setShowMinimumCharge(showMinimumCharge); - } - - public PricingPeriod getMinimumCharge() - { - return PricingPeriod.fromId(target.getMinimumCharge()); - } - - public void setMinimumCharge(final PricingPeriod minimumCharge) - { - target.setMinimumCharge(minimumCharge.ordinal()); - } - - public PricingPeriod getChargingPeriod() - { - return PricingPeriod.fromId(target.getChargingPeriod()); - } - - public void setChargingPeriod(final PricingPeriod chargingPeriod) - { - target.setChargingPeriod(chargingPeriod.ordinal()); - } - - public BigDecimal getPublicIp() - { - return target.getPublicIp(); - } - - public void setPublicIp(final BigDecimal publicIp) - { - target.setPublicIp(publicIp); - } - - public BigDecimal getVcpu() - { - return target.getVcpu(); - } - - public void setVcpu(final BigDecimal vcpu) - { - target.setVcpu(vcpu); - } - - public BigDecimal getMemoryGB() - { - return target.getMemoryGB(); - } - - public void setMemoryGB(final BigDecimal memoryGB) - { - target.setMemoryGB(memoryGB); - } - - public boolean isDefaultTemplate() - { - return target.isDefaultTemplate(); - } - - public void setDefaultTemplate(final boolean defaultTemplate) - { - target.setDefaultTemplate(defaultTemplate); - } - - public Date getLastUpdate() - { - return target.getLastUpdate(); - } - - public void setLastUpdate(final Date lastUpdate) - { - target.setLastUpdate(lastUpdate); - } - - @Override - public String toString() - { - return "PricingTemplate [id=" + getId() + ", name=" + getName() + ", description=" - + getDescription() + ", hdGB =" + getHdGB() + ", standingChargePeriod =" - + getStandingChargePeriod() + ", vlan = " + getVlan() + ", chargingPeriod =" - + getChargingPeriod() + ", minimumChargePeriod=" + getMinimumChargePeriod() - + ", showChangesBefore =" + isShowChangesBefore() + ", showMinimumCharge= " - + isShowMinimumCharge() + ", minimumCharge = " + getMinimumCharge() + ", publicIp = " - + getPublicIp() + ", vcpu =" + getVcpu() + ", memoryGB= " + getMemoryGB() - + ", defaultTemplate= " + isDefaultTemplate() + ", lastUpdate = " + getLastUpdate() - + "]"; - } + private boolean showChangesBefore; + + private boolean showMinimumCharge; + + private PricingPeriod minimumCharge; + + private BigDecimal publicIp; + + private BigDecimal vcpu; + + private BigDecimal memoryGB; + + private boolean defaultTemplate; + + private Date lastUpdate; + + public Builder(final RestContext context, final Currency currency) { + super(); + this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class); + this.context = context; + } + + public Builder name(final String name) { + this.name = name; + return this; + } + + public Builder description(final String description) { + this.description = description; + return this; + } + + public Builder hdGB(final BigDecimal hdGB) { + this.hdGB = hdGB; + return this; + } + + public Builder standingChargePeriod(final BigDecimal standingChargePeriod) { + this.standingChargePeriod = standingChargePeriod; + return this; + } + + public Builder chargingPeriod(final PricingPeriod chargingPeriod) { + this.chargingPeriod = chargingPeriod; + return this; + } + + public Builder vlan(final BigDecimal vlan) { + this.vlan = vlan; + return this; + } + + public Builder minimumChargePeriod(final BigDecimal minimumChargePeriod) { + this.minimumChargePeriod = minimumChargePeriod; + return this; + } + + public Builder minimumCharge(final PricingPeriod minimumCharge) { + this.minimumCharge = minimumCharge; + return this; + } + + public Builder showChangesBefore(final boolean showChangesBefore) { + this.showChangesBefore = showChangesBefore; + return this; + } + + public Builder showMinimumCharge(final boolean showMinimumCharge) { + this.showMinimumCharge = showMinimumCharge; + return this; + } + + public Builder publicIp(final BigDecimal publicIp) { + this.publicIp = publicIp; + return this; + } + + public Builder vcpu(final BigDecimal vcpu) { + this.vcpu = vcpu; + return this; + } + + public Builder memoryGB(final BigDecimal memoryGB) { + this.memoryGB = memoryGB; + return this; + } + + public Builder defaultTemplate(final boolean defaultTemplate) { + this.defaultTemplate = defaultTemplate; + return this; + } + + public Builder lastUpdate(final Date lastUpdate) { + this.lastUpdate = lastUpdate; + return this; + } + + public Builder currency(final Currency currency) { + this.currency = checkNotNull(currency, ValidationErrors.NULL_RESOURCE + Currency.class); + return this; + } + + public PricingTemplate build() { + PricingTemplateDto dto = new PricingTemplateDto(); + dto.setName(name); + dto.setDescription(description); + dto.setHdGB(hdGB); + dto.setStandingChargePeriod(standingChargePeriod); + dto.setVlan(vlan); + dto.setChargingPeriod(chargingPeriod.ordinal()); + dto.setMinimumCharge(minimumCharge.ordinal()); + dto.setMinimumChargePeriod(minimumChargePeriod); + dto.setShowChangesBefore(showChangesBefore); + dto.setShowMinimumCharge(showMinimumCharge); + dto.setPublicIp(publicIp); + dto.setVcpu(vcpu); + dto.setMemoryGB(memoryGB); + dto.setDefaultTemplate(defaultTemplate); + dto.setLastUpdate(lastUpdate); + + RESTLink link = currency.unwrap().searchLink("edit"); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + dto.addLink(new RESTLink("currency", link.getHref())); + + PricingTemplate pricingTemplate = new PricingTemplate(context, dto); + pricingTemplate.currency = currency; + + return pricingTemplate; + } + + public static Builder fromPricingTemplate(final PricingTemplate in) { + Builder builder = PricingTemplate.builder(in.context, in.currency).name(in.getName()) + .description(in.getDescription()).hdGB(in.getHdGB()).standingChargePeriod(in.getStandingChargePeriod()) + .vcpu(in.getVlan()).chargingPeriod(in.getChargingPeriod()).minimumCharge(in.getMinimumCharge()) + .minimumChargePeriod(in.getMinimumChargePeriod()).showChangesBefore(in.isShowChangesBefore()) + .showMinimumCharge(in.isShowMinimumCharge()).publicIp(in.getPublicIp()).vcpu(in.getVcpu()) + .memoryGB(in.getMemoryGB()).defaultTemplate(in.isDefaultTemplate()).lastUpdate(in.getLastUpdate()); + return builder; + } + } + + // Delegate methods + + public Integer getId() { + return target.getId(); + } + + public String getName() { + return target.getName(); + } + + public void setName(final String name) { + target.setName(name); + } + + public String getDescription() { + return target.getDescription(); + } + + public void setDescription(final String description) { + target.setDescription(description); + } + + public BigDecimal getHdGB() { + return target.getHdGB(); + } + + public void setHdGB(final BigDecimal hdGB) { + target.setHdGB(hdGB); + } + + public BigDecimal getStandingChargePeriod() { + return target.getStandingChargePeriod(); + } + + public void setStandingChargePeriod(final BigDecimal standingChargePeriod) { + target.setStandingChargePeriod(standingChargePeriod); + } + + public BigDecimal getVlan() { + return target.getVlan(); + } + + public void setVlan(final BigDecimal vlan) { + target.getVlan(); + } + + public BigDecimal getMinimumChargePeriod() { + return target.getMinimumChargePeriod(); + } + + public void setMinimumChargePeriod(final BigDecimal minimumChargePeriod) { + target.setMinimumChargePeriod(minimumChargePeriod); + } + + public boolean isShowChangesBefore() { + return target.isShowChangesBefore(); + } + + public void setShowChangesBefore(final boolean showChangesBefore) { + target.setShowChangesBefore(showChangesBefore); + } + + public boolean isShowMinimumCharge() { + return target.isShowMinimumCharge(); + } + + public void setShowMinimumCharge(final boolean showMinimumCharge) { + target.setShowMinimumCharge(showMinimumCharge); + } + + public PricingPeriod getMinimumCharge() { + return PricingPeriod.fromId(target.getMinimumCharge()); + } + + public void setMinimumCharge(final PricingPeriod minimumCharge) { + target.setMinimumCharge(minimumCharge.ordinal()); + } + + public PricingPeriod getChargingPeriod() { + return PricingPeriod.fromId(target.getChargingPeriod()); + } + + public void setChargingPeriod(final PricingPeriod chargingPeriod) { + target.setChargingPeriod(chargingPeriod.ordinal()); + } + + public BigDecimal getPublicIp() { + return target.getPublicIp(); + } + + public void setPublicIp(final BigDecimal publicIp) { + target.setPublicIp(publicIp); + } + + public BigDecimal getVcpu() { + return target.getVcpu(); + } + + public void setVcpu(final BigDecimal vcpu) { + target.setVcpu(vcpu); + } + + public BigDecimal getMemoryGB() { + return target.getMemoryGB(); + } + + public void setMemoryGB(final BigDecimal memoryGB) { + target.setMemoryGB(memoryGB); + } + + public boolean isDefaultTemplate() { + return target.isDefaultTemplate(); + } + + public void setDefaultTemplate(final boolean defaultTemplate) { + target.setDefaultTemplate(defaultTemplate); + } + + public Date getLastUpdate() { + return target.getLastUpdate(); + } + + public void setLastUpdate(final Date lastUpdate) { + target.setLastUpdate(lastUpdate); + } + + @Override + public String toString() { + return "PricingTemplate [id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + + ", hdGB =" + getHdGB() + ", standingChargePeriod =" + getStandingChargePeriod() + ", vlan = " + getVlan() + + ", chargingPeriod =" + getChargingPeriod() + ", minimumChargePeriod=" + getMinimumChargePeriod() + + ", showChangesBefore =" + isShowChangesBefore() + ", showMinimumCharge= " + isShowMinimumCharge() + + ", minimumCharge = " + getMinimumCharge() + ", publicIp = " + getPublicIp() + ", vcpu =" + getVcpu() + + ", memoryGB= " + getMemoryGB() + ", defaultTemplate= " + isDefaultTemplate() + ", lastUpdate = " + + getLastUpdate() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java index 36a4612bb1..89f4ec548c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/PricingTier.java @@ -37,94 +37,79 @@ import com.abiquo.server.core.pricing.PricingTierDto; * * @author Susana Acedo */ -public class PricingTier extends DomainWrapper -{ - private Tier tier; +public class PricingTier extends DomainWrapper { + private Tier tier; - private PricingTemplate pricingTemplate; + private PricingTemplate pricingTemplate; - protected PricingTier(final RestContext context, - final PricingTierDto target) - { - super(context, target); - } + protected PricingTier(final RestContext context, final PricingTierDto target) { + super(context, target); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final PricingTemplate pricingtemplate, final Tier tier) - { - return new Builder(context, pricingtemplate, tier); - } + public static Builder builder(final RestContext context, + final PricingTemplate pricingtemplate, final Tier tier) { + return new Builder(context, pricingtemplate, tier); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Integer id; + private Integer id; - private PricingTemplate pricingTemplate; + private PricingTemplate pricingTemplate; - private Tier tier; + private Tier tier; - private BigDecimal price; + private BigDecimal price; - public Builder(final RestContext context, - final PricingTemplate pricingTemplate, final Tier tier) - { - super(); - this.pricingTemplate = - checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE - + PricingTemplate.class); - this.tier = checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class); - this.context = context; - } + public Builder(final RestContext context, final PricingTemplate pricingTemplate, + final Tier tier) { + super(); + this.pricingTemplate = checkNotNull(pricingTemplate, ValidationErrors.NULL_RESOURCE + PricingTemplate.class); + this.tier = checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Tier.class); + this.context = context; + } - public Builder price(final BigDecimal price) - { - this.price = price; - return this; - } + public Builder price(final BigDecimal price) { + this.price = price; + return this; + } - public PricingTier build() - { - PricingTierDto dto = new PricingTierDto(); - dto.setId(id); - dto.setPrice(price); + public PricingTier build() { + PricingTierDto dto = new PricingTierDto(); + dto.setId(id); + dto.setPrice(price); - RESTLink link = tier.unwrap().searchLink("edit"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - dto.addLink(new RESTLink("tier", link.getHref())); + RESTLink link = tier.unwrap().searchLink("edit"); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + dto.addLink(new RESTLink("tier", link.getHref())); - PricingTier pricingTier = new PricingTier(context, dto); - pricingTier.pricingTemplate = pricingTemplate; - pricingTier.tier = tier; + PricingTier pricingTier = new PricingTier(context, dto); + pricingTier.pricingTemplate = pricingTemplate; + pricingTier.tier = tier; - return pricingTier; - } + return pricingTier; + } - public static Builder fromPricingTier(final PricingTier in) - { - return PricingTier.builder(in.context, in.pricingTemplate, in.tier) - .price(in.getPrice()); - } - } + public static Builder fromPricingTier(final PricingTier in) { + return PricingTier.builder(in.context, in.pricingTemplate, in.tier).price(in.getPrice()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public BigDecimal getPrice() - { - return target.getPrice(); - } + public BigDecimal getPrice() { + return target.getPrice(); + } - @Override - public String toString() - { - return "PricingTier [id=" + getId() + ", price=" + getPrice() + "]"; - } + @Override + public String toString() { + return "PricingTier [id=" + getId() + ", price=" + getPrice() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java index a35e4ee1bf..8c828dbdcf 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/Privilege.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.config; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -35,32 +34,28 @@ import com.abiquo.server.core.enterprise.PrivilegeDto; * @author Francesc Montserrat */ @EnterpriseEdition -public class Privilege extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private Privilege(final RestContext context, final PrivilegeDto target) - { - super(context, target); - } +public class Privilege extends DomainWrapper { + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private Privilege(final RestContext context, final PrivilegeDto target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - @Override - public String toString() - { - return "Privilege [id=" + getId() + ", name=" + getName() + "]"; - } + @Override + public String toString() { + return "Privilege [id=" + getId() + ", name=" + getName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java index 51c88c4cc9..07c57827a2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.config; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -32,53 +31,49 @@ import com.abiquo.server.core.config.SystemPropertyDto; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/System+Property+resource + * @see API: http://community.abiquo.com/display/ABI20/System+Property+resource */ -public class SystemProperty extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private SystemProperty(final RestContext context, final SystemPropertyDto target) - { - super(context, target); - } +public class SystemProperty extends DomainWrapper { + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private SystemProperty(final RestContext context, final SystemPropertyDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * @see API: - * http://community.abiquo.com/display/ABI20/System+Property+resource#SystemPropertyresource-ModifyanexistingSystemProperty - */ - public void update() - { - target = context.getApi().getConfigApi().updateSystemProperty(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/System+Property+resource# + * SystemPropertyresource-ModifyanexistingSystemProperty + */ + public void update() { + target = context.getApi().getConfigApi().updateSystemProperty(target); + } - // Delegate methods + // Delegate methods - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getValue() - { - return target.getValue(); - } + public String getValue() { + return target.getValue(); + } - public void setValue(final String value) - { - target.setValue(value); - } + public void setValue(final String value) { + target.setValue(value); + } - @Override - public String toString() - { - return "SystemPorperty [getName()=" + getName() + ", getValue()=" + getValue() + "]"; - } + @Override + public String toString() { + return "SystemPorperty [getName()=" + getName() + ", getValue()=" + getValue() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java index 5c975815b7..792abeefd1 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java @@ -26,40 +26,33 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class IconOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class IconOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - IconOptions options = new IconOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + IconOptions options = new IconOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private String path; + public static class Builder { + private String path; - public Builder path(final String path) - { - this.path = path; - return this; - } + public Builder path(final String path) { + this.path = path; + return this; + } - public IconOptions build() - { - IconOptions options = new IconOptions(); - if (path != null) - { - options.queryParameters.put("path", path); - } + public IconOptions build() { + IconOptions options = new IconOptions(); + if (path != null) { + options.queryParameters.put("path", path); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java index 7234fc2686..252b507791 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java @@ -28,51 +28,43 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * @author Francesc Montserrat */ @EnterpriseEdition -public class LicenseOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class LicenseOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - LicenseOptions options = new LicenseOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + LicenseOptions options = new LicenseOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private Boolean active; + public static class Builder { + private Boolean active; - /** - * Search active licenses - */ - public Builder active(final boolean active) - { - this.active = active; - return this; - } + /** + * Search active licenses + */ + public Builder active(final boolean active) { + this.active = active; + return this; + } - /** - * Search inaactive licenses - */ - public Builder inactive(final boolean inactive) - { - this.active = !inactive; - return this; - } + /** + * Search inaactive licenses + */ + public Builder inactive(final boolean inactive) { + this.active = !inactive; + return this; + } - public LicenseOptions build() - { - LicenseOptions options = new LicenseOptions(); - if (active != null) - { - options.queryParameters.put("active", active.toString()); - } - return options; - } - } + public LicenseOptions build() { + LicenseOptions options = new LicenseOptions(); + if (active != null) { + options.queryParameters.put("active", active.toString()); + } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java index 1f8a3876d4..8b9c597619 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java @@ -26,52 +26,43 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class PropertyOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class PropertyOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - PropertyOptions options = new PropertyOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + PropertyOptions options = new PropertyOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private String component; + public static class Builder { + private String component; - private String name; + private String name; - public Builder component(final String component) - { - this.component = component; - return this; - } + public Builder component(final String component) { + this.component = component; + return this; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public PropertyOptions build() - { - PropertyOptions options = new PropertyOptions(); - if (component != null) - { - options.queryParameters.put("component", component.toString()); - } + public PropertyOptions build() { + PropertyOptions options = new PropertyOptions(); + if (component != null) { + options.queryParameters.put("component", component.toString()); + } - if (name != null) - { - options.queryParameters.put("name", name.toString()); - } - return options; - } - } + if (name != null) { + options.queryParameters.put("name", name.toString()); + } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java index f62ee8b90a..7b6d55bfa5 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java @@ -74,927 +74,859 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/EnterpriseResource */ -public class Enterprise extends DomainWithLimitsWrapper -{ - /** The default value for the reservation restricted flag. */ - private static final boolean DEFAULT_RESERVATION_RESTRICTED = false; +public class Enterprise extends DomainWithLimitsWrapper { + /** The default value for the reservation restricted flag. */ + private static final boolean DEFAULT_RESERVATION_RESTRICTED = false; - /** - * Constructor to be used only by the builder. - */ - protected Enterprise(final RestContext context, - final EnterpriseDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Enterprise(final RestContext context, final EnterpriseDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * DeleteanexistingEnterprise - */ - public void delete() - { - context.getApi().getEnterpriseApi().deleteEnterprise(target); - target = null; - } + /** + * Delete the enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- DeleteanexistingEnterprise + */ + public void delete() { + context.getApi().getEnterpriseApi().deleteEnterprise(target); + target = null; + } - /** - * Create a new enterprise in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * CreatesanewEnterprise - */ - public void save() - { - target = context.getApi().getEnterpriseApi().createEnterprise(target); - } + /** + * Create a new enterprise in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- CreatesanewEnterprise + */ + public void save() { + target = context.getApi().getEnterpriseApi().createEnterprise(target); + } - /** - * Update emterprise information in the server with the data from this enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * Updateanexistingenterprise - */ - public void update() - { - target = context.getApi().getEnterpriseApi().updateEnterprise(target); - } + /** + * Update emterprise information in the server with the data from this + * enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- Updateanexistingenterprise + */ + public void update() { + target = context.getApi().getEnterpriseApi().updateEnterprise(target); + } - // Children access + // Children access - /** - * Retrieve the list of virtual datacenters by this enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvitualdatacentersbyanEnterprise - * @return List of virtual datacenters in this enterprise. - */ - public List listVirtualDatacenters() - { - VirtualDatacentersDto dto = - context.getApi().getEnterpriseApi().listVirtualDatacenters(target); - return wrap(context, VirtualDatacenter.class, dto.getCollection()); - } + /** + * Retrieve the list of virtual datacenters by this enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievealistofvitualdatacentersbyanEnterprise + * @return List of virtual datacenters in this enterprise. + */ + public List listVirtualDatacenters() { + VirtualDatacentersDto dto = context.getApi().getEnterpriseApi().listVirtualDatacenters(target); + return wrap(context, VirtualDatacenter.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of virtual datacenters by this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvitualdatacentersbyanEnterprise - * @return Filtered list of virtual datacenters in this enterprise. - */ - public List listVirtualDatacenters(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualDatacenters(), filter)); - } + /** + * Retrieve a filtered list of virtual datacenters by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievealistofvitualdatacentersbyanEnterprise + * @return Filtered list of virtual datacenters in this enterprise. + */ + public List listVirtualDatacenters(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualDatacenters(), filter)); + } - /** - * Retrieve a the first virtual datacenter matching the filter within the list of virtual - * datacenters by this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvitualdatacentersbyanEnterprise - * @return First virtual datacenter matching the filter or null if the is none. - */ - public VirtualDatacenter findVirtualDatacenter(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualDatacenters(), filter), null); - } + /** + * Retrieve a the first virtual datacenter matching the filter within the + * list of virtual datacenters by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievealistofvitualdatacentersbyanEnterprise + * @return First virtual datacenter matching the filter or null + * if the is none. + */ + public VirtualDatacenter findVirtualDatacenter(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualDatacenters(), filter), null); + } - /** - * Retrieve the list of template definition lists of the enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists - * @return List of template definition lists of the enterprise. - */ - public List listTemplateDefinitionLists() - { - TemplateDefinitionListsDto dto = - context.getApi().getEnterpriseApi().listTemplateDefinitionLists(target); - return wrap(context, TemplateDefinitionList.class, dto.getCollection()); - } + /** + * Retrieve the list of template definition lists of the enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists + * @return List of template definition lists of the enterprise. + */ + public List listTemplateDefinitionLists() { + TemplateDefinitionListsDto dto = context.getApi().getEnterpriseApi().listTemplateDefinitionLists(target); + return wrap(context, TemplateDefinitionList.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of template definition lists from this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists - * @return Filtered list of template definition lists of the enterprise. - */ - public List listTemplateDefinitionLists( - final Predicate filter) - { - return Lists.newLinkedList(filter(listTemplateDefinitionLists(), filter)); - } + /** + * Retrieve a filtered list of template definition lists from this + * enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists + * @return Filtered list of template definition lists of the enterprise. + */ + public List listTemplateDefinitionLists(final Predicate filter) { + return Lists.newLinkedList(filter(listTemplateDefinitionLists(), filter)); + } - /** - * Retrieve the first template definition list matching the filter within the list. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists - * @return First template definition list matching the filter or null if the is - * none. - */ - public TemplateDefinitionList findTemplateDefinitionList( - final Predicate filter) - { - return Iterables.getFirst(filter(listTemplateDefinitionLists(), filter), null); - } + /** + * Retrieve the first template definition list matching the filter within the + * list. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists + * @return First template definition list matching the filter or + * null if the is none. + */ + public TemplateDefinitionList findTemplateDefinitionList(final Predicate filter) { + return Iterables.getFirst(filter(listTemplateDefinitionLists(), filter), null); + } - /** - * Retrieve a single template definition list. - * - * @param id Unique ID of the template definition list for this enterprise. - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrieveatemplatedefinitionlist - * @return Template definition with the given id or null if it does not exist. - */ - public TemplateDefinitionList getTemplateDefinitionList(final Integer id) - { - TemplateDefinitionListDto templateList = - context.getApi().getEnterpriseApi().getTemplateDefinitionList(target, id); - return wrap(context, TemplateDefinitionList.class, templateList); - } + /** + * Retrieve a single template definition list. + * + * @param id + * Unique ID of the template definition list for this enterprise. + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Retrieveatemplatedefinitionlist + * @return Template definition with the given id or null if it + * does not exist. + */ + public TemplateDefinitionList getTemplateDefinitionList(final Integer id) { + TemplateDefinitionListDto templateList = context.getApi().getEnterpriseApi() + .getTemplateDefinitionList(target, id); + return wrap(context, TemplateDefinitionList.class, templateList); + } - /** - * Retrieve the list of datacenter limits by enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# - * DatacenterLimitsResource-Retrievelimitsbyenterprise - * @return List of datacenter limits by enterprise. - */ - public List listLimits() - { - DatacentersLimitsDto dto = context.getApi().getEnterpriseApi().listLimits(this.unwrap()); - return wrap(context, Limits.class, dto.getCollection()); - } + /** + * Retrieve the list of datacenter limits by enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# + * DatacenterLimitsResource-Retrievelimitsbyenterprise + * @return List of datacenter limits by enterprise. + */ + public List listLimits() { + DatacentersLimitsDto dto = context.getApi().getEnterpriseApi().listLimits(this.unwrap()); + return wrap(context, Limits.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of datacenter limits by enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# - * DatacenterLimitsResource-Retrievelimitsbyenterprise - * @return Filtered list of datacenter limits by enterprise. - */ - public List listLimits(final Predicate filter) - { - return Lists.newLinkedList(filter(listLimits(), filter)); - } + /** + * Retrieve a filtered list of datacenter limits by enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# + * DatacenterLimitsResource-Retrievelimitsbyenterprise + * @return Filtered list of datacenter limits by enterprise. + */ + public List listLimits(final Predicate filter) { + return Lists.newLinkedList(filter(listLimits(), filter)); + } - /** - * Retrieve the first datacenter limits matching the filter within the list of datacenter limits - * by enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# - * DatacenterLimitsResource-Retrievelimitsbyenterprise - * @return First datacenter limits matching the filter or null if there is none. - */ - public Limits findLimits(final Predicate filter) - { - return Iterables.getFirst(filter(listLimits(), filter), null); - } + /** + * Retrieve the first datacenter limits matching the filter within the list + * of datacenter limits by enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# + * DatacenterLimitsResource-Retrievelimitsbyenterprise + * @return First datacenter limits matching the filter or null + * if there is none. + */ + public Limits findLimits(final Predicate filter) { + return Iterables.getFirst(filter(listLimits(), filter), null); + } - /** - * Retrieve the defined properties of the given enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterprisePropertiesResource# - * EnterprisePropertiesResource-Retrievethepropertiesforanenterprise - * @return The defined properties of the given enterprise. - */ - public EnterpriseProperties getEnterpriseProperties() - { - EnterprisePropertiesDto dto = - context.getApi().getEnterpriseApi().getEnterpriseProperties(this.unwrap()); - return wrap(context, EnterpriseProperties.class, dto); - } + /** + * Retrieve the defined properties of the given enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/ + * EnterprisePropertiesResource# + * EnterprisePropertiesResource-Retrievethepropertiesforanenterprise + * @return The defined properties of the given enterprise. + */ + public EnterpriseProperties getEnterpriseProperties() { + EnterprisePropertiesDto dto = context.getApi().getEnterpriseApi().getEnterpriseProperties(this.unwrap()); + return wrap(context, EnterpriseProperties.class, dto); + } - /** - * Retrieve the list of users of this enterprise. - * - * @see API: - * http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers - * - * @return List of users of this enterprise. - */ - public List listUsers() - { - UsersDto dto = context.getApi().getEnterpriseApi().listUsers(this.unwrap()); - return wrap(context, User.class, dto.getCollection()); - } + /** + * Retrieve the list of users of this enterprise. + * + * @see API: + * http://community.abiquo.com/display/ABI20/UserResource#UserResource- + * Retrievealistofusers + * @return List of users of this enterprise. + */ + public List listUsers() { + UsersDto dto = context.getApi().getEnterpriseApi().listUsers(this.unwrap()); + return wrap(context, User.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of users of this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers - * - * @return Filtered list of users of this enterprise. - */ - public List listUsers(final Predicate filter) - { - return Lists.newLinkedList(filter(listUsers(), filter)); - } + /** + * Retrieve a filtered list of users of this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/UserResource#UserResource- + * Retrievealistofusers + * @return Filtered list of users of this enterprise. + */ + public List listUsers(final Predicate filter) { + return Lists.newLinkedList(filter(listUsers(), filter)); + } - /** - * Retrieve the first user matching the filter within the list of users of this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers - * - * @return First user matching the filter or null if there is none. - */ - public User findUser(final Predicate filter) - { - return Iterables.getFirst(filter(listUsers(), filter), null); - } + /** + * Retrieve the first user matching the filter within the list of users of + * this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/UserResource#UserResource- + * Retrievealistofusers + * @return First user matching the filter or null if there is + * none. + */ + public User findUser(final Predicate filter) { + return Iterables.getFirst(filter(listUsers(), filter), null); + } - /** - * Retrieve a single user. - * - * @param id Unique ID of the user in this enterprise. - * @see API: - * http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrieveauser - * @return User with the given id or null if it does not exist. - */ - public User getUser(final Integer id) - { - UserDto user = context.getApi().getEnterpriseApi().getUser(target, id); - return wrap(context, User.class, user); - } + /** + * Retrieve a single user. + * + * @param id + * Unique ID of the user in this enterprise. + * @see API: + * http://community.abiquo.com/display/ABI20/UserResource#UserResource- + * Retrieveauser + * @return User with the given id or null if it does not exist. + */ + public User getUser(final Integer id) { + UserDto user = context.getApi().getEnterpriseApi().getUser(target, id); + return wrap(context, User.class, user); + } - /** - * Retrieve the list of roles defined by this enterprise. - * - * @return List of roles by this enterprise. - */ - public List listRoles() - { - RolesDto dto = context.getApi().getAdminApi().listRoles(target); - return wrap(context, Role.class, dto.getCollection()); - } + /** + * Retrieve the list of roles defined by this enterprise. + * + * @return List of roles by this enterprise. + */ + public List listRoles() { + RolesDto dto = context.getApi().getAdminApi().listRoles(target); + return wrap(context, Role.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of roles defined by this enterprise. - * - * @param filter Filter to be applied to the list. - * @return Filtered list of roles by this enterprise. - */ - public List listRoles(final Predicate filter) - { - return Lists.newLinkedList(filter(listRoles(), filter)); - } + /** + * Retrieve a filtered list of roles defined by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @return Filtered list of roles by this enterprise. + */ + public List listRoles(final Predicate filter) { + return Lists.newLinkedList(filter(listRoles(), filter)); + } - /** - * Retrieve the first role matching the filter within the list of roles defined by this - * enterprise. - * - * @param filter Filter to be applied to the list. - * @return First role matching the filter or null if there is none. - */ - public Role findRole(final Predicate filter) - { - return Iterables.getFirst(filter(listRoles(), filter), null); - } + /** + * Retrieve the first role matching the filter within the list of roles + * defined by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @return First role matching the filter or null if there is + * none. + */ + public Role findRole(final Predicate filter) { + return Iterables.getFirst(filter(listRoles(), filter), null); + } - public List listTemplatesInRepository(final Datacenter datacenter) - { - VirtualMachineTemplatesDto dto = - context.getApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(target.getId(), datacenter.getId()); - return wrap(context, VirtualMachineTemplate.class, dto.getCollection()); - } + public List listTemplatesInRepository(final Datacenter datacenter) { + VirtualMachineTemplatesDto dto = context.getApi().getVirtualMachineTemplateApi() + .listVirtualMachineTemplates(target.getId(), datacenter.getId()); + return wrap(context, VirtualMachineTemplate.class, dto.getCollection()); + } - public List listTemplatesInRepository(final Datacenter datacenter, - final Predicate filter) - { - return Lists.newLinkedList(filter(listTemplatesInRepository(datacenter), filter)); - } + public List listTemplatesInRepository(final Datacenter datacenter, + final Predicate filter) { + return Lists.newLinkedList(filter(listTemplatesInRepository(datacenter), filter)); + } - public VirtualMachineTemplate findTemplateInRepository(final Datacenter datacenter, - final Predicate filter) - { - return Iterables.getFirst(filter(listTemplatesInRepository(datacenter), filter), null); - } + public VirtualMachineTemplate findTemplateInRepository(final Datacenter datacenter, + final Predicate filter) { + return Iterables.getFirst(filter(listTemplatesInRepository(datacenter), filter), null); + } - public VirtualMachineTemplate getTemplateInRepository(final Datacenter datacenter, - final Integer id) - { - VirtualMachineTemplateDto template = - context.getApi().getVirtualMachineTemplateApi() - .getVirtualMachineTemplate(target.getId(), datacenter.getId(), id); - return wrap(context, VirtualMachineTemplate.class, template); - } + public VirtualMachineTemplate getTemplateInRepository(final Datacenter datacenter, final Integer id) { + VirtualMachineTemplateDto template = context.getApi().getVirtualMachineTemplateApi() + .getVirtualMachineTemplate(target.getId(), datacenter.getId(), id); + return wrap(context, VirtualMachineTemplate.class, template); + } - public List listTemplates() - { - ListVirtualMachineTemplates strategy = - context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class); - return Lists.newLinkedList(strategy.execute(this)); - } + public List listTemplates() { + ListVirtualMachineTemplates strategy = context.getUtils().getInjector() + .getInstance(ListVirtualMachineTemplates.class); + return Lists.newLinkedList(strategy.execute(this)); + } - public List listTemplates(final Predicate filter) - { - ListVirtualMachineTemplates strategy = - context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class); - return Lists.newLinkedList(strategy.execute(this, filter)); - } + public List listTemplates(final Predicate filter) { + ListVirtualMachineTemplates strategy = context.getUtils().getInjector() + .getInstance(ListVirtualMachineTemplates.class); + return Lists.newLinkedList(strategy.execute(this, filter)); + } - public VirtualMachineTemplate findTemplate(final Predicate filter) - { - ListVirtualMachineTemplates strategy = - context.getUtils().getInjector().getInstance(ListVirtualMachineTemplates.class); - return Iterables.getFirst(strategy.execute(this, filter), null); - } + public VirtualMachineTemplate findTemplate(final Predicate filter) { + ListVirtualMachineTemplates strategy = context.getUtils().getInjector() + .getInstance(ListVirtualMachineTemplates.class); + return Iterables.getFirst(strategy.execute(this, filter), null); + } - public List listAllowedDatacenters() - { - DatacentersDto datacenters = - context.getApi().getEnterpriseApi().listAllowedDatacenters(target.getId()); - return wrap(context, Datacenter.class, datacenters.getCollection()); - } + public List listAllowedDatacenters() { + DatacentersDto datacenters = context.getApi().getEnterpriseApi().listAllowedDatacenters(target.getId()); + return wrap(context, Datacenter.class, datacenters.getCollection()); + } - public List listAllowedDatacenters(final Predicate filter) - { - return Lists.newLinkedList(filter(listAllowedDatacenters(), filter)); - } + public List listAllowedDatacenters(final Predicate filter) { + return Lists.newLinkedList(filter(listAllowedDatacenters(), filter)); + } - public Datacenter findAllowedDatacenter(final Predicate filter) - { - return Iterables.getFirst(filter(listAllowedDatacenters(), filter), null); - } + public Datacenter findAllowedDatacenter(final Predicate filter) { + return Iterables.getFirst(filter(listAllowedDatacenters(), filter), null); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * Getthelistofexternalnetworks - */ - @EnterpriseEdition - public List listExternalNetworks(final Datacenter datacenter) - { - DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); + /** + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- Getthelistofexternalnetworks + */ + @EnterpriseEdition + public List listExternalNetworks(final Datacenter datacenter) { + DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = - utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworksDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworksDto.class)); - return wrap(context, ExternalNetwork.class, parser.apply(response).getCollection()); - } + return wrap(context, ExternalNetwork.class, parser.apply(response).getCollection()); + } - @EnterpriseEdition - public List listExternalNetworks(final Datacenter datacenter, - final Predicate> filter) - { - return Lists.newLinkedList(filter(listExternalNetworks(datacenter), filter)); - } + @EnterpriseEdition + public List listExternalNetworks(final Datacenter datacenter, + final Predicate> filter) { + return Lists.newLinkedList(filter(listExternalNetworks(datacenter), filter)); + } - @EnterpriseEdition - public ExternalNetwork findExternalNetwork(final Datacenter datacenter, - final Predicate> filter) - { - return Iterables.getFirst(filter(listExternalNetworks(datacenter), filter), null); - } + @EnterpriseEdition + public ExternalNetwork findExternalNetwork(final Datacenter datacenter, final Predicate> filter) { + return Iterables.getFirst(filter(listExternalNetworks(datacenter), filter), null); + } - @EnterpriseEdition - public List listUnmanagedNetworks(final Datacenter datacenter) - { - DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); + @EnterpriseEdition + public List listUnmanagedNetworks(final Datacenter datacenter) { + DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - // The "rel" for the unmanaged networks is the same than teh one used for external networks - HttpResponse response = - utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + // The "rel" for the unmanaged networks is the same than teh one used for + // external networks + HttpResponse response = utils.getAbiquoHttpClient().get(limitForDatacenter.searchLink("externalnetworks")); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworksDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworksDto.class)); - return wrap(context, UnmanagedNetwork.class, parser.apply(response).getCollection()); - } + return wrap(context, UnmanagedNetwork.class, parser.apply(response).getCollection()); + } - @EnterpriseEdition - public List listUnmanagedNetworks(final Datacenter datacenter, - final Predicate> filter) - { - return Lists.newLinkedList(filter(listUnmanagedNetworks(datacenter), filter)); - } + @EnterpriseEdition + public List listUnmanagedNetworks(final Datacenter datacenter, + final Predicate> filter) { + return Lists.newLinkedList(filter(listUnmanagedNetworks(datacenter), filter)); + } - @EnterpriseEdition - public UnmanagedNetwork findUnmanagedNetwork(final Datacenter datacenter, - final Predicate> filter) - { - return Iterables.getFirst(filter(listUnmanagedNetworks(datacenter), filter), null); - } + @EnterpriseEdition + public UnmanagedNetwork findUnmanagedNetwork(final Datacenter datacenter, + final Predicate> filter) { + return Iterables.getFirst(filter(listUnmanagedNetworks(datacenter), filter), null); + } - /** - * Retrieve the list of virtual appliances by this enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievethelistofvirtualappliancesbyanEnterprise - * @return List of virtual appliances by this enterprise. - */ - public List listVirtualAppliances() - { - VirtualAppliancesDto virtualAppliances = - context.getApi().getEnterpriseApi().listVirtualAppliances(target); - return wrap(context, VirtualAppliance.class, virtualAppliances.getCollection()); - } + /** + * Retrieve the list of virtual appliances by this enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievethelistofvirtualappliancesbyanEnterprise + * @return List of virtual appliances by this enterprise. + */ + public List listVirtualAppliances() { + VirtualAppliancesDto virtualAppliances = context.getApi().getEnterpriseApi().listVirtualAppliances(target); + return wrap(context, VirtualAppliance.class, virtualAppliances.getCollection()); + } - /** - * Retrieve a filtered list of virtual appliances by this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievethelistofvirtualappliancesbyanEnterprise - * @return Filtered list of virtual appliances by this enterprise. - */ - public List listVirtualAppliances(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualAppliances(), filter)); - } + /** + * Retrieve a filtered list of virtual appliances by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievethelistofvirtualappliancesbyanEnterprise + * @return Filtered list of virtual appliances by this enterprise. + */ + public List listVirtualAppliances(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualAppliances(), filter)); + } - /** - * Retrieve the first virtual appliance matching the filter within the list of virtual - * appliances in this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievethelistofvirtualappliancesbyanEnterprise - * @return First virtual machine matching the filter or null if the is none. - */ - public VirtualAppliance findVirtualAppliance(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualAppliances(), filter), null); - } + /** + * Retrieve the first virtual appliance matching the filter within the list + * of virtual appliances in this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- + * RetrievethelistofvirtualappliancesbyanEnterprise + * @return First virtual machine matching the filter or null if + * the is none. + */ + public VirtualAppliance findVirtualAppliance(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualAppliances(), filter), null); + } - /** - * Retrieve the list of virtual machines by this enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvirtualmachinesbyanEnterprise - * @return List of virtual machines by this enterprise. - */ - public List listVirtualMachines() - { - VirtualMachinesWithNodeExtendedDto machines = - context.getApi().getEnterpriseApi().listVirtualMachines(target); - return wrap(context, VirtualMachine.class, machines.getCollection()); - } + /** + * Retrieve the list of virtual machines by this enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise + * @return List of virtual machines by this enterprise. + */ + public List listVirtualMachines() { + VirtualMachinesWithNodeExtendedDto machines = context.getApi().getEnterpriseApi().listVirtualMachines(target); + return wrap(context, VirtualMachine.class, machines.getCollection()); + } - /** - * Retrieve a filtered list of virtual machines by this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvirtualmachinesbyanEnterprise - * @return Filtered list of virtual machines by this enterprise. - */ - public List listVirtualMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualMachines(), filter)); - } + /** + * Retrieve a filtered list of virtual machines by this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise + * @return Filtered list of virtual machines by this enterprise. + */ + public List listVirtualMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualMachines(), filter)); + } - /** - * Retrieve the first virtual machine matching the filter within the list of virtual machines in - * this enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource- - * RetrievealistofvirtualmachinesbyanEnterprise - * @return First virtual machine matching the filter or null if the is none. - */ - public VirtualMachine findVirtualMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } + /** + * Retrieve the first virtual machine matching the filter within the list of + * virtual machines in this enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/EnterpriseResource# + * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise + * @return First virtual machine matching the filter or null if + * the is none. + */ + public VirtualMachine findVirtualMachine(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualMachines(), filter), null); + } - public List listReservedMachines() - { - MachinesDto machines = context.getApi().getEnterpriseApi().listReservedMachines(target); - return wrap(context, Machine.class, machines.getCollection()); - } + public List listReservedMachines() { + MachinesDto machines = context.getApi().getEnterpriseApi().listReservedMachines(target); + return wrap(context, Machine.class, machines.getCollection()); + } - public List listReservedMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualMachines(), filter)); - } + public List listReservedMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualMachines(), filter)); + } - public VirtualMachine findReservedMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } + public VirtualMachine findReservedMachine(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualMachines(), filter), null); + } - // Actions + // Actions - /** - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Repository+Resource# - * DatacenterRepositoryResource-SynchronizetheDatacenterRepositorywiththerepository - */ - public void refreshTemplateRepository(final Datacenter datacenter) - { - context.getApi().getEnterpriseApi() - .refreshTemplateRepository(target.getId(), datacenter.getId()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Repository+ + * Resource# DatacenterRepositoryResource- + * SynchronizetheDatacenterRepositorywiththerepository + */ + public void refreshTemplateRepository(final Datacenter datacenter) { + context.getApi().getEnterpriseApi().refreshTemplateRepository(target.getId(), datacenter.getId()); + } - /** - * Allows the given datacenter to be used by this enterprise. Creates a {@link Limits} object if - * not exists. - * - * @param datacenter The datacenter. - * @return Default datacenter limits of the enterprise for the given datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource# - * DatacenterLimitsResource-CreateanewLimitforanenterpriseinadatacenter - */ - public Limits allowDatacenter(final Datacenter datacenter) - { - DatacenterLimitsDto dto; + /** + * Allows the given datacenter to be used by this enterprise. Creates a + * {@link Limits} object if not exists. + * + * @param datacenter + * The datacenter. + * @return Default datacenter limits of the enterprise for the given + * datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Limits+ + * Resource# + * DatacenterLimitsResource-CreateanewLimitforanenterpriseinadatacenter + * + */ + public Limits allowDatacenter(final Datacenter datacenter) { + DatacenterLimitsDto dto; - try - { - // Create new limits - Limits limits = Limits.builder(context).build(); + try { + // Create new limits + Limits limits = Limits.builder(context).build(); - // Save new limits - dto = - context.getApi().getEnterpriseApi() - .createLimits(target, datacenter.unwrap(), limits.unwrap()); - } - catch (AbiquoException ex) - { - // Controlled error to allow duplicated authorizations - if (ex.hasError("LIMIT-7")) - { - DatacentersLimitsDto limits = - context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); - // Should be only one limit - dto = limits.getCollection().get(0); - } - else - { - throw ex; - } - } - - return wrap(context, Limits.class, dto); - } - - /** - * Prohibe the given datacenter to be used by this enterprise. Deletes a {@link Limits} object. - * - * @param datacenter The datacenter. - * @return Default datacenter limits of the enterprise for the given datacenter. - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource# - * DatacenterLimitsResource-Deleteanexistinglimitforanenterpriseinadatacenter - */ - public void prohibitDatacenter(final Datacenter datacenter) - { - // Get limits - DatacentersLimitsDto dto = - context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); - - // Delete limits (if any) - if (dto != null && !dto.isEmpty()) - { + // Save new limits + dto = context.getApi().getEnterpriseApi().createLimits(target, datacenter.unwrap(), limits.unwrap()); + } catch (AbiquoException ex) { + // Controlled error to allow duplicated authorizations + if (ex.hasError("LIMIT-7")) { + DatacentersLimitsDto limits = context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); // Should be only one limit - context.getApi().getEnterpriseApi().deleteLimits(dto.getCollection().get(0)); - } - } + dto = limits.getCollection().get(0); + } else { + throw ex; + } + } - /** - * Disables chef in the enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * DisableChefinanexistingEnterprise - */ - public void disableChef() - { - target.setChefClient(null); - target.setChefClientCertificate(null); - target.setChefURL(null); - target.setChefValidator(null); - target.setChefValidatorCertificate(null); - update(); - } + return wrap(context, Limits.class, dto); + } - // Builder + /** + * Prohibe the given datacenter to be used by this enterprise. Deletes a + * {@link Limits} object. + * + * @param datacenter + * The datacenter. + * @return Default datacenter limits of the enterprise for the given + * datacenter. + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Limits+ + * Resource# DatacenterLimitsResource- + * Deleteanexistinglimitforanenterpriseinadatacenter + */ + public void prohibitDatacenter(final Datacenter datacenter) { + // Get limits + DatacentersLimitsDto dto = context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + // Delete limits (if any) + if (dto != null && !dto.isEmpty()) { + // Should be only one limit + context.getApi().getEnterpriseApi().deleteLimits(dto.getCollection().get(0)); + } + } - public static class Builder extends LimitsBuilder - { - private RestContext context; + /** + * Disables chef in the enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- DisableChefinanexistingEnterprise + */ + public void disableChef() { + target.setChefClient(null); + target.setChefClientCertificate(null); + target.setChefURL(null); + target.setChefValidator(null); + target.setChefValidatorCertificate(null); + update(); + } - private String name; + // Builder - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); + public static Builder builder(final RestContext context) { + return new Builder(context); + } - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); + public static class Builder extends LimitsBuilder { + private RestContext context; - private Boolean isReservationRestricted = DEFAULT_RESERVATION_RESTRICTED; + private String name; - private String chefURL; + protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - private String chefClient; + protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - private String chefValidator; + private Boolean isReservationRestricted = DEFAULT_RESERVATION_RESTRICTED; - private String chefApiCertificate; + private String chefURL; - private String chefValidatorCertificate; + private String chefClient; - public Builder(final RestContext context) - { - super(); - this.context = context; - } + private String chefValidator; - public Builder isReservationRestricted(final boolean isReservationRestricted) - { - this.isReservationRestricted = isReservationRestricted; - return this; - } + private String chefApiCertificate; - public Builder chefURL(final String chefURL) - { - this.chefURL = chefURL; - return this; - } + private String chefValidatorCertificate; - public Builder chefClient(final String chefClient) - { - this.chefClient = chefClient; - return this; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder chefApiCertificate(final String chefApiCertificate) - { - this.chefApiCertificate = chefApiCertificate; - return this; - } + public Builder isReservationRestricted(final boolean isReservationRestricted) { + this.isReservationRestricted = isReservationRestricted; + return this; + } - public Builder chefValidator(final String chefValidator) - { - this.chefValidator = chefValidator; - return this; - } + public Builder chefURL(final String chefURL) { + this.chefURL = chefURL; + return this; + } - public Builder chefValidatorCertificate(final String chefValidatorCertificate) - { - this.chefValidatorCertificate = chefValidatorCertificate; - return this; - } + public Builder chefClient(final String chefClient) { + this.chefClient = chefClient; + return this; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder chefApiCertificate(final String chefApiCertificate) { + this.chefApiCertificate = chefApiCertificate; + return this; + } - public Builder repositoryLimits(final long soft, final long hard) - { - this.repositorySoft = soft; - this.repositoryHard = hard; - return this; - } + public Builder chefValidator(final String chefValidator) { + this.chefValidator = chefValidator; + return this; + } - public Enterprise build() - { - EnterpriseDto dto = new EnterpriseDto(); - dto.setName(name); - dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); - dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); - dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); - dto.setStorageLimits(storageSoft, storageHard); - dto.setVlansLimits(vlansSoft, vlansHard); - dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); - dto.setRepositoryLimits(repositorySoft, repositoryHard); - dto.setIsReservationRestricted(isReservationRestricted); - dto.setChefClient(chefClient); - dto.setChefClientCertificate(chefApiCertificate); - dto.setChefURL(chefURL); - dto.setChefValidator(chefValidator); - dto.setChefValidatorCertificate(chefValidatorCertificate); + public Builder chefValidatorCertificate(final String chefValidatorCertificate) { + this.chefValidatorCertificate = chefValidatorCertificate; + return this; + } - return new Enterprise(context, dto); - } + public Builder name(final String name) { + this.name = name; + return this; + } - public static Builder fromEnterprise(final Enterprise in) - { - return Enterprise.builder(in.context).name(in.getName()) - .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) - .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) - .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) - .storageLimits(in.getStorageSoft(), in.getStorageHard()) - .vlansLimits(in.getVlansSoft(), in.getVlansHard()) - .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) - .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()) - .isReservationRestricted(in.getIsReservationRestricted()) - .chefClient(in.getChefClient()).chefApiCertificate(in.getChefApiCertificate()) - .chefURL(in.getChefURL()).chefValidator(in.getChefValidator()) - .chefValidatorCertificate(in.getChefValidatorCertificate()); - } - } + public Builder repositoryLimits(final long soft, final long hard) { + this.repositorySoft = soft; + this.repositoryHard = hard; + return this; + } - // Delegate methods + public Enterprise build() { + EnterpriseDto dto = new EnterpriseDto(); + dto.setName(name); + dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); + dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); + dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); + dto.setStorageLimits(storageSoft, storageHard); + dto.setVlansLimits(vlansSoft, vlansHard); + dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); + dto.setRepositoryLimits(repositorySoft, repositoryHard); + dto.setIsReservationRestricted(isReservationRestricted); + dto.setChefClient(chefClient); + dto.setChefClientCertificate(chefApiCertificate); + dto.setChefURL(chefURL); + dto.setChefValidator(chefValidator); + dto.setChefValidatorCertificate(chefValidatorCertificate); - public Integer getId() - { - return target.getId(); - } + return new Enterprise(context, dto); + } - public boolean getIsReservationRestricted() - { - return target.getIsReservationRestricted(); - } + public static Builder fromEnterprise(final Enterprise in) { + return Enterprise.builder(in.context).name(in.getName()) + .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) + .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) + .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) + .storageLimits(in.getStorageSoft(), in.getStorageHard()) + .vlansLimits(in.getVlansSoft(), in.getVlansHard()) + .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) + .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()) + .isReservationRestricted(in.getIsReservationRestricted()).chefClient(in.getChefClient()) + .chefApiCertificate(in.getChefApiCertificate()).chefURL(in.getChefURL()) + .chefValidator(in.getChefValidator()).chefValidatorCertificate(in.getChefValidatorCertificate()); + } + } - public String getName() - { - return target.getName(); - } + // Delegate methods - public long getRepositoryHard() - { - return target.getRepositoryHard(); - } + public Integer getId() { + return target.getId(); + } - public long getRepositorySoft() - { - return target.getRepositorySoft(); - } + public boolean getIsReservationRestricted() { + return target.getIsReservationRestricted(); + } - public void setIsReservationRestricted(final boolean isReservationRestricted) - { - target.setIsReservationRestricted(isReservationRestricted); - } + public String getName() { + return target.getName(); + } - public void setName(final String name) - { - target.setName(name); - } + public long getRepositoryHard() { + return target.getRepositoryHard(); + } - public void setRepositoryHard(final long repositoryHard) - { - target.setRepositoryHard(repositoryHard); - } + public long getRepositorySoft() { + return target.getRepositorySoft(); + } - public void setRepositoryLimits(final long soft, final long hard) - { - target.setRepositoryLimits(soft, hard); - } + public void setIsReservationRestricted(final boolean isReservationRestricted) { + target.setIsReservationRestricted(isReservationRestricted); + } - public void setRepositorySoft(final long repositorySoft) - { - target.setRepositorySoft(repositorySoft); - } + public void setName(final String name) { + target.setName(name); + } - public String getChefClient() - { - return target.getChefClient(); - } + public void setRepositoryHard(final long repositoryHard) { + target.setRepositoryHard(repositoryHard); + } - public String getChefApiCertificate() - { - return target.getChefClientCertificate(); - } + public void setRepositoryLimits(final long soft, final long hard) { + target.setRepositoryLimits(soft, hard); + } - public String getChefURL() - { - return target.getChefURL(); - } + public void setRepositorySoft(final long repositorySoft) { + target.setRepositorySoft(repositorySoft); + } - public String getChefValidator() - { - return target.getChefValidator(); - } + public String getChefClient() { + return target.getChefClient(); + } - public String getChefValidatorCertificate() - { - return target.getChefValidatorCertificate(); - } + public String getChefApiCertificate() { + return target.getChefClientCertificate(); + } - public void setChefClient(final String chefClient) - { - target.setChefClient(chefClient); - } + public String getChefURL() { + return target.getChefURL(); + } - public void setChefClientCertificate(final String chefClientCertificate) - { - target.setChefClientCertificate(chefClientCertificate); - } + public String getChefValidator() { + return target.getChefValidator(); + } - public void setChefURL(final String chefURL) - { - target.setChefURL(chefURL); - } + public String getChefValidatorCertificate() { + return target.getChefValidatorCertificate(); + } - public void setChefValidator(final String chefValidator) - { - target.setChefValidator(chefValidator); - } + public void setChefClient(final String chefClient) { + target.setChefClient(chefClient); + } - public void setChefValidatorCertificate(final String chefValidatorCertificate) - { - target.setChefValidatorCertificate(chefValidatorCertificate); - } + public void setChefClientCertificate(final String chefClientCertificate) { + target.setChefClientCertificate(chefClientCertificate); + } - @Override - public String toString() - { - return "Enterprise [id=" + getId() + ", isReservationRestricted=" - + getIsReservationRestricted() + ", name=" + getName() + "]"; - } + public void setChefURL(final String chefURL) { + target.setChefURL(chefURL); + } - private DatacenterLimitsDto getLimits(final Datacenter datacenter) - { - DatacentersLimitsDto limits = context.getApi().getEnterpriseApi().listLimits(target); + public void setChefValidator(final String chefValidator) { + target.setChefValidator(chefValidator); + } - return Iterables.find(limits.getCollection(), new Predicate() - { - @Override - public boolean apply(final DatacenterLimitsDto input) - { - RESTLink datacenterLink = input.searchLink("datacenter"); - return datacenterLink != null - && datacenterLink.getHref().equals(datacenter.unwrap().getEditLink().getHref()); - } - }); - } + public void setChefValidatorCertificate(final String chefValidatorCertificate) { + target.setChefValidatorCertificate(chefValidatorCertificate); + } + + @Override + public String toString() { + return "Enterprise [id=" + getId() + ", isReservationRestricted=" + getIsReservationRestricted() + ", name=" + + getName() + "]"; + } + + private DatacenterLimitsDto getLimits(final Datacenter datacenter) { + DatacentersLimitsDto limits = context.getApi().getEnterpriseApi().listLimits(target); + + return Iterables.find(limits.getCollection(), new Predicate() { + @Override + public boolean apply(final DatacenterLimitsDto input) { + RESTLink datacenterLink = input.searchLink("datacenter"); + return datacenterLink != null + && datacenterLink.getHref().equals(datacenter.unwrap().getEditLink().getHref()); + } + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java index dba92be840..897c49b43b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java @@ -34,55 +34,52 @@ import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; * Adds high level functionality to {@link EnterprisePropertiesDto}. * * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource + * @see API: + * http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource + * */ @EnterpriseEdition -public class EnterpriseProperties extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected EnterpriseProperties(final RestContext context, - final EnterprisePropertiesDto target) - { - super(context, target); - } +public class EnterpriseProperties extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected EnterpriseProperties(final RestContext context, + final EnterprisePropertiesDto target) { + super(context, target); + } - // Domain operations - /** - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource# - * EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise - */ - public void update() - { - target = context.getApi().getEnterpriseApi().updateEnterpriseProperties(target); - } + // Domain operations + /** + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Properties+ + * Resource# + * EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise + */ + public void update() { + target = context.getApi().getEnterpriseApi().updateEnterpriseProperties(target); + } - // Parent access - /** - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * RetrieveaEnterprise - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi() - .getEnterprise(enterpriseId)); - } + // Parent access + /** + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- RetrieveaEnterprise + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); + } - // Delegate methods - public Map getProperties() - { - return target.getProperties(); - } + // Delegate methods + public Map getProperties() { + return target.getProperties(); + } - public void setProperties(final Map properties) - { - target.setProperties(properties); - } + public void setProperties(final Map properties) { + target.setProperties(properties); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java index 3e31eb0f55..bf2fa20ef0 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.enterprise; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; @@ -33,133 +32,120 @@ import com.abiquo.server.core.enterprise.DatacenterLimitsDto; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource */ -public class Limits extends DomainWithLimitsWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Limits(final RestContext context, final DatacenterLimitsDto target) - { - super(context, target); - } +public class Limits extends DomainWithLimitsWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Limits(final RestContext context, final DatacenterLimitsDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-UpdatesanexistingLimitforanenterpriseinadatacenter - */ - public void update() - { - target = context.getApi().getEnterpriseApi().updateLimits(target); - } + /** + * @see API: + * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource + * #DatacenterLimitsResource + * -UpdatesanexistingLimitforanenterpriseinadatacenter + */ + public void update() { + target = context.getApi().getEnterpriseApi().updateLimits(target); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder extends LimitsBuilder - { - private RestContext context; + public static class Builder extends LimitsBuilder { + private RestContext context; - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); + protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); + protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder repositoryLimits(final long soft, final long hard) - { - this.repositorySoft = soft; - this.repositoryHard = hard; - return this; - } + public Builder repositoryLimits(final long soft, final long hard) { + this.repositorySoft = soft; + this.repositoryHard = hard; + return this; + } - public Limits build() - { - DatacenterLimitsDto dto = new DatacenterLimitsDto(); - dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); - dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); - dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); - dto.setStorageLimits(storageSoft, storageHard); - dto.setVlansLimits(vlansSoft, vlansHard); - dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); - dto.setRepositoryHardLimitsInMb(repositoryHard); - dto.setRepositorySoftLimitsInMb(repositorySoft); + public Limits build() { + DatacenterLimitsDto dto = new DatacenterLimitsDto(); + dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); + dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); + dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); + dto.setStorageLimits(storageSoft, storageHard); + dto.setVlansLimits(vlansSoft, vlansHard); + dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); + dto.setRepositoryHardLimitsInMb(repositoryHard); + dto.setRepositorySoftLimitsInMb(repositorySoft); - Limits limits = new Limits(context, dto); + Limits limits = new Limits(context, dto); - return limits; - } + return limits; + } - public static Builder fromEnterprise(final Limits in) - { - return Limits.builder(in.context) - .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) - .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) - .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) - .storageLimits(in.getStorageSoft(), in.getStorageHard()) - .vlansLimits(in.getVlansSoft(), in.getVlansHard()) - .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) - .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()); - } - } + public static Builder fromEnterprise(final Limits in) { + return Limits.builder(in.context).ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) + .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) + .hdLimitsInMb(in.getHdSoftLimitInMb(), in.getHdHardLimitInMb()) + .storageLimits(in.getStorageSoft(), in.getStorageHard()) + .vlansLimits(in.getVlansSoft(), in.getVlansHard()) + .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) + .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public long getRepositoryHard() - { - return target.getRepositoryHardLimitsInMb(); - } + public long getRepositoryHard() { + return target.getRepositoryHardLimitsInMb(); + } - public long getRepositorySoft() - { - return target.getRepositorySoftLimitsInMb(); - } + public long getRepositorySoft() { + return target.getRepositorySoftLimitsInMb(); + } - public void setRepositoryHard(final long repositoryHard) - { - target.setRepositoryHardLimitsInMb(repositoryHard); - } + public void setRepositoryHard(final long repositoryHard) { + target.setRepositoryHardLimitsInMb(repositoryHard); + } - public void setRepositoryLimits(final long soft, final long hard) - { - target.setRepositoryHardLimitsInMb(hard); - target.setRepositorySoftLimitsInMb(soft); - } + public void setRepositoryLimits(final long soft, final long hard) { + target.setRepositoryHardLimitsInMb(hard); + target.setRepositorySoftLimitsInMb(soft); + } - public void setRepositorySoft(final long repositorySoft) - { - target.setRepositorySoftLimitsInMb(repositorySoft); - } + public void setRepositorySoft(final long repositorySoft) { + target.setRepositorySoftLimitsInMb(repositorySoft); + } - @Override - public String toString() - { - return "Limits [id=" + getId() + ", repositoryHard=" + getRepositoryHard() - + ", repositorySoft=" + getRepositorySoft() + ", cpuCounthard=" - + getCpuCountHardLimit() + ", cpuCountSoft=" + getCpuCountSoftLimit() + ", hdHardInMB=" - + getHdHardLimitInMb() + ", hdSoftInMB=" + getHdSoftLimitInMb() + ", publicIPsHard=" - + getPublicIpsHard() + ", publicIpsSoft=" + getPublicIpsSoft() + ", ramHardInMB=" - + getRamHardLimitInMb() + ", ramSoftInMB=" + getRamSoftLimitInMb() + ", storageHard=" - + getStorageHard() + ", storageSoft=" + getStorageSoft() + ", vlansHard=" - + getVlansHard() + ", vlansSoft=" + getVlansSoft() + "]"; - } + @Override + public String toString() { + return "Limits [id=" + getId() + ", repositoryHard=" + getRepositoryHard() + ", repositorySoft=" + + getRepositorySoft() + ", cpuCounthard=" + getCpuCountHardLimit() + ", cpuCountSoft=" + + getCpuCountSoftLimit() + ", hdHardInMB=" + getHdHardLimitInMb() + ", hdSoftInMB=" + getHdSoftLimitInMb() + + ", publicIPsHard=" + getPublicIpsHard() + ", publicIpsSoft=" + getPublicIpsSoft() + ", ramHardInMB=" + + getRamHardLimitInMb() + ", ramSoftInMB=" + getRamSoftLimitInMb() + ", storageHard=" + getStorageHard() + + ", storageSoft=" + getStorageSoft() + ", vlansHard=" + getVlansHard() + ", vlansSoft=" + getVlansSoft() + + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java index b12b62214a..b77c560bf9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java @@ -47,204 +47,177 @@ import com.google.common.collect.Lists; * @see API: * http://community.abiquo.com/display/ABI20/Roles+Resource */ -public class Role extends DomainWrapper -{ - /** Default active value of the user */ - private static final boolean DEFAULT_BLOCKED = false; +public class Role extends DomainWrapper { + /** Default active value of the user */ + private static final boolean DEFAULT_BLOCKED = false; - /** - * Constructor to be used only by the builder. - */ - protected Role(final RestContext context, final RoleDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Role(final RestContext context, final RoleDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-DeleteanexistingRole - * - */ - public void delete() - { - context.getApi().getAdminApi().deleteRole(target); - target = null; - } + /** + * @see API: + * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource + * -DeleteanexistingRole + */ + public void delete() { + context.getApi().getAdminApi().deleteRole(target); + target = null; + } - /** - * @see API: - * http - * ://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-CreateanewRole - */ - public void save() - { - target = context.getApi().getAdminApi().createRole(target); - } + /** + * @see API: http + * ://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource + * -CreateanewRole + */ + public void save() { + target = context.getApi().getAdminApi().createRole(target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-UpdateanexistingRole - * - */ - public void update() - { - target = context.getApi().getAdminApi().updateRole(target); - } + /** + * @see API: + * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource + * -UpdateanexistingRole + */ + public void update() { + target = context.getApi().getAdminApi().updateRole(target); + } - public void setEnterprise(final Enterprise enterprise) - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Enterprise.class); + public void setEnterprise(final Enterprise enterprise) { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - RESTLink link = enterprise.unwrap().searchLink("edit"); + RESTLink link = enterprise.unwrap().searchLink("edit"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - target.addLink(new RESTLink("enterprise", link.getHref())); - } + target.addLink(new RESTLink("enterprise", link.getHref())); + } - @EnterpriseEdition - public void setPrivileges(final List privileges) - { - for (Privilege privilege : privileges) - { - addPrivilege(privilege); - } - } + @EnterpriseEdition + public void setPrivileges(final List privileges) { + for (Privilege privilege : privileges) { + addPrivilege(privilege); + } + } - @EnterpriseEdition - private void addPrivilege(final Privilege privilege) - { - checkNotNull(privilege, ValidationErrors.NULL_RESOURCE + Privilege.class); - checkNotNull(privilege.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Privilege.class); + @EnterpriseEdition + private void addPrivilege(final Privilege privilege) { + checkNotNull(privilege, ValidationErrors.NULL_RESOURCE + Privilege.class); + checkNotNull(privilege.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Privilege.class); - RESTLink link = privilege.unwrap().searchLink("self"); + RESTLink link = privilege.unwrap().searchLink("self"); - // rel would be "privilege" if the object is coming from a privilege list. - if (link == null) - { - link = privilege.unwrap().searchLink("privilege"); - } + // rel would be "privilege" if the object is coming from a privilege list. + if (link == null) { + link = privilege.unwrap().searchLink("privilege"); + } - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref())); - } + target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref())); + } - // Children access + // Children access - /** - * @see API: http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource- - * RetrievealistofprivilegesfromaRole - */ - public List listPrivileges() - { - PrivilegesDto dto = context.getApi().getAdminApi().listPrivileges(target); + /** + * @see API: http://community.abiquo.com/display/ABI20/Roles+Resource# + * RolesResource- RetrievealistofprivilegesfromaRole + */ + public List listPrivileges() { + PrivilegesDto dto = context.getApi().getAdminApi().listPrivileges(target); - return wrap(context, Privilege.class, dto.getCollection()); - } + return wrap(context, Privilege.class, dto.getCollection()); + } - public List listPrivileges(final Predicate filter) - { - return Lists.newLinkedList(filter(listPrivileges(), filter)); - } + public List listPrivileges(final Predicate filter) { + return Lists.newLinkedList(filter(listPrivileges(), filter)); + } - public Privilege findPrivileges(final Predicate filter) - { - return Iterables.getFirst(filter(listPrivileges(), filter), null); - } + public Privilege findPrivileges(final Predicate filter) { + return Iterables.getFirst(filter(listPrivileges(), filter), null); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private boolean blocked = DEFAULT_BLOCKED; + private boolean blocked = DEFAULT_BLOCKED; - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder blocked(final boolean blocked) - { - this.blocked = blocked; - return this; - } + public Builder blocked(final boolean blocked) { + this.blocked = blocked; + return this; + } - public Role build() - { - RoleDto dto = new RoleDto(); - dto.setName(name); - dto.setBlocked(blocked); - Role role = new Role(context, dto); + public Role build() { + RoleDto dto = new RoleDto(); + dto.setName(name); + dto.setBlocked(blocked); + Role role = new Role(context, dto); - return role; - } + return role; + } - public static Builder fromRole(final Role in) - { - return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName()); - } - } + public static Builder fromRole(final Role in) { + return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public boolean isBlocked() - { - return target.isBlocked(); - } + public boolean isBlocked() { + return target.isBlocked(); + } - public void setBlocked(final boolean blocked) - { - target.setBlocked(blocked); - } + public void setBlocked(final boolean blocked) { + target.setBlocked(blocked); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - @Override - public String toString() - { - return "Role [id=" + getId() + ", name=" + getName() + ", blocked=" + isBlocked() + "]"; - } + @Override + public String toString() { + return "Role [id=" + getId() + ", name=" + getName() + ", blocked=" + isBlocked() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java index f4e9b1380b..c8803a5c06 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java @@ -35,202 +35,185 @@ import com.google.common.base.Predicate; import com.google.common.collect.Lists; /** - * Adds high level functionality to {@link TemplateDefinitionListDto}. A Template Definition List - * provides a way to organize multiple Template Definitions. A single Template Definition can be - * shared by many lists. Its compatible with ovfindex.xml format. + * Adds high level functionality to {@link TemplateDefinitionListDto}. A + * Template Definition List provides a way to organize multiple Template + * Definitions. A single Template Definition can be shared by many lists. Its + * compatible with ovfindex.xml format. * * @author Ignasi Barrera * @author Francesc Montserrat */ -public class TemplateDefinitionList extends DomainWrapper -{ - /** The enterprise where the list belongs. */ - private Enterprise enterprise; +public class TemplateDefinitionList extends DomainWrapper { + /** The enterprise where the list belongs. */ + private Enterprise enterprise; - /** - * Constructor to be used only by the builder. - */ - protected TemplateDefinitionList(final RestContext context, - final TemplateDefinitionListDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected TemplateDefinitionList(final RestContext context, + final TemplateDefinitionListDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the template definition list. Deleting the list doesn't delete the containing Template - * Definitions. - * - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Deleteatemplatedefinitionlist - */ - public void delete() - { - context.getApi().getEnterpriseApi().deleteTemplateDefinitionList(target); - target = null; - } + /** + * Delete the template definition list. Deleting the list doesn't delete the + * containing Template Definitions. + * + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Deleteatemplatedefinitionlist + */ + public void delete() { + context.getApi().getEnterpriseApi().deleteTemplateDefinitionList(target); + target = null; + } - /** - * Create a template definition list. All the contained Template Definitions will also be - * created. - * - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Createatemplatedefinitionlistr - */ - public void save() - { - target = - context.getApi().getEnterpriseApi() - .createTemplateDefinitionList(enterprise.unwrap(), target); - } + /** + * Create a template definition list. All the contained Template Definitions + * will also be created. + * + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Createatemplatedefinitionlistr + */ + public void save() { + target = context.getApi().getEnterpriseApi().createTemplateDefinitionList(enterprise.unwrap(), target); + } - /** - * Update a template definition list with the data from this template definition list. - * - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Modifyatemplatedefinitionlist - */ - public void update() - { - target = context.getApi().getEnterpriseApi().updateTemplateDefinitionList(target); - } + /** + * Update a template definition list with the data from this template + * definition list. + * + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# + * TemplateDefinitionListResource-Modifyatemplatedefinitionlist + */ + public void update() { + target = context.getApi().getEnterpriseApi().updateTemplateDefinitionList(target); + } - // Children access + // Children access - /** - * Retrieve the list of states of the templates in the template definition list in the - * repository of the given datacenter. Template Definition are available sources, but in order - * to create a Virtual Machine the Definition should be downloaded into the Datacenter - * Repository (NFS filesystem). - * - * @param The datacenter in which repository search. - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist - */ - public List listStatus(final Datacenter datacenter) - { - TemplatesStateDto states = - context.getApi().getEnterpriseApi() - .listTemplateListStatus(target, datacenter.unwrap()); - return wrap(context, TemplateState.class, states.getCollection()); - } + /** + * Retrieve the list of states of the templates in the template definition + * list in the repository of the given datacenter. Template Definition are + * available sources, but in order to create a Virtual Machine the Definition + * should be downloaded into the Datacenter Repository (NFS filesystem). + * + * @param The + * datacenter in which repository search. + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# TemplateDefinitionListResource- + * Retrievealistofthestatusofalltemplatestatuslist + */ + public List listStatus(final Datacenter datacenter) { + TemplatesStateDto states = context.getApi().getEnterpriseApi() + .listTemplateListStatus(target, datacenter.unwrap()); + return wrap(context, TemplateState.class, states.getCollection()); + } - /** - * Retrieve a filtered list of states of the templates in the template definition list in the - * repository of the given datacenter. Template Definition are available sources, but in order - * to create a Virtual Machine the Definition should be downloaded into the Datacenter - * Repository (NFS filesystem). - * - * @param filter Filter to be applied to the list. - * @param The datacenter in which repository search. - * @see API: http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist - */ - public List listStatus(final Predicate filter, - final Datacenter datacenter) - { - return Lists.newLinkedList(filter(listStatus(datacenter), filter)); - } + /** + * Retrieve a filtered list of states of the templates in the template + * definition list in the repository of the given datacenter. Template + * Definition are available sources, but in order to create a Virtual Machine + * the Definition should be downloaded into the Datacenter Repository (NFS + * filesystem). + * + * @param filter + * Filter to be applied to the list. + * @param The + * datacenter in which repository search. + * @see API: http://community.abiquo.com/display/ABI20/ + * TemplateDefinitionListResource# TemplateDefinitionListResource- + * Retrievealistofthestatusofalltemplatestatuslist + */ + public List listStatus(final Predicate filter, final Datacenter datacenter) { + return Lists.newLinkedList(filter(listStatus(datacenter), filter)); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Enterprise enterprise) - { - return new Builder(context, enterprise); - } + public static Builder builder(final RestContext context, final Enterprise enterprise) { + return new Builder(context, enterprise); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Enterprise enterprise; + private Enterprise enterprise; - private String name; + private String name; - private String url; + private String url; - public Builder(final RestContext context, - final Enterprise enterprise) - { - super(); - this.context = context; - this.enterprise = enterprise; - } + public Builder(final RestContext context, final Enterprise enterprise) { + super(); + this.context = context; + this.enterprise = enterprise; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder url(final String url) - { - this.url = url; - return this; - } + public Builder url(final String url) { + this.url = url; + return this; + } - public TemplateDefinitionList build() - { - TemplateDefinitionListDto dto = new TemplateDefinitionListDto(); - dto.setName(name); - dto.setUrl(url); + public TemplateDefinitionList build() { + TemplateDefinitionListDto dto = new TemplateDefinitionListDto(); + dto.setName(name); + dto.setUrl(url); - TemplateDefinitionList templateList = new TemplateDefinitionList(context, dto); - templateList.enterprise = enterprise; - return templateList; + TemplateDefinitionList templateList = new TemplateDefinitionList(context, dto); + templateList.enterprise = enterprise; + return templateList; - } + } - public static Builder fromTemplateDefinitionList(final TemplateDefinitionList in) - { - return TemplateDefinitionList.builder(in.context, in.enterprise).name(in.getName()) - .url(in.getUrl()); - } - } + public static Builder fromTemplateDefinitionList(final TemplateDefinitionList in) { + return TemplateDefinitionList.builder(in.context, in.enterprise).name(in.getName()).url(in.getUrl()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getUrl() - { - return target.getUrl(); - } + public String getUrl() { + return target.getUrl(); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setUrl(final String url) - { - target.setUrl(url); - } + public void setUrl(final String url) { + target.setUrl(url); + } - @Override - public String toString() - { - return "TemplateDefinitionList [getId()=" + getId() + ", getName()=" + getName() - + ", getUrl()=" + getUrl() + "]"; - } + @Override + public String toString() { + return "TemplateDefinitionList [getId()=" + getId() + ", getName()=" + getName() + ", getUrl()=" + getUrl() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java index c0773b8952..31f02a21cc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java @@ -33,49 +33,40 @@ import com.abiquo.am.model.TemplateStatusEnumType; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class TemplateState extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected TemplateState(final RestContext context, - final TemplateStateDto target) - { - super(context, target); - } +public class TemplateState extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected TemplateState(final RestContext context, final TemplateStateDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public Double getDownloadingProgress() - { - return target.getDownloadingProgress(); - } + public Double getDownloadingProgress() { + return target.getDownloadingProgress(); + } - public String getErrorCause() - { - return target.getErrorCause(); - } + public String getErrorCause() { + return target.getErrorCause(); + } - public String getMasterOvf() - { - return target.getMasterOvf(); - } + public String getMasterOvf() { + return target.getMasterOvf(); + } - public String getOvfId() - { - return target.getOvfId(); - } + public String getOvfId() { + return target.getOvfId(); + } - public TemplateStatusEnumType getStatus() - { - return target.getStatus(); - } + public TemplateStatusEnumType getStatus() { + return target.getStatus(); + } - @Override - public String toString() - { - return "TemplateState [getDownloadingProgress()=" + getDownloadingProgress() - + ", getErrorCause()=" + getErrorCause() + ", getMasterOvf()=" + getMasterOvf() - + ", getOvfId()=" + getOvfId() + ", getStatus()=" + getStatus() + "]"; - } + @Override + public String toString() { + return "TemplateState [getDownloadingProgress()=" + getDownloadingProgress() + ", getErrorCause()=" + + getErrorCause() + ", getMasterOvf()=" + getMasterOvf() + ", getOvfId()=" + getOvfId() + ", getStatus()=" + + getStatus() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java index bfb1b6c86c..26265123bb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java @@ -53,457 +53,392 @@ import com.google.common.collect.Lists; * @see API: * http://community.abiquo.com/display/ABI20/Users+Resource */ -public class User extends DomainWrapper -{ - /** Default active value of the user */ - private static final boolean DEFAULT_ACTIVE = true; - - /** The default authentication type. */ - private static final String DEFAULT_AUTH_TYPE = "ABIQUO"; - - /** The default locale for the user. */ - private static final String DEFAULT_LOCALE = "en_US"; - - /** The enterprise where the user belongs. */ - private Enterprise enterprise; - - /** Role of the user. */ - private Role role; - - /** - * Constructor to be used only by the builder. - */ - protected User(final RestContext context, final UserDto target) - { - super(context, target); - } - - // Domain operations - - /** - * @see API: - * http://community.abiquo.com/display/ABI20/User+resource#Userresource-Deleteanexistinguser - * - */ - public void delete() - { - context.getApi().getEnterpriseApi().deleteUser(target); - target = null; - } - - /** - * @see API: - * http://community.abiquo.com/display/ABI20/User+resource#Userresource-Createanewuser - */ - public void save() - { - // set role link - target.addLink(new RESTLink("role", role.unwrap().getEditLink().getHref())); - target = context.getApi().getEnterpriseApi().createUser(enterprise.unwrap(), target); - } - - /** - * @see API: - * http://community.abiquo.com/display/ABI20/User+resource#Userresource-Updatesanexistinguser - * - */ - public void update() - { - // update role link (if exists) - if (role != null) - { - target.searchLink("role").setHref(role.unwrap().getEditLink().getHref()); - } - - target = context.getApi().getEnterpriseApi().updateUser(target); - } - - public List listPermitedVirtualDatacenters() - { - List ids = extractAvailableDatacenters(); - - // null value means all virtual datacenters all allowed - if (ids.size() == 0) - { - return this.getEnterprise().listVirtualDatacenters(); - } - - ListVirtualDatacenters listVirtualDatacenters = - context.getUtils().getInjector().getInstance(ListVirtualDatacenters.class); - return Lists.newArrayList(listVirtualDatacenters.execute(ids)); - } - - public List listPermitedVirtualDatacenters( - final Predicate filter) - { - return Lists.newLinkedList(filter(listPermitedVirtualDatacenters(), filter)); - } - - public VirtualDatacenter findPermitedVirtualDatacenter(final Predicate filter) - { - return Iterables.getFirst(filter(listPermitedVirtualDatacenters(), filter), null); - } - - /** - * Give access to all virtualdatacenters in the enterprise (requires update). - */ - public void permitAllVirtualDatacenters() - { - setAvailableVirtualDatacenters(null); - } - - /** - * Limits user access ONLY to the virtual datacenters in the list. If the list is empty, user - * will get access to all virtual datacenters. - * - * @param vdc List of virtual datancers from the user's enterprise. - */ - public void setPermitedVirtualDatacenters(final List vdcs) - { - List ids = new ArrayList(); - - for (VirtualDatacenter vdc : vdcs) - { - checkNotNull(vdc.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + VirtualDatacenter.class); - ids.add(vdc.getId()); - } - - setAvailableVirtualDatacenters(ids); - } - - // Parent access - /** - * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource- - * RetrieveaEnterprise - */ - public Enterprise getEnterprise() - { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi() - .getEnterprise(enterpriseId)); - } - - // Children access - - public Role getRole() - { - RoleDto role = context.getApi().getAdminApi().getRole(target); - return wrap(context, Role.class, role); - } - - /** - * @see API: http://community.abiquo.com/display/ABI20/User+resource#Userresource- - * Retrievethelistofvirtualmachinesbyuser - */ - public List listMachines() - { - VirtualMachinesWithNodeExtendedDto machines = - context.getApi().getEnterpriseApi().listVirtualMachines(target); - return wrap(context, VirtualMachine.class, machines.getCollection()); - } - - public List listMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listMachines(), filter)); - } - - public VirtualMachine findMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listMachines(), filter), null); - } - - // Builder - - public static Builder builder(final RestContext context, - final Enterprise enterprise, final Role role) - { - return new Builder(context, enterprise, role); - } - - public static class Builder - { - private RestContext context; - - private Enterprise enterprise; - - private Role role; - - private String name; - - private String nick; - - private String locale = DEFAULT_LOCALE; - - private String password; - - private String surname; - - private boolean active = DEFAULT_ACTIVE; - - private String email; - - private String description; - - private String authType = DEFAULT_AUTH_TYPE; - - public Builder(final RestContext context, - final Enterprise enterprise, final Role role) - { - super(); - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(role, ValidationErrors.NULL_RESOURCE + Role.class); - this.context = context; - this.enterprise = enterprise; - this.role = role; - } - - public Builder enterprise(final Enterprise enterprise) - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.enterprise = enterprise; - return this; - } - - public Builder role(final Role role) - { - this.role = role; - return this; - } - - public Builder name(final String name, final String surname) - { - this.name = name; - this.surname = surname; - return this; - } - - public Builder nick(final String nick) - { - this.nick = nick; - return this; - } - - public Builder locale(final String locale) - { - this.locale = locale; - return this; - } - - public Builder password(final String password) - { - this.password = password; - return this; - } - - public Builder active(final boolean active) - { - this.active = active; - return this; - } - - public Builder email(final String email) - { - this.email = email; - return this; - } - - public Builder description(final String description) - { - this.description = description; - return this; - } - - public Builder authType(final String authType) - { - this.authType = authType; - return this; - } - - public User build() - { - UserDto dto = new UserDto(); - dto.setActive(active); - dto.setAuthType(authType); - dto.setDescription(description); - dto.setEmail(email); - dto.setLocale(locale); - dto.setName(name); - dto.setNick(nick); - dto.setPassword(password); - dto.setSurname(surname); - User user = new User(context, dto); - user.enterprise = enterprise; - user.role = role; - - return user; - } - - public static Builder fromUser(final User in) - { - return User.builder(in.context, in.enterprise, in.role).active(in.isActive()) - .authType(in.getAuthType()).description(in.getDescription()).email(in.getEmail()) - .locale(in.getLocale()).name(in.getName(), in.getSurname()).nick(in.getNick()) - .password(in.getPassword()); - } - } - - // Delegate methods - - public String getAuthType() - { - return target.getAuthType(); - } - - public String getDescription() - { - return target.getDescription(); - } - - public String getEmail() - { - return target.getEmail(); - } - - public Integer getId() - { - return target.getId(); - } - - public String getLocale() - { - return target.getLocale(); - } - - public String getName() - { - return target.getName(); - } - - public String getNick() - { - return target.getNick(); - } - - public String getPassword() - { - return target.getPassword(); - } - - public String getSurname() - { - return target.getSurname(); - } - - public boolean isActive() - { - return target.isActive(); - } - - public void setActive(final boolean active) - { - target.setActive(active); - } - - public void setAuthType(final String authType) - { - target.setAuthType(authType); - } - - public void setDescription(final String description) - { - target.setDescription(description); - } - - public void setEmail(final String email) - { - target.setEmail(email); - } - - public void setLocale(final String locale) - { - target.setLocale(locale); - } - - public void setName(final String name) - { - target.setName(name); - } - - public void setNick(final String nick) - { - target.setNick(nick); - } - - public void setPassword(final String password) - { - target.setPassword(password); - } - - public void setSurname(final String surname) - { - target.setSurname(surname); - } - - public void setRole(final Role role) - { - this.role = role; - } - - // Aux operations - - /** - * Converts the tokenized String of available virtual datacenters provided in the userDto to a - * list of ids. - */ - private List extractAvailableDatacenters() - { - List ids = Lists.newArrayList(); - - if (target.getAvailableVirtualDatacenters() != null) - { - - StringTokenizer st = new StringTokenizer(target.getAvailableVirtualDatacenters(), ","); - - while (st.hasMoreTokens()) - { - ids.add(Integer.parseInt(st.nextToken())); - } - } - - return ids; - } - - private void setAvailableVirtualDatacenters(final List ids) - { - if (ids == null || ids.size() == 0) - { - target.setAvailableVirtualDatacenters(""); - } - else - { - Joiner joiner = Joiner.on(",").skipNulls(); - target.setAvailableVirtualDatacenters(joiner.join(ids)); - } - } - - @Override - public String toString() - { - return "User [id=" + getId() + ", role=" + getRole() + ", authType=" + getAuthType() - + ", description=" + getDescription() + ", email=" + getEmail() + ", locale=" - + getLocale() + ", name=" + getName() + ", nick=" + getNick() + ", password=" - + getPassword() + ", surname=" + getSurname() + ", active=" + isActive() + "]"; - } +public class User extends DomainWrapper { + /** Default active value of the user */ + private static final boolean DEFAULT_ACTIVE = true; + + /** The default authentication type. */ + private static final String DEFAULT_AUTH_TYPE = "ABIQUO"; + + /** The default locale for the user. */ + private static final String DEFAULT_LOCALE = "en_US"; + + /** The enterprise where the user belongs. */ + private Enterprise enterprise; + + /** Role of the user. */ + private Role role; + + /** + * Constructor to be used only by the builder. + */ + protected User(final RestContext context, final UserDto target) { + super(context, target); + } + + // Domain operations + + /** + * @see API: + * http://community.abiquo.com/display/ABI20/User+resource#Userresource + * -Deleteanexistinguser + */ + public void delete() { + context.getApi().getEnterpriseApi().deleteUser(target); + target = null; + } + + /** + * @see API: + * http://community.abiquo.com/display/ABI20/User+resource#Userresource + * -Createanewuser + */ + public void save() { + // set role link + target.addLink(new RESTLink("role", role.unwrap().getEditLink().getHref())); + target = context.getApi().getEnterpriseApi().createUser(enterprise.unwrap(), target); + } + + /** + * @see API: + * http://community.abiquo.com/display/ABI20/User+resource#Userresource + * -Updatesanexistinguser + */ + public void update() { + // update role link (if exists) + if (role != null) { + target.searchLink("role").setHref(role.unwrap().getEditLink().getHref()); + } + + target = context.getApi().getEnterpriseApi().updateUser(target); + } + + public List listPermitedVirtualDatacenters() { + List ids = extractAvailableDatacenters(); + + // null value means all virtual datacenters all allowed + if (ids.size() == 0) { + return this.getEnterprise().listVirtualDatacenters(); + } + + ListVirtualDatacenters listVirtualDatacenters = context.getUtils().getInjector() + .getInstance(ListVirtualDatacenters.class); + return Lists.newArrayList(listVirtualDatacenters.execute(ids)); + } + + public List listPermitedVirtualDatacenters(final Predicate filter) { + return Lists.newLinkedList(filter(listPermitedVirtualDatacenters(), filter)); + } + + public VirtualDatacenter findPermitedVirtualDatacenter(final Predicate filter) { + return Iterables.getFirst(filter(listPermitedVirtualDatacenters(), filter), null); + } + + /** + * Give access to all virtualdatacenters in the enterprise (requires update). + */ + public void permitAllVirtualDatacenters() { + setAvailableVirtualDatacenters(null); + } + + /** + * Limits user access ONLY to the virtual datacenters in the list. If the + * list is empty, user will get access to all virtual datacenters. + * + * @param vdc + * List of virtual datancers from the user's enterprise. + */ + public void setPermitedVirtualDatacenters(final List vdcs) { + List ids = new ArrayList(); + + for (VirtualDatacenter vdc : vdcs) { + checkNotNull(vdc.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + VirtualDatacenter.class); + ids.add(vdc.getId()); + } + + setAvailableVirtualDatacenters(ids); + } + + // Parent access + /** + * @see API: http://community.abiquo.com/display/ABI20/Enterprise+Resource# + * EnterpriseResource- RetrieveaEnterprise + */ + public Enterprise getEnterprise() { + Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); + return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); + } + + // Children access + + public Role getRole() { + RoleDto role = context.getApi().getAdminApi().getRole(target); + return wrap(context, Role.class, role); + } + + /** + * @see API: http://community.abiquo.com/display/ABI20/User+resource# + * Userresource- Retrievethelistofvirtualmachinesbyuser + */ + public List listMachines() { + VirtualMachinesWithNodeExtendedDto machines = context.getApi().getEnterpriseApi().listVirtualMachines(target); + return wrap(context, VirtualMachine.class, machines.getCollection()); + } + + public List listMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listMachines(), filter)); + } + + public VirtualMachine findMachine(final Predicate filter) { + return Iterables.getFirst(filter(listMachines(), filter), null); + } + + // Builder + + public static Builder builder(final RestContext context, final Enterprise enterprise, + final Role role) { + return new Builder(context, enterprise, role); + } + + public static class Builder { + private RestContext context; + + private Enterprise enterprise; + + private Role role; + + private String name; + + private String nick; + + private String locale = DEFAULT_LOCALE; + + private String password; + + private String surname; + + private boolean active = DEFAULT_ACTIVE; + + private String email; + + private String description; + + private String authType = DEFAULT_AUTH_TYPE; + + public Builder(final RestContext context, final Enterprise enterprise, final Role role) { + super(); + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + checkNotNull(role, ValidationErrors.NULL_RESOURCE + Role.class); + this.context = context; + this.enterprise = enterprise; + this.role = role; + } + + public Builder enterprise(final Enterprise enterprise) { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.enterprise = enterprise; + return this; + } + + public Builder role(final Role role) { + this.role = role; + return this; + } + + public Builder name(final String name, final String surname) { + this.name = name; + this.surname = surname; + return this; + } + + public Builder nick(final String nick) { + this.nick = nick; + return this; + } + + public Builder locale(final String locale) { + this.locale = locale; + return this; + } + + public Builder password(final String password) { + this.password = password; + return this; + } + + public Builder active(final boolean active) { + this.active = active; + return this; + } + + public Builder email(final String email) { + this.email = email; + return this; + } + + public Builder description(final String description) { + this.description = description; + return this; + } + + public Builder authType(final String authType) { + this.authType = authType; + return this; + } + + public User build() { + UserDto dto = new UserDto(); + dto.setActive(active); + dto.setAuthType(authType); + dto.setDescription(description); + dto.setEmail(email); + dto.setLocale(locale); + dto.setName(name); + dto.setNick(nick); + dto.setPassword(password); + dto.setSurname(surname); + User user = new User(context, dto); + user.enterprise = enterprise; + user.role = role; + + return user; + } + + public static Builder fromUser(final User in) { + return User.builder(in.context, in.enterprise, in.role).active(in.isActive()).authType(in.getAuthType()) + .description(in.getDescription()).email(in.getEmail()).locale(in.getLocale()) + .name(in.getName(), in.getSurname()).nick(in.getNick()).password(in.getPassword()); + } + } + + // Delegate methods + + public String getAuthType() { + return target.getAuthType(); + } + + public String getDescription() { + return target.getDescription(); + } + + public String getEmail() { + return target.getEmail(); + } + + public Integer getId() { + return target.getId(); + } + + public String getLocale() { + return target.getLocale(); + } + + public String getName() { + return target.getName(); + } + + public String getNick() { + return target.getNick(); + } + + public String getPassword() { + return target.getPassword(); + } + + public String getSurname() { + return target.getSurname(); + } + + public boolean isActive() { + return target.isActive(); + } + + public void setActive(final boolean active) { + target.setActive(active); + } + + public void setAuthType(final String authType) { + target.setAuthType(authType); + } + + public void setDescription(final String description) { + target.setDescription(description); + } + + public void setEmail(final String email) { + target.setEmail(email); + } + + public void setLocale(final String locale) { + target.setLocale(locale); + } + + public void setName(final String name) { + target.setName(name); + } + + public void setNick(final String nick) { + target.setNick(nick); + } + + public void setPassword(final String password) { + target.setPassword(password); + } + + public void setSurname(final String surname) { + target.setSurname(surname); + } + + public void setRole(final Role role) { + this.role = role; + } + + // Aux operations + + /** + * Converts the tokenized String of available virtual datacenters provided in + * the userDto to a list of ids. + */ + private List extractAvailableDatacenters() { + List ids = Lists.newArrayList(); + + if (target.getAvailableVirtualDatacenters() != null) { + + StringTokenizer st = new StringTokenizer(target.getAvailableVirtualDatacenters(), ","); + + while (st.hasMoreTokens()) { + ids.add(Integer.parseInt(st.nextToken())); + } + } + + return ids; + } + + private void setAvailableVirtualDatacenters(final List ids) { + if (ids == null || ids.size() == 0) { + target.setAvailableVirtualDatacenters(""); + } else { + Joiner joiner = Joiner.on(",").skipNulls(); + target.setAvailableVirtualDatacenters(joiner.join(ids)); + } + } + + @Override + public String toString() { + return "User [id=" + getId() + ", role=" + getRole() + ", authType=" + getAuthType() + ", description=" + + getDescription() + ", email=" + getEmail() + ", locale=" + getLocale() + ", name=" + getName() + + ", nick=" + getNick() + ", password=" + getPassword() + ", surname=" + getSurname() + ", active=" + + isActive() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java index fb5bfdbbbe..f64e95a1a7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java @@ -27,106 +27,89 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class EnterpriseOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class EnterpriseOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - EnterpriseOptions options = new EnterpriseOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + EnterpriseOptions options = new EnterpriseOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder extends BaseFilterOptionsBuilder - { - private String idPricingTemplate; + public static class Builder extends BaseFilterOptionsBuilder { + private String idPricingTemplate; - private Boolean included; + private Boolean included; - private String filter; + private String filter; - private Integer page; + private Integer page; - private Integer results; + private Integer results; - private Boolean network; + private Boolean network; - public Builder pricingTemplate(final String idPricingTemplate) - { - this.idPricingTemplate = idPricingTemplate; - return this; - } + public Builder pricingTemplate(final String idPricingTemplate) { + this.idPricingTemplate = idPricingTemplate; + return this; + } - public Builder included(final boolean included) - { - this.included = included; - return this; - } + public Builder included(final boolean included) { + this.included = included; + return this; + } - public Builder filter(final String filter) - { - this.filter = filter; - return this; - } + public Builder filter(final String filter) { + this.filter = filter; + return this; + } - public Builder network(final boolean network) - { - this.network = network; - return this; - } + public Builder network(final boolean network) { + this.network = network; + return this; + } - public Builder page(final int page) - { - this.page = page; - return this; - } + public Builder page(final int page) { + this.page = page; + return this; + } - public Builder results(final int results) - { - this.results = results; - return this; - } + public Builder results(final int results) { + this.results = results; + return this; + } - public EnterpriseOptions build() - { - EnterpriseOptions options = new EnterpriseOptions(); + public EnterpriseOptions build() { + EnterpriseOptions options = new EnterpriseOptions(); - if (idPricingTemplate != null) - { - options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate)); - } + if (idPricingTemplate != null) { + options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate)); + } - if (included != null) - { - options.queryParameters.put("included", String.valueOf(included)); - } + if (included != null) { + options.queryParameters.put("included", String.valueOf(included)); + } - if (filter != null) - { - options.queryParameters.put("filter", String.valueOf(filter)); - } + if (filter != null) { + options.queryParameters.put("filter", String.valueOf(filter)); + } - if (page != null) - { - options.queryParameters.put("page", String.valueOf(page)); - } + if (page != null) { + options.queryParameters.put("page", String.valueOf(page)); + } - if (results != null) - { - options.queryParameters.put("numResults", String.valueOf(results)); - } + if (results != null) { + options.queryParameters.put("numResults", String.valueOf(results)); + } - if (network != null) - { - options.queryParameters.put("network", String.valueOf(network)); - } + if (network != null) { + options.queryParameters.put("network", String.valueOf(network)); + } - return addFilterOptions(options); - } - } + return addFilterOptions(options); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/Event.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/Event.java index 5bb0791cc0..d83ac1396e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/Event.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/Event.java @@ -32,362 +32,290 @@ import com.abiquo.server.core.event.EventDto; /** * @author Vivien Mahé */ -public class Event extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Event(final RestContext context, - final EventDto target) - { - super(context, target); - } - - // Delegate methods - - public Integer getId() - { - return target.getId(); - } - - public String getUser() - { - return target.getUser(); - } - - public void setUser(final String user) - { - target.setUser(user); - } - - public String getStacktrace() - { - return target.getStacktrace(); - } - - public void setStacktrace(final String stacktrace) - { - target.setStacktrace(stacktrace); - } - - public String getComponent() - { - return target.getComponent(); - } - - public void setComponent(final String component) - { - target.setComponent(component); - } - - public String getPerformedBy() - { - return target.getPerformedBy(); - } - - public void setPerformedBy(final String performedBy) - { - target.setPerformedBy(performedBy); - } - - public Integer getIdNetwork() - { - return target.getIdNetwork(); - } - - public void setIdNetwork(final Integer idNetwork) - { - target.setIdNetwork(idNetwork); - } - - public String getIdVolume() - { - return target.getIdVolume(); - } - - public void setIdVolume(final String idVolume) - { - target.setIdVolume(idVolume); - } - - public String getStoragePool() - { - return target.getStoragePool(); - } - - public void setStoragePool(final String storagePool) - { - target.setStoragePool(storagePool); - } - - public Date getTimestamp() - { - return target.getTimestamp(); - } - - public void setTimestamp(final Date timestamp) - { - target.setTimestamp(timestamp); - } - - public String getVirtualApp() - { - return target.getVirtualApp(); - } - - public void setVirtualApp(final String virtualApp) - { - target.setVirtualApp(virtualApp); - } - - public String getDatacenter() - { - return target.getDatacenter(); - } - - public void setDatacenter(final String datacenter) - { - target.setDatacenter(datacenter); - } - - public String getActionPerformed() - { - return target.getActionPerformed(); - } - - public void setActionPerformed(final String actionPerformed) - { - target.setActionPerformed(actionPerformed); - } - - public Integer getIdVirtualMachine() - { - return target.getIdVirtualMachine(); - } - - public void setIdVirtualMachine(final Integer idVirtualMachine) - { - target.setIdVirtualMachine(idVirtualMachine); - } - - public String getVirtualDatacenter() - { - return target.getVirtualDatacenter(); - } - - public void setVirtualDatacenter(final String virtualDatacenter) - { - target.setVirtualDatacenter(virtualDatacenter); - } - - public String getEnterprise() - { - return target.getEnterprise(); - } - - public void setEnterprise(final String enterprise) - { - target.setEnterprise(enterprise); - } - - public String getStorageSystem() - { - return target.getStorageSystem(); - } - - public void setStorageSystem(final String storageSystem) - { - target.setStorageSystem(storageSystem); - } - - public Integer getIdPhysicalMachine() - { - return target.getIdPhysicalMachine(); - } - - public void setIdPhysicalMachine(final Integer idPhysicalMachine) - { - target.setIdPhysicalMachine(idPhysicalMachine); - } - - public SeverityType getSeverity() - { - return target.getSeverity(); - } - - public void setSeverity(final SeverityType severity) - { - target.setSeverity(severity); - } - - public Integer getIdStorageSystem() - { - return target.getIdStorageSystem(); - } - - public void setIdStorageSystem(final Integer idStorageSystem) - { - target.setIdStorageSystem(idStorageSystem); - } - - public Integer getIdDatacenter() - { - return target.getIdDatacenter(); - } - - public void setIdDatacenter(final Integer idDatacenter) - { - target.setIdDatacenter(idDatacenter); - } - - public String getNetwork() - { - return target.getNetwork(); - } - - public void setNetwork(final String network) - { - target.setNetwork(network); - } - - public String getPhysicalMachine() - { - return target.getPhysicalMachine(); - } - - public void setPhysicalMachine(final String physicalMachine) - { - target.setPhysicalMachine(physicalMachine); - } - - public String getRack() - { - return target.getRack(); - } - - public void setRack(final String rack) - { - target.setRack(rack); - } - - public Integer getIdVirtualDatacenter() - { - return target.getIdVirtualDatacenter(); - } - - public void setIdVirtualDatacenter(final Integer idVirtualDatacenter) - { - target.setIdVirtualDatacenter(idVirtualDatacenter); - } - - public Integer getIdSubnet() - { - return target.getIdSubnet(); - } - - public void setIdSubnet(final Integer idSubnet) - { - target.setIdSubnet(idSubnet); - } - - public String getVolume() - { - return target.getVolume(); - } - - public void setVolume(final String volume) - { - target.setVolume(volume); - } - - public String getSubnet() - { - return target.getSubnet(); - } - - public void setSubnet(final String subnet) - { - target.setSubnet(subnet); - } - - public Integer getIdUser() - { - return target.getIdUser(); - } - - public void setIdUser(final Integer idUser) - { - target.setIdUser(idUser); - } - - public String getIdStoragePool() - { - return target.getIdStoragePool(); - } - - public void setIdStoragePool(final String idStoragePool) - { - target.setIdStoragePool(idStoragePool); - } - - public Integer getIdRack() - { - return target.getIdRack(); - } - - public void setIdRack(final Integer idRack) - { - target.setIdRack(idRack); - } - - public String getVirtualMachine() - { - return target.getVirtualMachine(); - } - - public void setVirtualMachine(final String virtualMachine) - { - target.setVirtualMachine(virtualMachine); - } - - public Integer getIdVirtualApp() - { - return target.getIdVirtualApp(); - } - - public void setIdVirtualApp(final Integer idVirtualApp) - { - target.setIdVirtualApp(idVirtualApp); - } - - public Integer getIdEnterprise() - { - return target.getIdEnterprise(); - } - - public void setIdEnterprise(final Integer idEnterprise) - { - target.setIdEnterprise(idEnterprise); - } - - @Override - public String toString() - { - return "Event [id=" + getId() + ", idUser=" + getIdUser() + ", user=" + getUser() - + ", idEnterprise=" + getIdEnterprise() + ", enterprise=" + getEnterprise() - + ", actionPerformed=" + getActionPerformed() + ", component=" + getComponent() - + ", idDatacenter=" + getIdDatacenter() + ", datacenter=" + getDatacenter() - + ", idStoragePool=" + getIdStoragePool() + ", storagePool=" + getStoragePool() - + ", idVolume=" + getIdVolume() + ", volume=" + getVolume() + ", idNetwork=" - + getIdNetwork() + ", network=" + getNetwork() + ", idPhysicalMachine=" - + getIdPhysicalMachine() + ", physicalMachine=" + getPhysicalMachine() + ", idRack=" - + getIdRack() + ", rack=" + getRack() + ", idStorageSystem=" + getIdStorageSystem() - + ", storageSystem=" + getStorageSystem() + ", idSubnet=" + getIdSubnet() + ", subnet=" - + getSubnet() + ", idVirtualApp=" + getIdVirtualApp() + ", virtualApp=" - + getVirtualApp() + ", idVirtualDatacenter=" + getIdVirtualDatacenter() - + ", virtualDatacenter=" + getVirtualDatacenter() + ", idVirtualMachine=" - + getIdVirtualMachine() + ", virtualMachine=" + getVirtualMachine() + ", stackstrace=" - + getStacktrace() + ", performedBy=" + getPerformedBy() + ", severity=" + getSeverity() +public class Event extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Event(final RestContext context, final EventDto target) { + super(context, target); + } + + // Delegate methods + + public Integer getId() { + return target.getId(); + } + + public String getUser() { + return target.getUser(); + } + + public void setUser(final String user) { + target.setUser(user); + } + + public String getStacktrace() { + return target.getStacktrace(); + } + + public void setStacktrace(final String stacktrace) { + target.setStacktrace(stacktrace); + } + + public String getComponent() { + return target.getComponent(); + } + + public void setComponent(final String component) { + target.setComponent(component); + } + + public String getPerformedBy() { + return target.getPerformedBy(); + } + + public void setPerformedBy(final String performedBy) { + target.setPerformedBy(performedBy); + } + + public Integer getIdNetwork() { + return target.getIdNetwork(); + } + + public void setIdNetwork(final Integer idNetwork) { + target.setIdNetwork(idNetwork); + } + + public String getIdVolume() { + return target.getIdVolume(); + } + + public void setIdVolume(final String idVolume) { + target.setIdVolume(idVolume); + } + + public String getStoragePool() { + return target.getStoragePool(); + } + + public void setStoragePool(final String storagePool) { + target.setStoragePool(storagePool); + } + + public Date getTimestamp() { + return target.getTimestamp(); + } + + public void setTimestamp(final Date timestamp) { + target.setTimestamp(timestamp); + } + + public String getVirtualApp() { + return target.getVirtualApp(); + } + + public void setVirtualApp(final String virtualApp) { + target.setVirtualApp(virtualApp); + } + + public String getDatacenter() { + return target.getDatacenter(); + } + + public void setDatacenter(final String datacenter) { + target.setDatacenter(datacenter); + } + + public String getActionPerformed() { + return target.getActionPerformed(); + } + + public void setActionPerformed(final String actionPerformed) { + target.setActionPerformed(actionPerformed); + } + + public Integer getIdVirtualMachine() { + return target.getIdVirtualMachine(); + } + + public void setIdVirtualMachine(final Integer idVirtualMachine) { + target.setIdVirtualMachine(idVirtualMachine); + } + + public String getVirtualDatacenter() { + return target.getVirtualDatacenter(); + } + + public void setVirtualDatacenter(final String virtualDatacenter) { + target.setVirtualDatacenter(virtualDatacenter); + } + + public String getEnterprise() { + return target.getEnterprise(); + } + + public void setEnterprise(final String enterprise) { + target.setEnterprise(enterprise); + } + + public String getStorageSystem() { + return target.getStorageSystem(); + } + + public void setStorageSystem(final String storageSystem) { + target.setStorageSystem(storageSystem); + } + + public Integer getIdPhysicalMachine() { + return target.getIdPhysicalMachine(); + } + + public void setIdPhysicalMachine(final Integer idPhysicalMachine) { + target.setIdPhysicalMachine(idPhysicalMachine); + } + + public SeverityType getSeverity() { + return target.getSeverity(); + } + + public void setSeverity(final SeverityType severity) { + target.setSeverity(severity); + } + + public Integer getIdStorageSystem() { + return target.getIdStorageSystem(); + } + + public void setIdStorageSystem(final Integer idStorageSystem) { + target.setIdStorageSystem(idStorageSystem); + } + + public Integer getIdDatacenter() { + return target.getIdDatacenter(); + } + + public void setIdDatacenter(final Integer idDatacenter) { + target.setIdDatacenter(idDatacenter); + } + + public String getNetwork() { + return target.getNetwork(); + } + + public void setNetwork(final String network) { + target.setNetwork(network); + } + + public String getPhysicalMachine() { + return target.getPhysicalMachine(); + } + + public void setPhysicalMachine(final String physicalMachine) { + target.setPhysicalMachine(physicalMachine); + } + + public String getRack() { + return target.getRack(); + } + + public void setRack(final String rack) { + target.setRack(rack); + } + + public Integer getIdVirtualDatacenter() { + return target.getIdVirtualDatacenter(); + } + + public void setIdVirtualDatacenter(final Integer idVirtualDatacenter) { + target.setIdVirtualDatacenter(idVirtualDatacenter); + } + + public Integer getIdSubnet() { + return target.getIdSubnet(); + } + + public void setIdSubnet(final Integer idSubnet) { + target.setIdSubnet(idSubnet); + } + + public String getVolume() { + return target.getVolume(); + } + + public void setVolume(final String volume) { + target.setVolume(volume); + } + + public String getSubnet() { + return target.getSubnet(); + } + + public void setSubnet(final String subnet) { + target.setSubnet(subnet); + } + + public Integer getIdUser() { + return target.getIdUser(); + } + + public void setIdUser(final Integer idUser) { + target.setIdUser(idUser); + } + + public String getIdStoragePool() { + return target.getIdStoragePool(); + } + + public void setIdStoragePool(final String idStoragePool) { + target.setIdStoragePool(idStoragePool); + } + + public Integer getIdRack() { + return target.getIdRack(); + } + + public void setIdRack(final Integer idRack) { + target.setIdRack(idRack); + } + + public String getVirtualMachine() { + return target.getVirtualMachine(); + } + + public void setVirtualMachine(final String virtualMachine) { + target.setVirtualMachine(virtualMachine); + } + + public Integer getIdVirtualApp() { + return target.getIdVirtualApp(); + } + + public void setIdVirtualApp(final Integer idVirtualApp) { + target.setIdVirtualApp(idVirtualApp); + } + + public Integer getIdEnterprise() { + return target.getIdEnterprise(); + } + + public void setIdEnterprise(final Integer idEnterprise) { + target.setIdEnterprise(idEnterprise); + } + + @Override + public String toString() { + return "Event [id=" + getId() + ", idUser=" + getIdUser() + ", user=" + getUser() + ", idEnterprise=" + + getIdEnterprise() + ", enterprise=" + getEnterprise() + ", actionPerformed=" + getActionPerformed() + + ", component=" + getComponent() + ", idDatacenter=" + getIdDatacenter() + ", datacenter=" + + getDatacenter() + ", idStoragePool=" + getIdStoragePool() + ", storagePool=" + getStoragePool() + + ", idVolume=" + getIdVolume() + ", volume=" + getVolume() + ", idNetwork=" + getIdNetwork() + + ", network=" + getNetwork() + ", idPhysicalMachine=" + getIdPhysicalMachine() + ", physicalMachine=" + + getPhysicalMachine() + ", idRack=" + getIdRack() + ", rack=" + getRack() + ", idStorageSystem=" + + getIdStorageSystem() + ", storageSystem=" + getStorageSystem() + ", idSubnet=" + getIdSubnet() + + ", subnet=" + getSubnet() + ", idVirtualApp=" + getIdVirtualApp() + ", virtualApp=" + getVirtualApp() + + ", idVirtualDatacenter=" + getIdVirtualDatacenter() + ", virtualDatacenter=" + getVirtualDatacenter() + + ", idVirtualMachine=" + getIdVirtualMachine() + ", virtualMachine=" + getVirtualMachine() + + ", stackstrace=" + getStacktrace() + ", performedBy=" + getPerformedBy() + ", severity=" + getSeverity() + "]"; - } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/options/EventOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/options/EventOptions.java index 1a606d9ad1..5225f67199 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/options/EventOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/event/options/EventOptions.java @@ -36,161 +36,134 @@ import com.google.common.collect.Maps; * * @author Vivien Mahé */ -public class EventOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class EventOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - EventOptions options = new EventOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + EventOptions options = new EventOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder extends BaseFilterOptionsBuilder - { - private Map filters = Maps.newHashMap(); + public static class Builder extends BaseFilterOptionsBuilder { + private Map filters = Maps.newHashMap(); - public Builder filters(final Map filters) - { - this.filters = filters; - return this; - } + public Builder filters(final Map filters) { + this.filters = filters; + return this; + } - public Builder severity(final SeverityType severity) - { - this.filters.put("severity", severity.name()); - return this; - } + public Builder severity(final SeverityType severity) { + this.filters.put("severity", severity.name()); + return this; + } - public Builder component(final ComponentType component) - { - this.filters.put("component", component.name()); - return this; - } + public Builder component(final ComponentType component) { + this.filters.put("component", component.name()); + return this; + } - public Builder actionPerformed(final EventType action) - { - this.filters.put("actionperformed", action.name()); - return this; - } + public Builder actionPerformed(final EventType action) { + this.filters.put("actionperformed", action.name()); + return this; + } - public Builder datacenterName(final String dc) - { - this.filters.put("datacenter", dc); - return this; - } + public Builder datacenterName(final String dc) { + this.filters.put("datacenter", dc); + return this; + } - public Builder rackName(final String rack) - { - this.filters.put("rack", rack); - return this; - } + public Builder rackName(final String rack) { + this.filters.put("rack", rack); + return this; + } - public Builder physicalMachineName(final String pm) - { - this.filters.put("physicalmachine", pm); - return this; - } + public Builder physicalMachineName(final String pm) { + this.filters.put("physicalmachine", pm); + return this; + } - public Builder storageSystemName(final String ss) - { - this.filters.put("storagesystem", ss); - return this; - } + public Builder storageSystemName(final String ss) { + this.filters.put("storagesystem", ss); + return this; + } - public Builder storagePoolName(final String sp) - { - this.filters.put("storagepool", sp); - return this; - } + public Builder storagePoolName(final String sp) { + this.filters.put("storagepool", sp); + return this; + } - public Builder volumeName(final String volume) - { - this.filters.put("volume", volume); - return this; - } + public Builder volumeName(final String volume) { + this.filters.put("volume", volume); + return this; + } - public Builder networkName(final String network) - { - this.filters.put("network", network); - return this; - } + public Builder networkName(final String network) { + this.filters.put("network", network); + return this; + } - public Builder subnetName(final String subnet) - { - this.filters.put("subnet", subnet); - return this; - } + public Builder subnetName(final String subnet) { + this.filters.put("subnet", subnet); + return this; + } - public Builder enterpriseName(final String ent) - { - this.filters.put("enterprise", ent); - return this; - } + public Builder enterpriseName(final String ent) { + this.filters.put("enterprise", ent); + return this; + } - public Builder userName(final String user) - { - this.filters.put("user", user); - return this; - } + public Builder userName(final String user) { + this.filters.put("user", user); + return this; + } - public Builder virtualDatacenterName(final String vdc) - { - this.filters.put("virtualdatacenter", vdc); - return this; - } + public Builder virtualDatacenterName(final String vdc) { + this.filters.put("virtualdatacenter", vdc); + return this; + } - public Builder virtualAppName(final String vapp) - { - this.filters.put("virtualapp", vapp); - return this; - } + public Builder virtualAppName(final String vapp) { + this.filters.put("virtualapp", vapp); + return this; + } - public Builder virtualMachineName(final String vm) - { - this.filters.put("virtualMachine", vm); - return this; - } + public Builder virtualMachineName(final String vm) { + this.filters.put("virtualMachine", vm); + return this; + } - public Builder performedBy(final String pb) - { - this.filters.put("performedBy", pb); - return this; - } + public Builder performedBy(final String pb) { + this.filters.put("performedBy", pb); + return this; + } - public Builder description(final String description) - { - this.filters.put("stacktrace", description); - return this; - } + public Builder description(final String description) { + this.filters.put("stacktrace", description); + return this; + } - public Builder dateFrom(final Date date) - { - this.filters.put("datefrom", String.valueOf(date.getTime())); - return this; - } + public Builder dateFrom(final Date date) { + this.filters.put("datefrom", String.valueOf(date.getTime())); + return this; + } - public Builder dateTo(final Date date) - { - this.filters.put("dateTo", String.valueOf(date.getTime())); - return this; - } + public Builder dateTo(final Date date) { + this.filters.put("dateTo", String.valueOf(date.getTime())); + return this; + } - public EventOptions build() - { - EventOptions options = new EventOptions(); + public EventOptions build() { + EventOptions options = new EventOptions(); - for (Entry filter : filters.entrySet()) - { - options.queryParameters.put(filter.getKey(), filter.getValue()); - } + for (Entry filter : filters.entrySet()) { + options.queryParameters.put(filter.getKey(), filter.getValue()); + } - return addFilterOptions(options); - } - } + return addFilterOptions(options); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java index 1a8ddf58d9..e3b635c736 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/AbiquoException.java @@ -38,91 +38,80 @@ import com.google.common.collect.Lists; * @author Francesc Montserrat * @author Ignasi Barrera */ -public class AbiquoException extends RuntimeException -{ - /** Serial UID. */ - private static final long serialVersionUID = 1L; +public class AbiquoException extends RuntimeException { + /** Serial UID. */ + private static final long serialVersionUID = 1L; - /** The HTTP statuc. */ - private Status httpStatus; + /** The HTTP statuc. */ + private Status httpStatus; - /** The errors. */ - private ErrorsDto errors; + /** The errors. */ + private ErrorsDto errors; - public AbiquoException(final Status httpStatus, final ErrorsDto errors) - { - super(); - this.httpStatus = httpStatus; - this.errors = errors; - } + public AbiquoException(final Status httpStatus, final ErrorsDto errors) { + super(); + this.httpStatus = httpStatus; + this.errors = errors; + } - /** - * Check if there is an error with the given code. - */ - public boolean hasError(final String code) - { - return any(errors.getCollection(), code(code)); - } + /** + * Check if there is an error with the given code. + */ + public boolean hasError(final String code) { + return any(errors.getCollection(), code(code)); + } - /** - * Find the first error with the given code. - */ - public ErrorDto findError(final String code) - { - return find(errors.getCollection(), code(code), null); - } + /** + * Find the first error with the given code. + */ + public ErrorDto findError(final String code) { + return find(errors.getCollection(), code(code), null); + } - /** - * Find all errors with the given code. - */ - public List findErrors(final String code) - { - return Lists.newLinkedList(filter(errors.getCollection(), code(code))); - } + /** + * Find all errors with the given code. + */ + public List findErrors(final String code) { + return Lists.newLinkedList(filter(errors.getCollection(), code(code))); + } - /** - * Get the number of errors. - */ - public int numErrors() - { - return errors.getCollection().size(); - } + /** + * Get the number of errors. + */ + public int numErrors() { + return errors.getCollection().size(); + } - /** - * Get the list of all errors. - */ - public List getErrors() - { - return errors.getCollection(); - } + /** + * Get the list of all errors. + */ + public List getErrors() { + return errors.getCollection(); + } - /** - * Get the HTTP status code. - */ - public int getHttpStatusCode() - { - return httpStatus.getStatusCode(); - } + /** + * Get the HTTP status code. + */ + public int getHttpStatusCode() { + return httpStatus.getStatusCode(); + } - /** - * Get the HTTP status name. - */ - public String getHttpStatusName() - { - return httpStatus.getReasonPhrase(); - } + /** + * Get the HTTP status name. + */ + public String getHttpStatusName() { + return httpStatus.getReasonPhrase(); + } - /** - * Get the HTTP status. - */ - public Status getHttpStatus() - { - return httpStatus; - } + /** + * Get the HTTP status. + */ + public Status getHttpStatus() { + return httpStatus; + } - @Override - public String getMessage() - { - return errors.toString(); - } + @Override + public String getMessage() { + return errors.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/BuilderException.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/BuilderException.java index 850bb21b77..3fea01a0d3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/BuilderException.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/BuilderException.java @@ -24,38 +24,38 @@ package org.jclouds.abiquo.domain.exception; * * @author Ignasi Barrera */ -public class BuilderException extends RuntimeException -{ - private static final long serialVersionUID = 1L; +public class BuilderException extends RuntimeException { + private static final long serialVersionUID = 1L; - /** - * Creates a {@link BuilderException} with the given message. - * - * @param message The message. - */ - public BuilderException(String message) - { - super(message); - } + /** + * Creates a {@link BuilderException} with the given message. + * + * @param message + * The message. + */ + public BuilderException(String message) { + super(message); + } - /** - * Creates a {@link BuilderException} with the given cause. - * - * @param cause The cause. - */ - public BuilderException(Throwable cause) - { - super(cause); - } + /** + * Creates a {@link BuilderException} with the given cause. + * + * @param cause + * The cause. + */ + public BuilderException(Throwable cause) { + super(cause); + } - /** - * Creates a {@link BuilderException} with the given message and cause. - * - * @param message The message. - * @param cause The cause. - */ - public BuilderException(String message, Throwable cause) - { - super(message, cause); - } + /** + * Creates a {@link BuilderException} with the given message and cause. + * + * @param message + * The message. + * @param cause + * The cause. + */ + public BuilderException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/WrapperException.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/WrapperException.java index 40f9e8e0ad..911db94e8b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/WrapperException.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/exception/WrapperException.java @@ -28,48 +28,40 @@ import com.abiquo.model.transport.SingleResourceTransportDto; * * @author Ignasi Barrera */ -public class WrapperException extends RuntimeException -{ - private static final long serialVersionUID = 1L; +public class WrapperException extends RuntimeException { + private static final long serialVersionUID = 1L; - private Class< ? extends DomainWrapper< ? >> wrapperClass; + private Class> wrapperClass; - private SingleResourceTransportDto target; + private SingleResourceTransportDto target; - public WrapperException(final Class< ? extends DomainWrapper< ? >> wrapperClass, - final SingleResourceTransportDto target, Throwable cause) - { - super(cause); - this.wrapperClass = wrapperClass; - this.target = target; - } + public WrapperException(final Class> wrapperClass, + final SingleResourceTransportDto target, Throwable cause) { + super(cause); + this.wrapperClass = wrapperClass; + this.target = target; + } - @Override - public String getMessage() - { - String msg = - "Could not wrap object [" + target + "] in class " + wrapperClass.getName() + ": "; - return msg + super.getMessage(); - } + @Override + public String getMessage() { + String msg = "Could not wrap object [" + target + "] in class " + wrapperClass.getName() + ": "; + return msg + super.getMessage(); + } - public Class< ? extends DomainWrapper< ? >> getWrapperClass() - { - return wrapperClass; - } + public Class> getWrapperClass() { + return wrapperClass; + } - public void setWrapperClass(Class< ? extends DomainWrapper< ? >> wrapperClass) - { - this.wrapperClass = wrapperClass; - } + public void setWrapperClass(Class> wrapperClass) { + this.wrapperClass = wrapperClass; + } - public SingleResourceTransportDto getTarget() - { - return target; - } + public SingleResourceTransportDto getTarget() { + return target; + } - public void setTarget(SingleResourceTransportDto target) - { - this.target = target; - } + public void setTarget(SingleResourceTransportDto target) { + this.target = target; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java index 6ec6c47ce6..ecfcd49c70 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/AbstractPhysicalMachine.java @@ -41,316 +41,261 @@ import com.google.common.base.Predicates; import com.google.common.collect.Lists; /** - * Adds high level functionality to {@link MachineDto}. This class defines common methods for - * unmanaged {@link Machine} and managed {@link Blade} physical machines. + * Adds high level functionality to {@link MachineDto}. This class defines + * common methods for unmanaged {@link Machine} and managed {@link Blade} + * physical machines. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/MachineResource */ -public abstract class AbstractPhysicalMachine extends DomainWrapper -{ - /** The default virtual ram used in MB. */ - protected static final int DEFAULT_VRAM_USED = 1; +public abstract class AbstractPhysicalMachine extends DomainWrapper { + /** The default virtual ram used in MB. */ + protected static final int DEFAULT_VRAM_USED = 1; - /** The default virtual cpu used in MB. */ - protected static final int DEFAULT_VCPU_USED = 1; + /** The default virtual cpu used in MB. */ + protected static final int DEFAULT_VCPU_USED = 1; - /** List of available virtual switches provided by discover operation **/ - protected List virtualSwitches; + /** List of available virtual switches provided by discover operation **/ + protected List virtualSwitches; - /** - * Constructor to be used only by the builder. - */ - protected AbstractPhysicalMachine(final RestContext context, - final MachineDto target) - { - super(context, target); - extractVirtualSwitches(); - } + /** + * Constructor to be used only by the builder. + */ + protected AbstractPhysicalMachine(final RestContext context, final MachineDto target) { + super(context, target); + extractVirtualSwitches(); + } - public void delete() - { - context.getApi().getInfrastructureApi().deleteMachine(target); - target = null; - } + public void delete() { + context.getApi().getInfrastructureApi().deleteMachine(target); + target = null; + } - public void update() - { - target = context.getApi().getInfrastructureApi().updateMachine(target); - } + public void update() { + target = context.getApi().getInfrastructureApi().updateMachine(target); + } - public MachineState check() - { - MachineStateDto dto = - context.getApi().getInfrastructureApi().checkMachineState(target, true); - MachineState state = dto.getState(); - target.setState(state); - return state; - } + public MachineState check() { + MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true); + MachineState state = dto.getState(); + target.setState(state); + return state; + } - public MachineIpmiState checkIpmi() - { - MachineIpmiStateDto dto = - context.getApi().getInfrastructureApi().checkMachineIpmiState(target); - return dto.getState(); - } + public MachineIpmiState checkIpmi() { + MachineIpmiStateDto dto = context.getApi().getInfrastructureApi().checkMachineIpmiState(target); + return dto.getState(); + } - // Children access + // Children access - public List getDatastores() - { - return wrap(context, Datastore.class, target.getDatastores().getCollection()); - } + public List getDatastores() { + return wrap(context, Datastore.class, target.getDatastores().getCollection()); + } - public Datastore findDatastore(final String name) - { - return find(getDatastores(), DatastorePredicates.name(name), null); - } + public Datastore findDatastore(final String name) { + return find(getDatastores(), DatastorePredicates.name(name), null); + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getIp() - { - return target.getIp(); - } + public String getIp() { + return target.getIp(); + } - public String getIpmiIp() - { - return target.getIpmiIP(); - } + public String getIpmiIp() { + return target.getIpmiIP(); + } - public String getIpmiPassword() - { - return target.getIpmiPassword(); - } + public String getIpmiPassword() { + return target.getIpmiPassword(); + } - public Integer getIpmiPort() - { - return target.getIpmiPort(); - } + public Integer getIpmiPort() { + return target.getIpmiPort(); + } - public String getIpmiUser() - { - return target.getIpmiUser(); - } + public String getIpmiUser() { + return target.getIpmiUser(); + } - public String getIpService() - { - return target.getIpService(); - } + public String getIpService() { + return target.getIpService(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getPassword() - { - return target.getPassword(); - } + public String getPassword() { + return target.getPassword(); + } - public Integer getPort() - { - return target.getPort(); - } + public Integer getPort() { + return target.getPort(); + } - public MachineState getState() - { - return target.getState(); - } + public MachineState getState() { + return target.getState(); + } - public HypervisorType getType() - { - return target.getType(); - } + public HypervisorType getType() { + return target.getType(); + } - public String getUser() - { - return target.getUser(); - } + public String getUser() { + return target.getUser(); + } - public Integer getVirtualCpuCores() - { - return target.getVirtualCpuCores(); - } + public Integer getVirtualCpuCores() { + return target.getVirtualCpuCores(); + } - public Integer getVirtualCpusUsed() - { - return target.getVirtualCpusUsed(); - } + public Integer getVirtualCpusUsed() { + return target.getVirtualCpusUsed(); + } - public Integer getVirtualRamInMb() - { - return target.getVirtualRamInMb(); - } + public Integer getVirtualRamInMb() { + return target.getVirtualRamInMb(); + } - public Integer getVirtualRamUsedInMb() - { - return target.getVirtualRamUsedInMb(); - } + public Integer getVirtualRamUsedInMb() { + return target.getVirtualRamUsedInMb(); + } - public String getVirtualSwitch() - { - return target.getVirtualSwitch(); - } + public String getVirtualSwitch() { + return target.getVirtualSwitch(); + } - public void setDatastores(final List datastores) - { - DatastoresDto datastoresDto = new DatastoresDto(); - datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores)); - target.setDatastores(datastoresDto); - } + public void setDatastores(final List datastores) { + DatastoresDto datastoresDto = new DatastoresDto(); + datastoresDto.getCollection().addAll(DomainWrapper.unwrap(datastores)); + target.setDatastores(datastoresDto); + } - public void setDescription(final String description) - { - target.setDescription(description); - } + public void setDescription(final String description) { + target.setDescription(description); + } - public void setIp(final String ip) - { - target.setIp(ip); - } + public void setIp(final String ip) { + target.setIp(ip); + } - public void setIpmiIp(final String ipmiIp) - { - target.setIpmiIP(ipmiIp); - } + public void setIpmiIp(final String ipmiIp) { + target.setIpmiIP(ipmiIp); + } - public void setIpmiPassword(final String ipmiPassword) - { - target.setIpmiPassword(ipmiPassword); - } + public void setIpmiPassword(final String ipmiPassword) { + target.setIpmiPassword(ipmiPassword); + } - public void setIpmiPort(final Integer ipmiPort) - { - target.setIpmiPort(ipmiPort); - } + public void setIpmiPort(final Integer ipmiPort) { + target.setIpmiPort(ipmiPort); + } - public void setIpmiUser(final String ipmiUser) - { - target.setIpmiUser(ipmiUser); - } + public void setIpmiUser(final String ipmiUser) { + target.setIpmiUser(ipmiUser); + } - public void setIpService(final String ipService) - { - target.setIpService(ipService); - } + public void setIpService(final String ipService) { + target.setIpService(ipService); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setPassword(final String password) - { - target.setPassword(password); - } + public void setPassword(final String password) { + target.setPassword(password); + } - public void setPort(final Integer port) - { - target.setPort(port); - } + public void setPort(final Integer port) { + target.setPort(port); + } - public void setState(final MachineState state) - { - target.setState(state); - } + public void setState(final MachineState state) { + target.setState(state); + } - public void setType(final HypervisorType type) - { - target.setType(type); - } + public void setType(final HypervisorType type) { + target.setType(type); + } - public void setUser(final String user) - { - target.setUser(user); - } + public void setUser(final String user) { + target.setUser(user); + } - public void setVirtualCpuCores(final Integer virtualCpuCores) - { - target.setVirtualCpuCores(virtualCpuCores); - } + public void setVirtualCpuCores(final Integer virtualCpuCores) { + target.setVirtualCpuCores(virtualCpuCores); + } - public void setVirtualCpusUsed(final Integer virtualCpusUsed) - { - target.setVirtualCpusUsed(virtualCpusUsed); - } + public void setVirtualCpusUsed(final Integer virtualCpusUsed) { + target.setVirtualCpusUsed(virtualCpusUsed); + } - public void setVirtualRamInMb(final Integer virtualRamInMb) - { - target.setVirtualRamInMb(virtualRamInMb); - } + public void setVirtualRamInMb(final Integer virtualRamInMb) { + target.setVirtualRamInMb(virtualRamInMb); + } - public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) - { - target.setVirtualRamUsedInMb(virtualRamUsedInMb); - } + public void setVirtualRamUsedInMb(final Integer virtualRamUsedInMb) { + target.setVirtualRamUsedInMb(virtualRamUsedInMb); + } - public void setVirtualSwitch(final String virtualSwitch) - { - target.setVirtualSwitch(virtualSwitch); - } + public void setVirtualSwitch(final String virtualSwitch) { + target.setVirtualSwitch(virtualSwitch); + } - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - // Aux operations + // Aux operations - /** - * Converts the tokenized String provided by the node collector API to a list of Strings and - * stores it at the attribute switches. - */ - protected void extractVirtualSwitches() - { - StringTokenizer st = new StringTokenizer(getVirtualSwitch(), "/"); - this.virtualSwitches = Lists.newArrayList(); + /** + * Converts the tokenized String provided by the node collector API to a list + * of Strings and stores it at the attribute switches. + */ + protected void extractVirtualSwitches() { + StringTokenizer st = new StringTokenizer(getVirtualSwitch(), "/"); + this.virtualSwitches = Lists.newArrayList(); - while (st.hasMoreTokens()) - { - this.virtualSwitches.add(st.nextToken()); - } + while (st.hasMoreTokens()) { + this.virtualSwitches.add(st.nextToken()); + } - if (virtualSwitches.size() > 0) - { - this.setVirtualSwitch(virtualSwitches.get(0)); - } - } + if (virtualSwitches.size() > 0) { + this.setVirtualSwitch(virtualSwitches.get(0)); + } + } - /** - * Returns the virtual switches available. One of them needs to be selected. - */ - public List getAvailableVirtualSwitches() - { - return virtualSwitches; - } + /** + * Returns the virtual switches available. One of them needs to be selected. + */ + public List getAvailableVirtualSwitches() { + return virtualSwitches; + } - public String findAvailableVirtualSwitch(final String vswitch) - { - return find(virtualSwitches, Predicates.equalTo(vswitch)); - } + public String findAvailableVirtualSwitch(final String vswitch) { + return find(virtualSwitches, Predicates.equalTo(vswitch)); + } - @Override - public String toString() - { - return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp() - + ", ipmiPassword=" + getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser=" - + getIpmiUser() + ", ipService=" + getIpService() + ", name=" + getName() - + ", password=" + getPassword() + ", port=" + getPort() + ", state=" + getState() - + ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores=" - + getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed() - + ", getVirtualRamInMb()=" + getVirtualRamInMb() + ", virtualRamUsedInMb=" - + getVirtualRamUsedInMb() + ", virtualSwitch=" + getVirtualSwitch() + ", description=" - + getDescription() + ", availableVirtualSwitches=" + getAvailableVirtualSwitches() - + "]"; - } + @Override + public String toString() { + return "Machine [id=" + getId() + ", ip=" + getIp() + ", ipmiIp=" + getIpmiIp() + ", ipmiPassword=" + + getIpmiPassword() + ", ipmiPort=" + getIpmiPort() + ", ipmiUser=" + getIpmiUser() + ", ipService=" + + getIpService() + ", name=" + getName() + ", password=" + getPassword() + ", port=" + getPort() + + ", state=" + getState() + ", type=" + getType() + ", user=" + getUser() + ", virtualCpuCores=" + + getVirtualCpuCores() + ", virtualCpusUsed=" + getVirtualCpusUsed() + ", getVirtualRamInMb()=" + + getVirtualRamInMb() + ", virtualRamUsedInMb=" + getVirtualRamUsedInMb() + ", virtualSwitch=" + + getVirtualSwitch() + ", description=" + getDescription() + ", availableVirtualSwitches=" + + getAvailableVirtualSwitches() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java index db2ca35b64..b45a0bb926 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Blade.java @@ -38,139 +38,136 @@ import com.abiquo.server.core.infrastructure.UcsRackDto; import com.google.inject.TypeLiteral; /** - * Adds high level functionality to a {@link MachineDto} managed in a UCS rack. This resource allows - * you to access blades in managed racks in the cloud infrastructure. + * Adds high level functionality to a {@link MachineDto} managed in a UCS rack. + * This resource allows you to access blades in managed racks in the cloud + * infrastructure. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/MachineResource */ -public class Blade extends AbstractPhysicalMachine -{ - /** The rack where the machine belongs. */ - protected UcsRackDto rack; +public class Blade extends AbstractPhysicalMachine { + /** The rack where the machine belongs. */ + protected UcsRackDto rack; - /** - * Constructor to be used only by the builder. - */ - protected Blade(final RestContext context, final MachineDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Blade(final RestContext context, final MachineDto target) { + super(context, target); + } - // Parent access + // Parent access - /** - * Retrieve the UCS rack where the blade is. - * - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack - */ - public ManagedRack getRack() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.RACK), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.RACK); + /** + * Retrieve the UCS rack where the blade is. + * + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveaUCSRack + */ + public ManagedRack getRack() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.RACK), ValidationErrors.MISSING_REQUIRED_LINK + " " + + ParentLinkName.RACK); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(UcsRackDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(UcsRackDto.class)); - return wrap(context, ManagedRack.class, parser.apply(response)); - } + return wrap(context, ManagedRack.class, parser.apply(response)); + } - /** - * Retrieve the logic server associated with this machine in the Cisco UCS rack. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrieveslogicserverassociatedwithamachineinaCiscoUCS - */ - public LogicServer getLogicServer() - { - LogicServerDto server = context.getApi().getInfrastructureApi().getLogicServer(target); + /** + * Retrieve the logic server associated with this machine in the Cisco UCS + * rack. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- + * RetrieveslogicserverassociatedwithamachineinaCiscoUCS + */ + public LogicServer getLogicServer() { + LogicServerDto server = context.getApi().getInfrastructureApi().getLogicServer(target); - return wrap(context, LogicServer.class, server); - } + return wrap(context, LogicServer.class, server); + } - // Actions + // Actions - /** - * Turn the blade associated to the provided logic server off. The blade must belong to a Logic - * Server. This action sets the state of a given machine to STOPPED. Also sends a stop request - * to Cisco UCS to shut down the machine. The given machine must be a Physical Machine inside a - * Cisco UCS. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * PoweroffanexistingmachineinCiscoUCS - */ - public void powerOff() - { - context.getApi().getInfrastructureApi().powerOff(target); - } + /** + * Turn the blade associated to the provided logic server off. The blade must + * belong to a Logic Server. This action sets the state of a given machine to + * STOPPED. Also sends a stop request to Cisco UCS to shut down the machine. + * The given machine must be a Physical Machine inside a Cisco UCS. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- PoweroffanexistingmachineinCiscoUCS + */ + public void powerOff() { + context.getApi().getInfrastructureApi().powerOff(target); + } - /** - * Turn the blade associated to the provided logic server on. The machine must belong to an UCS - * Rack. The blade must belong to a Logic Server. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * PoweronanexistingmachineinCiscoUCS - */ - public void powerOn() - { - context.getApi().getInfrastructureApi().powerOn(target); - } + /** + * Turn the blade associated to the provided logic server on. The machine + * must belong to an UCS Rack. The blade must belong to a Logic Server. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- PoweronanexistingmachineinCiscoUCS + */ + public void powerOn() { + context.getApi().getInfrastructureApi().powerOn(target); + } - /** - * Turn blade led on. The machine must belong to an UCS Rack. The blade must belong to a Logic - * Server. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * LightoffthelocatorledofanexistingmachineinaCiscoUCS - */ - public void ledOn() - { - context.getApi().getInfrastructureApi().ledOn(target); - } + /** + * Turn blade led on. The machine must belong to an UCS Rack. The blade must + * belong to a Logic Server. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- + * LightoffthelocatorledofanexistingmachineinaCiscoUCS + */ + public void ledOn() { + context.getApi().getInfrastructureApi().ledOn(target); + } - /** - * Turn blade led off. The machine must belong to an UCS Rack. The blade must belong to a Logic - * Server. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource- - * LightoffthelocatorledofanexistingmachineinaCiscoUCS - */ - public void ledOff() - { - context.getApi().getInfrastructureApi().ledOff(target); - } + /** + * Turn blade led off. The machine must belong to an UCS Rack. The blade must + * belong to a Logic Server. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource- + * LightoffthelocatorledofanexistingmachineinaCiscoUCS + */ + public void ledOff() { + context.getApi().getInfrastructureApi().ledOff(target); + } - /** - * Retrieve the led locator information as a {@link BladeLocatorLed}. - * - * @return Blade locator led representation. - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * Retrievethelocatorledoftheblade - */ - public BladeLocatorLed getLocatorLed() - { - BladeLocatorLedDto led = context.getApi().getInfrastructureApi().getLocatorLed(target); + /** + * Retrieve the led locator information as a {@link BladeLocatorLed}. + * + * @return Blade locator led representation. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- Retrievethelocatorledoftheblade + */ + public BladeLocatorLed getLocatorLed() { + BladeLocatorLedDto led = context.getApi().getInfrastructureApi().getLocatorLed(target); - return wrap(context, BladeLocatorLed.class, led); - } + return wrap(context, BladeLocatorLed.class, led); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java index cd74bd64e6..65d8f7a371 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/BladeLocatorLed.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.infrastructure; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -35,47 +34,40 @@ import com.abiquo.server.core.infrastructure.BladeLocatorLedDto; * @author Francesc Montserrat * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * Retrievethelocatorledoftheblade + * > http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- Retrievethelocatorledoftheblade */ @EnterpriseEdition -public class BladeLocatorLed extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected BladeLocatorLed(final RestContext context, final BladeLocatorLedDto target) - { - super(context, target); - } +public class BladeLocatorLed extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected BladeLocatorLed(final RestContext context, final BladeLocatorLedDto target) { + super(context, target); + } - // Delegate Methods + // Delegate Methods - public String getAdminStatus() - { - return target.getAdminStatus(); - } + public String getAdminStatus() { + return target.getAdminStatus(); + } - public String getBladeDn() - { - return target.getBladeDn(); - } + public String getBladeDn() { + return target.getBladeDn(); + } - public String getColor() - { - return target.getColor(); - } + public String getColor() { + return target.getColor(); + } - public String getDn() - { - return target.getDn(); - } + public String getDn() { + return target.getDn(); + } - @Override - public String toString() - { - return "BladeLocatorLed [Dn=" + getDn() + ", BladeDn=" + getBladeDn() + ", Color=" - + getColor() + ", AdminStatus=" + getAdminStatus() + "]"; - } + @Override + public String toString() { + return "BladeLocatorLed [Dn=" + getDn() + ", BladeDn=" + getBladeDn() + ", Color=" + getColor() + + ", AdminStatus=" + getAdminStatus() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java index 80ef2e8af8..4d3bc6d427 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datacenter.java @@ -75,1100 +75,1130 @@ import com.google.common.collect.Lists; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/DatacenterResource */ -public class Datacenter extends DomainWrapper -{ - /** - * IP address of the datacenter (used to create all remote services with the same ip). - */ - private String ip; +public class Datacenter extends DomainWrapper { + /** + * IP address of the datacenter (used to create all remote services with the + * same ip). + */ + private String ip; - /** - * Indicates the Abiquo edition to create the available remote services. - * - * @see API: - * http://community.abiquo.com/display/ABI20/Introduction+-+The+Abiquo+Platform - */ - private AbiquoEdition edition; + /** + * Indicates the Abiquo edition to create the available remote services. + * + * @see API: + * http://community.abiquo.com/display/ABI20/Introduction+-+The+Abiquo+ + * Platform + */ + private AbiquoEdition edition; - /** - * Constructor to be used only by the builder. - */ - protected Datacenter(final RestContext context, - final DatacenterDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Datacenter(final RestContext context, final DatacenterDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * DeleteanexistingDatacenter - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteDatacenter(target); - target = null; - } + /** + * Delete the datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- DeleteanexistingDatacenter + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteDatacenter(target); + target = null; + } - /** - * Create a datacenter in Abiquo. This method will perform several calls to the API if remote - * services have been defined in the builder. Different remote services will be created - * depending on the {@link AbiquoEdition}. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * CreateanewDatacenter - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * CreateaRemoteService - */ - public void save() - { - // Datacenter must be persisted first, so links get populated in the target object - target = context.getApi().getInfrastructureApi().createDatacenter(target); + /** + * Create a datacenter in Abiquo. This method will perform several calls to + * the API if remote services have been defined in the builder. Different + * remote services will be created depending on the {@link AbiquoEdition}. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- CreateanewDatacenter + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- CreateaRemoteService + */ + public void save() { + // Datacenter must be persisted first, so links get populated in the + // target object + target = context.getApi().getInfrastructureApi().createDatacenter(target); - // If remote services data is set, create remote services. - if (ip != null && edition != null) - { - createRemoteServices(); - } - } + // If remote services data is set, create remote services. + if (ip != null && edition != null) { + createRemoteServices(); + } + } - /** - * Update datacenter information in the server with the data from this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Updateanexistingdatacenter - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateDatacenter(target); - } + /** + * Update datacenter information in the server with the data from this + * datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Updateanexistingdatacenter + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateDatacenter(target); + } - /** - * The cloud administrator will find it useful to know if a VLAN Tag is already assigned before - * creating a new Public or External Network. This method provides this functionality: Check if - * a tag is available inside the Datacenter. Please refer link for more information. - * - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Checkthetagavailability - * @return Availability state of the tag. - */ - public VlanTagAvailabilityType checkTagAvailability(final int tag) - { - VlanTagAvailabilityDto availability = - context.getApi().getInfrastructureApi().checkTagAvailability(target, tag); + /** + * The cloud administrator will find it useful to know if a VLAN Tag is + * already assigned before creating a new Public or External Network. This + * method provides this functionality: Check if a tag is available inside the + * Datacenter. Please refer link for more information. + * + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Checkthetagavailability + * @return Availability state of the tag. + */ + public VlanTagAvailabilityType checkTagAvailability(final int tag) { + VlanTagAvailabilityDto availability = context.getApi().getInfrastructureApi().checkTagAvailability(target, tag); - return availability.getAvailable(); - } + return availability.getAvailable(); + } - // Children access + // Children access - /** - * Retrieve the list of unmanaged racks in this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofRacks - * @return List of unmanaged racks in this datacenter. - */ - public List listRacks() - { - RacksDto racks = context.getApi().getInfrastructureApi().listRacks(target); - return wrap(context, Rack.class, racks.getCollection()); - } + /** + * Retrieve the list of unmanaged racks in this datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofRacks + * @return List of unmanaged racks in this datacenter. + */ + public List listRacks() { + RacksDto racks = context.getApi().getInfrastructureApi().listRacks(target); + return wrap(context, Rack.class, racks.getCollection()); + } - /** - * Retrieve a filtered list of unmanaged racks in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofRacks - * @return Filtered list of unmanaged racks in this datacenter. - */ - public List listRacks(final Predicate filter) - { - return Lists.newLinkedList(filter(listRacks(), filter)); - } + /** + * Retrieve a filtered list of unmanaged racks in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofRacks + * @return Filtered list of unmanaged racks in this datacenter. + */ + public List listRacks(final Predicate filter) { + return Lists.newLinkedList(filter(listRacks(), filter)); + } - /** - * Retrieve the first unmanaged rack matching the filter within the list of racks in this - * datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofRacks - * @return First unmanaged rack matching the filter or null if the is none. - */ - public Rack findRack(final Predicate filter) - { - return Iterables.getFirst(filter(listRacks(), filter), null); - } + /** + * Retrieve the first unmanaged rack matching the filter within the list of + * racks in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofRacks + * @return First unmanaged rack matching the filter or null if + * the is none. + */ + public Rack findRack(final Predicate filter) { + return Iterables.getFirst(filter(listRacks(), filter), null); + } - /** - * Retrieve a single unmanaged rack. - * - * @param id Unique ID of the rack in this datacenter. - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaRack - * @return Unmanaged rack with the given id or null if it does not exist. - */ - public Rack getRack(final Integer id) - { - RackDto rack = context.getApi().getInfrastructureApi().getRack(target, id); - return wrap(context, Rack.class, rack); - } + /** + * Retrieve a single unmanaged rack. + * + * @param id + * Unique ID of the rack in this datacenter. + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveaRack + * @return Unmanaged rack with the given id or null if it does + * not exist. + */ + public Rack getRack(final Integer id) { + RackDto rack = context.getApi().getInfrastructureApi().getRack(target, id); + return wrap(context, Rack.class, rack); + } - /** - * Retrieve the list of managed racks in this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofUCSracks - * @return List of managed racks in this datacenter. - */ - @EnterpriseEdition - public List listManagedRacks() - { - UcsRacksDto racks = context.getApi().getInfrastructureApi().listManagedRacks(target); - return wrap(context, ManagedRack.class, racks.getCollection()); - } + /** + * Retrieve the list of managed racks in this datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofUCSracks + * @return List of managed racks in this datacenter. + */ + @EnterpriseEdition + public List listManagedRacks() { + UcsRacksDto racks = context.getApi().getInfrastructureApi().listManagedRacks(target); + return wrap(context, ManagedRack.class, racks.getCollection()); + } - /** - * Retrieve a filtered list of managed racks in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofUCSracks - * @return Filtered list of managed racks in this datacenter. - */ - @EnterpriseEdition - public List listManagedRacks(final Predicate filter) - { - return Lists.newLinkedList(filter(listManagedRacks(), filter)); - } + /** + * Retrieve a filtered list of managed racks in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofUCSracks + * @return Filtered list of managed racks in this datacenter. + */ + @EnterpriseEdition + public List listManagedRacks(final Predicate filter) { + return Lists.newLinkedList(filter(listManagedRacks(), filter)); + } - /** - * Retrieve the first managed rack matching the filter within the list of racks in this - * datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofUCSracks - * @return First managed rack matching the filter or null if there is none. - */ - @EnterpriseEdition - public ManagedRack findManagedRack(final Predicate filter) - { - return Iterables.getFirst(filter(listManagedRacks(), filter), null); - } + /** + * Retrieve the first managed rack matching the filter within the list of + * racks in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofUCSracks + * @return First managed rack matching the filter or null if + * there is none. + */ + @EnterpriseEdition + public ManagedRack findManagedRack(final Predicate filter) { + return Iterables.getFirst(filter(listManagedRacks(), filter), null); + } - /** - * Retrieve a single managed rack. - * - * @param id Unique ID of the rack in this datacenter. - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaUCSRack - * @return Unmanaged rack with the given id or null if it does not exist. - */ - @EnterpriseEdition - public ManagedRack getManagedRack(final Integer id) - { - UcsRackDto rack = context.getApi().getInfrastructureApi().getManagedRack(target, id); - return wrap(context, ManagedRack.class, rack); - } + /** + * Retrieve a single managed rack. + * + * @param id + * Unique ID of the rack in this datacenter. + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveaUCSRack + * @return Unmanaged rack with the given id or null if it does + * not exist. + */ + @EnterpriseEdition + public ManagedRack getManagedRack(final Integer id) { + UcsRackDto rack = context.getApi().getInfrastructureApi().getManagedRack(target, id); + return wrap(context, ManagedRack.class, rack); + } - /** - * Retrieve the list of supported storage devices. - *

- * This method will get the list of the storage devices that are supported in the datacenter. - * - * @return List of supported storage devices. This list has only the default information for the - * storage devices, such as the management and iscsi ports, or the default credentials - * to access the device. - */ - @EnterpriseEdition - public List listSupportedStorageDevices() - { - StorageDevicesMetadataDto devices = - context.getApi().getInfrastructureApi().listSupportedStorageDevices(target); - return wrap(context, StorageDeviceMetadata.class, devices.getCollection()); - } + /** + * Retrieve the list of supported storage devices. + *

+ * This method will get the list of the storage devices that are supported in + * the datacenter. + * + * @return List of supported storage devices. This list has only the default + * information for the storage devices, such as the management and + * iscsi ports, or the default credentials to access the device. + */ + @EnterpriseEdition + public List listSupportedStorageDevices() { + StorageDevicesMetadataDto devices = context.getApi().getInfrastructureApi().listSupportedStorageDevices(target); + return wrap(context, StorageDeviceMetadata.class, devices.getCollection()); + } - /** - * Retrieve the list of supported storage devices matching the filter. - *

- * This method will get the list of the storage devices that are supported in the datacenter. - * - * @param filter Filter to be applied to the list. - * @return List of supported storage devices. This list has only the default information for the - * storage devices, such as the management and iscsi ports, or the default credentials - * to access the device. - */ - @EnterpriseEdition - public List listSupportedStorageDevices( - final Predicate filter) - { - return Lists.newLinkedList(filter(listSupportedStorageDevices(), filter)); - } + /** + * Retrieve the list of supported storage devices matching the filter. + *

+ * This method will get the list of the storage devices that are supported in + * the datacenter. + * + * @param filter + * Filter to be applied to the list. + * @return List of supported storage devices. This list has only the default + * information for the storage devices, such as the management and + * iscsi ports, or the default credentials to access the device. + */ + @EnterpriseEdition + public List listSupportedStorageDevices(final Predicate filter) { + return Lists.newLinkedList(filter(listSupportedStorageDevices(), filter)); + } - /** - * Retrieve a single supported storage devices matching the filter. - * - * @param filter Filter to be applied to the list. - * @return First supported storage device matching the filter or null if there is - * none. - */ - @EnterpriseEdition - public StorageDeviceMetadata findSupportedStorageDevice( - final Predicate filter) - { - return Iterables.getFirst(filter(listSupportedStorageDevices(), filter), null); - } + /** + * Retrieve a single supported storage devices matching the filter. + * + * @param filter + * Filter to be applied to the list. + * @return First supported storage device matching the filter or + * null if there is none. + */ + @EnterpriseEdition + public StorageDeviceMetadata findSupportedStorageDevice(final Predicate filter) { + return Iterables.getFirst(filter(listSupportedStorageDevices(), filter), null); + } - /** - * Retrieve the list of storage devices in this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrievethelistofstoragedevices - * @return List of storage devices in this datacenter. - */ - @EnterpriseEdition - public List listStorageDevices() - { - StorageDevicesDto devices = - context.getApi().getInfrastructureApi().listStorageDevices(target); - return wrap(context, StorageDevice.class, devices.getCollection()); - } + /** + * Retrieve the list of storage devices in this datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrievethelistofstoragedevices + * @return List of storage devices in this datacenter. + */ + @EnterpriseEdition + public List listStorageDevices() { + StorageDevicesDto devices = context.getApi().getInfrastructureApi().listStorageDevices(target); + return wrap(context, StorageDevice.class, devices.getCollection()); + } - /** - * Retrieve a filtered list of storage devices in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrievethelistofstoragedevices - * @return Filtered list of storage devices in this datacenter. - */ - @EnterpriseEdition - public List listStorageDevices(final Predicate filter) - { - return Lists.newLinkedList(filter(listStorageDevices(), filter)); - } + /** + * Retrieve a filtered list of storage devices in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrievethelistofstoragedevices + * @return Filtered list of storage devices in this datacenter. + */ + @EnterpriseEdition + public List listStorageDevices(final Predicate filter) { + return Lists.newLinkedList(filter(listStorageDevices(), filter)); + } - /** - * Retrieve the first storage device matching the filter within the list of devices in this - * datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrievethelistofstoragedevices - * @return First storage device matching the filter or null if there is none. - */ - @EnterpriseEdition - public StorageDevice findStorageDevice(final Predicate filter) - { - return Iterables.getFirst(filter(listStorageDevices(), filter), null); - } + /** + * Retrieve the first storage device matching the filter within the list of + * devices in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrievethelistofstoragedevices + * @return First storage device matching the filter or null if + * there is none. + */ + @EnterpriseEdition + public StorageDevice findStorageDevice(final Predicate filter) { + return Iterables.getFirst(filter(listStorageDevices(), filter), null); + } - /** - * Retrieve a single storage device. - * - * @param id Unique ID of the storage device in this datacenter. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrieveastoragedevice - * @return Storage device with the given id or null if it does not exist. - */ - @EnterpriseEdition - public StorageDevice getStorageDevice(final Integer id) - { - StorageDeviceDto device = - context.getApi().getInfrastructureApi().getStorageDevice(target, id); - return wrap(context, StorageDevice.class, device); - } + /** + * Retrieve a single storage device. + * + * @param id + * Unique ID of the storage device in this datacenter. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrieveastoragedevice + * @return Storage device with the given id or null if it does + * not exist. + */ + @EnterpriseEdition + public StorageDevice getStorageDevice(final Integer id) { + StorageDeviceDto device = context.getApi().getInfrastructureApi().getStorageDevice(target, id); + return wrap(context, StorageDevice.class, device); + } - /** - * Retrieve the list of remote services of this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * RetrievealistofRemoteServices - * @return List of remote services in this datacenter. - */ - public List listRemoteServices() - { - RemoteServicesDto remoteServices = - context.getApi().getInfrastructureApi().listRemoteServices(target); - return wrap(context, RemoteService.class, remoteServices.getCollection()); - } + /** + * Retrieve the list of remote services of this datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- RetrievealistofRemoteServices + * @return List of remote services in this datacenter. + */ + public List listRemoteServices() { + RemoteServicesDto remoteServices = context.getApi().getInfrastructureApi().listRemoteServices(target); + return wrap(context, RemoteService.class, remoteServices.getCollection()); + } - /** - * Retrieve a filtered list of remote services of this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * RetrievealistofRemoteServices - * @return Filtered list of remote services in this datacenter. - */ - public List listRemoteServices(final Predicate filter) - { - return Lists.newLinkedList(filter(listRemoteServices(), filter)); - } + /** + * Retrieve a filtered list of remote services of this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- RetrievealistofRemoteServices + * @return Filtered list of remote services in this datacenter. + */ + public List listRemoteServices(final Predicate filter) { + return Lists.newLinkedList(filter(listRemoteServices(), filter)); + } - /** - * Retrieve the first remote service matching the filter within the list of remote services in - * this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * RetrievealistofRemoteServices - * @return First remote service matching the filter or null if there is none. - */ - public RemoteService findRemoteService(final Predicate filter) - { - return Iterables.getFirst(filter(listRemoteServices(), filter), null); - } + /** + * Retrieve the first remote service matching the filter within the list of + * remote services in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- RetrievealistofRemoteServices + * @return First remote service matching the filter or null if + * there is none. + */ + public RemoteService findRemoteService(final Predicate filter) { + return Iterables.getFirst(filter(listRemoteServices(), filter), null); + } - private void createRemoteServices() - { - if (this.edition == AbiquoEdition.ENTERPRISE) - { - createRemoteService(RemoteServiceType.BPM_SERVICE); - createRemoteService(RemoteServiceType.DHCP_SERVICE); - createRemoteService(RemoteServiceType.STORAGE_SYSTEM_MONITOR); - } + private void createRemoteServices() { + if (this.edition == AbiquoEdition.ENTERPRISE) { + createRemoteService(RemoteServiceType.BPM_SERVICE); + createRemoteService(RemoteServiceType.DHCP_SERVICE); + createRemoteService(RemoteServiceType.STORAGE_SYSTEM_MONITOR); + } - createRemoteService(RemoteServiceType.APPLIANCE_MANAGER); - createRemoteService(RemoteServiceType.VIRTUAL_SYSTEM_MONITOR); - createRemoteService(RemoteServiceType.NODE_COLLECTOR); - createRemoteService(RemoteServiceType.VIRTUAL_FACTORY); - } + createRemoteService(RemoteServiceType.APPLIANCE_MANAGER); + createRemoteService(RemoteServiceType.VIRTUAL_SYSTEM_MONITOR); + createRemoteService(RemoteServiceType.NODE_COLLECTOR); + createRemoteService(RemoteServiceType.VIRTUAL_FACTORY); + } - private void createRemoteService(final RemoteServiceType type) - { - RemoteService.builder(context, this).type(type).ip(this.ip).build().save(); - } + private void createRemoteService(final RemoteServiceType type) { + RemoteService.builder(context, this).type(type).ip(this.ip).build().save(); + } - /** - * Retrieve the list of datacenter limits by all enterprises. The Datacenter Limits resource - * allows you to assign datacenters and allocated resources in them to be used by an enterprise. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievelimitsbydatacenter - * @return List of datacenter limits by all enterprises. - */ - public List listLimits() - { - DatacentersLimitsDto dto = - context.getApi().getInfrastructureApi().listLimits(this.unwrap()); - return DomainWrapper.wrap(context, Limits.class, dto.getCollection()); - } + /** + * Retrieve the list of datacenter limits by all enterprises. The Datacenter + * Limits resource allows you to assign datacenters and allocated resources + * in them to be used by an enterprise. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievelimitsbydatacenter + * @return List of datacenter limits by all enterprises. + */ + public List listLimits() { + DatacentersLimitsDto dto = context.getApi().getInfrastructureApi().listLimits(this.unwrap()); + return DomainWrapper.wrap(context, Limits.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of datacenter limits by enterprises. The Datacenter Limits resource - * allows you to assign datacenters and allocated resources in them to be used by an enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievelimitsbydatacenter - * @return Filtered list of datacenter limits by all enterprises. - */ - public List listLimits(final Predicate filter) - { - return Lists.newLinkedList(filter(listLimits(), filter)); - } + /** + * Retrieve a filtered list of datacenter limits by enterprises. The + * Datacenter Limits resource allows you to assign datacenters and allocated + * resources in them to be used by an enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievelimitsbydatacenter + * @return Filtered list of datacenter limits by all enterprises. + */ + public List listLimits(final Predicate filter) { + return Lists.newLinkedList(filter(listLimits(), filter)); + } - /** - * Retrieve the first datacenter limits matching the filter within the list of datacenter limits - * by enterprise. The Datacenter Limits resource allows you to assign datacenters and allocated - * resources in them to be used by an enterprise. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievelimitsbydatacenter - * @return First datacenter limits matching the filter or null if there is none. - */ - public Limits findLimits(final Predicate filter) - { - return Iterables.getFirst(filter(listLimits(), filter), null); - } + /** + * Retrieve the first datacenter limits matching the filter within the list + * of datacenter limits by enterprise. The Datacenter Limits resource allows + * you to assign datacenters and allocated resources in them to be used by an + * enterprise. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievelimitsbydatacenter + * @return First datacenter limits matching the filter or null + * if there is none. + */ + public Limits findLimits(final Predicate filter) { + return Iterables.getFirst(filter(listLimits(), filter), null); + } - /** - * Retrieve the list of tiers in ths datacenter. - * - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers - * - * @return List of tiers in this datacenter. - */ - @EnterpriseEdition - public List listTiers() - { - TiersDto dto = context.getApi().getInfrastructureApi().listTiers(this.unwrap()); - return DomainWrapper.wrap(context, Tier.class, dto.getCollection()); - } + /** + * Retrieve the list of tiers in ths datacenter. + * + * @see API: + * http://community.abiquo.com/display/ABI20/TierResource#TierResource- + * Retrievethelistoftiers + * @return List of tiers in this datacenter. + */ + @EnterpriseEdition + public List listTiers() { + TiersDto dto = context.getApi().getInfrastructureApi().listTiers(this.unwrap()); + return DomainWrapper.wrap(context, Tier.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of tiers in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers - * - * @return Filtered list of tiers in this datacenter. - */ - @EnterpriseEdition - public List listTiers(final Predicate filter) - { - return Lists.newLinkedList(filter(listTiers(), filter)); - } + /** + * Retrieve a filtered list of tiers in this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/TierResource#TierResource- + * Retrievethelistoftiers + * @return Filtered list of tiers in this datacenter. + */ + @EnterpriseEdition + public List listTiers(final Predicate filter) { + return Lists.newLinkedList(filter(listTiers(), filter)); + } - /** - * Retrieve the first tier matching the filter within the list of tiers in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrievethelistofstoragedevices - * @return First tier matching the filter or null if there is none. - */ - @EnterpriseEdition - public Tier findTier(final Predicate filter) - { - return Iterables.getFirst(filter(listTiers(), filter), null); - } + /** + * Retrieve the first tier matching the filter within the list of tiers in + * this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrievethelistofstoragedevices + * @return First tier matching the filter or null if there is + * none. + */ + @EnterpriseEdition + public Tier findTier(final Predicate filter) { + return Iterables.getFirst(filter(listTiers(), filter), null); + } - /** - * Retrieve the list of public, external and unmanaged networks in this datacenter. - * - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - * @return List of public, external and unmanaged networks in this datacenter. - */ - public List> listNetworks() - { - VLANNetworksDto networks = context.getApi().getInfrastructureApi().listNetworks(target); - return Network.wrapNetworks(context, networks.getCollection()); - } + /** + * Retrieve the list of public, external and unmanaged networks in this + * datacenter. + * + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + * @return List of public, external and unmanaged networks in this + * datacenter. + */ + public List> listNetworks() { + VLANNetworksDto networks = context.getApi().getInfrastructureApi().listNetworks(target); + return Network.wrapNetworks(context, networks.getCollection()); + } - /** - * Retrieve a filtered list of public, external and unmanaged networks in this datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - */ - public List> listNetworks(final Predicate> filter) - { - return Lists.newLinkedList(filter(listNetworks(), filter)); - } + /** + * Retrieve a filtered list of public, external and unmanaged networks in + * this datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + */ + public List> listNetworks(final Predicate> filter) { + return Lists.newLinkedList(filter(listNetworks(), filter)); + } - /** - * Retrieve the first network matching the filter within the list of networks. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - * @return Filtered list of public, external and unmanaged networks in this datacenter. - */ - public Network< ? > findNetwork(final Predicate> filter) - { - return Iterables.getFirst(filter(listNetworks(), filter), null); - } + /** + * Retrieve the first network matching the filter within the list of + * networks. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + * @return Filtered list of public, external and unmanaged networks in this + * datacenter. + */ + public Network findNetwork(final Predicate> filter) { + return Iterables.getFirst(filter(listNetworks(), filter), null); + } - /** - * Retrieve the list of networks of this datacenter matching the given type. - * - * @param type Network type filter. - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - * @return List of networks of this datacenter matching the given type. - */ - public List> listNetworks(final NetworkType type) - { - NetworkOptions options = NetworkOptions.builder().type(type).build(); - VLANNetworksDto networks = - context.getApi().getInfrastructureApi().listNetworks(target, options); - return Network.wrapNetworks(context, networks.getCollection()); - } + /** + * Retrieve the list of networks of this datacenter matching the given type. + * + * @param type + * Network type filter. + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + * @return List of networks of this datacenter matching the given type. + */ + public List> listNetworks(final NetworkType type) { + NetworkOptions options = NetworkOptions.builder().type(type).build(); + VLANNetworksDto networks = context.getApi().getInfrastructureApi().listNetworks(target, options); + return Network.wrapNetworks(context, networks.getCollection()); + } - /** - * Retrieve a filtered list of networks of this datacenter matching the given type. - * - * @param type Network type filter. - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - * @return Filtered list of networks of this datacenter matching the given type. - */ - public List> listNetworks(final NetworkType type, - final Predicate> filter) - { - return Lists.newLinkedList(filter(listNetworks(type), filter)); - } + /** + * Retrieve a filtered list of networks of this datacenter matching the given + * type. + * + * @param type + * Network type filter. + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + * @return Filtered list of networks of this datacenter matching the given + * type. + */ + public List> listNetworks(final NetworkType type, final Predicate> filter) { + return Lists.newLinkedList(filter(listNetworks(type), filter)); + } - /** - * Retrieve the first network of the given type matching the filter. - * - * @param type Network type filter. - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource#PublicNetworkResource- - * Getthelistofpublicnetworks - * @return First network of the given type matching the filter or null if there is - * none. - */ - public Network< ? > findNetwork(final NetworkType type, final Predicate> filter) - { - return Iterables.getFirst(filter(listNetworks(type), filter), null); - } + /** + * Retrieve the first network of the given type matching the filter. + * + * @param type + * Network type filter. + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/PublicNetworkResource# + * PublicNetworkResource- Getthelistofpublicnetworks + * @return First network of the given type matching the filter or + * null if there is none. + */ + public Network findNetwork(final NetworkType type, final Predicate> filter) { + return Iterables.getFirst(filter(listNetworks(type), filter), null); + } - /** - * Retrieve a single public, external or unmanaged network from this datacenter. - * {@link org.jclouds.abiquo.domain.network.Network#toExternalNetwork}, - * {@link org.jclouds.abiquo.domain.network.Network#toPublicNetwork} and - * {@link org.jclouds.abiquo.domain.network.Network#toUnmanagedNetwork} can be used to convert - * the Network into the appropiate domain object. - * - * @param id Unique ID of the network in this datacenter. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#PublicNetworkResource# - * PublicNetworkResource-Getthelistofpublicnetworks - * @return Network with the given id or null if it does not exist. - */ - public Network< ? > getNetwork(final Integer id) - { - VLANNetworkDto network = context.getApi().getInfrastructureApi().getNetwork(target, id); - return Network.wrapNetwork(context, network); - } + /** + * Retrieve a single public, external or unmanaged network from this + * datacenter. + * {@link org.jclouds.abiquo.domain.network.Network#toExternalNetwork}, + * {@link org.jclouds.abiquo.domain.network.Network#toPublicNetwork} and + * {@link org.jclouds.abiquo.domain.network.Network#toUnmanagedNetwork} can + * be used to convert the Network into the appropiate domain object. + * + * @param id + * Unique ID of the network in this datacenter. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * PublicNetworkResource# + * PublicNetworkResource-Getthelistofpublicnetworks + * @return Network with the given id or null if it does not + * exist. + */ + public Network getNetwork(final Integer id) { + VLANNetworkDto network = context.getApi().getInfrastructureApi().getNetwork(target, id); + return Network.wrapNetwork(context, network); + } - // Actions + // Actions - /** - * Retrieve the hypervisor type from remote machine. - * - * @param ip IP address of the physical machine. - * @see API: - * @return Hypervisor type of the remote machine. - * @throws Exception If the hypervisor type information cannot be retrieved. - */ - public HypervisorType getHypervisorType(final String ip) - { - DatacenterOptions options = DatacenterOptions.builder().ip(ip).build(); + /** + * Retrieve the hypervisor type from remote machine. + * + * @param ip + * IP address of the physical machine. + * @see API: + * @return Hypervisor type of the remote machine. + * @throws Exception + * If the hypervisor type information cannot be retrieved. + */ + public HypervisorType getHypervisorType(final String ip) { + DatacenterOptions options = DatacenterOptions.builder().ip(ip).build(); - String type = - context.getApi().getInfrastructureApi().getHypervisorTypeFromMachine(target, options); + String type = context.getApi().getInfrastructureApi().getHypervisorTypeFromMachine(target, options); - return HypervisorType.valueOf(type); - } + return HypervisorType.valueOf(type); + } - /** - * Retrieve the list of available hypervisor types in the datacenter. - * - * @see API: - * @return List of available hypervisor types in the datacenter. - */ - @EnterpriseEdition - public List listAvailableHypervisors() - { - HypervisorTypesDto types = - context.getApi().getInfrastructureApi().getHypervisorTypes(target); + /** + * Retrieve the list of available hypervisor types in the datacenter. + * + * @see API: + * @return List of available hypervisor types in the datacenter. + */ + @EnterpriseEdition + public List listAvailableHypervisors() { + HypervisorTypesDto types = context.getApi().getInfrastructureApi().getHypervisorTypes(target); - return getHypervisorTypes(types); - } + return getHypervisorTypes(types); + } - /** - * Retrieve a filtered list of available hypervisor types in the datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: - * @return Filtered list of available hypervisor types in the datacenter. - */ - @EnterpriseEdition - public List listAvailableHypervisors(final Predicate filter) - { - return Lists.newLinkedList(filter(listAvailableHypervisors(), filter)); - } + /** + * Retrieve a filtered list of available hypervisor types in the datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * @return Filtered list of available hypervisor types in the datacenter. + */ + @EnterpriseEdition + public List listAvailableHypervisors(final Predicate filter) { + return Lists.newLinkedList(filter(listAvailableHypervisors(), filter)); + } - /** - * Retrieve the first hypervisor type matching the filter within the list of types. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveavailablehypervisortypes - * @return First hypervisor type matching the filter or null if there is none. - */ - @EnterpriseEdition - public HypervisorType findHypervisor(final Predicate filter) - { - return Iterables.getFirst(filter(listAvailableHypervisors(), filter), null); - } + /** + * Retrieve the first hypervisor type matching the filter within the list of + * types. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveavailablehypervisortypes + * @return First hypervisor type matching the filter or null if + * there is none. + */ + @EnterpriseEdition + public HypervisorType findHypervisor(final Predicate filter) { + return Iterables.getFirst(filter(listAvailableHypervisors(), filter), null); + } - private List getHypervisorTypes(final HypervisorTypesDto dtos) - { - List types = Lists.newArrayList(); + private List getHypervisorTypes(final HypervisorTypesDto dtos) { + List types = Lists.newArrayList(); - for (HypervisorTypeDto dto : dtos.getCollection()) - { - types.add(HypervisorType.fromId(dto.getId())); - } + for (HypervisorTypeDto dto : dtos.getCollection()) { + types.add(HypervisorType.fromId(dto.getId())); + } - return types; - } + return types; + } - /** - * Searches a remote machine and retrieves an Machine object with its information. - * - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return A physical machine if found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveremotemachineinformation - */ - public Machine discoverSingleMachine(final String ip, final HypervisorType hypervisorType, - final String user, final String password) - { - return discoverSingleMachine(ip, hypervisorType, user, password, hypervisorType.defaultPort); - } + /** + * Searches a remote machine and retrieves an Machine object with its + * information. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return A physical machine if found or null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveremotemachineinformation + */ + public Machine discoverSingleMachine(final String ip, final HypervisorType hypervisorType, final String user, + final String password) { + return discoverSingleMachine(ip, hypervisorType, user, password, hypervisorType.defaultPort); + } - /** - * Searches a remote machine and retrieves an Machine object with its information. - * - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param port Port to connect. - * @return A physical machine if found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveremotemachineinformation - */ - public Machine discoverSingleMachine(final String ip, final HypervisorType hypervisorType, - final String user, final String password, final int port) - { - MachineDto dto = - context - .getApi() - .getInfrastructureApi() - .discoverSingleMachine(target, ip, hypervisorType, user, password, - MachineOptions.builder().port(port).build()); + /** + * Searches a remote machine and retrieves an Machine object with its + * information. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param port + * Port to connect. + * @return A physical machine if found or null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveremotemachineinformation + */ + public Machine discoverSingleMachine(final String ip, final HypervisorType hypervisorType, final String user, + final String password, final int port) { + MachineDto dto = context + .getApi() + .getInfrastructureApi() + .discoverSingleMachine(target, ip, hypervisorType, user, password, + MachineOptions.builder().port(port).build()); - // Credentials are not returned by the API - dto.setUser(user); - dto.setPassword(password); + // Credentials are not returned by the API + dto.setUser(user); + dto.setPassword(password); - return wrap(context, Machine.class, dto); - } + return wrap(context, Machine.class, dto); + } - /** - * Searches multiple remote machines and retrieves an Machine list with its information. - * - * @param ipFrom IP address of the remote first hypervisor to check. - * @param ipTo IP address of the remote last hypervisor to check. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievealistofremotemachineinformation - */ - public List discoverMultipleMachines(final String ipFrom, final String ipTo, - final HypervisorType hypervisorType, final String user, final String password) - { - return discoverMultipleMachines(ipFrom, ipTo, hypervisorType, user, password, - hypervisorType.defaultPort); - } + /** + * Searches multiple remote machines and retrieves an Machine list with its + * information. + * + * @param ipFrom + * IP address of the remote first hypervisor to check. + * @param ipTo + * IP address of the remote last hypervisor to check. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievealistofremotemachineinformation + */ + public List discoverMultipleMachines(final String ipFrom, final String ipTo, + final HypervisorType hypervisorType, final String user, final String password) { + return discoverMultipleMachines(ipFrom, ipTo, hypervisorType, user, password, hypervisorType.defaultPort); + } - /** - * Searches multiple remote machines and retrieves an Machine list with its information. - * - * @param ipFrom IP address of the remote first hypervisor to check. - * @param ipTo IP address of the remote last hypervisor to check. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param port Port to connect. - * @return The physical machine list. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievealistofremotemachineinformation - */ - public List discoverMultipleMachines(final String ipFrom, final String ipTo, - final HypervisorType hypervisorType, final String user, final String password, - final int port) - { - MachinesDto dto = - context - .getApi() - .getInfrastructureApi() - .discoverMultipleMachines(target, ipFrom, ipTo, hypervisorType, user, password, - MachineOptions.builder().port(port).build()); + /** + * Searches multiple remote machines and retrieves an Machine list with its + * information. + * + * @param ipFrom + * IP address of the remote first hypervisor to check. + * @param ipTo + * IP address of the remote last hypervisor to check. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param port + * Port to connect. + * @return The physical machine list. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievealistofremotemachineinformation + */ + public List discoverMultipleMachines(final String ipFrom, final String ipTo, + final HypervisorType hypervisorType, final String user, final String password, final int port) { + MachinesDto dto = context + .getApi() + .getInfrastructureApi() + .discoverMultipleMachines(target, ipFrom, ipTo, hypervisorType, user, password, + MachineOptions.builder().port(port).build()); - // Credentials are not returned by the API - for (MachineDto machine : dto.getCollection()) - { - machine.setUser(user); - machine.setPassword(password); - } + // Credentials are not returned by the API + for (MachineDto machine : dto.getCollection()) { + machine.setUser(user); + machine.setPassword(password); + } - return wrap(context, Machine.class, dto.getCollection()); - } + return wrap(context, Machine.class, dto.getCollection()); + } - /** - * Check the state of a remote machine. This feature is used to check the state from a remote - * machine giving its location, user, password and hypervisor type. This machine does not need - * to be managed by Abiquo. - * - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine state if the machine is found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Checkthestatefromremotemachine - */ - public MachineState checkMachineState(final String ip, final HypervisorType hypervisorType, - final String user, final String password) - { - return checkMachineState(ip, hypervisorType, user, password, + /** + * Check the state of a remote machine. This feature is used to check the + * state from a remote machine giving its location, user, password and + * hypervisor type. This machine does not need to be managed by Abiquo. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine state if the machine is found or + * null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Checkthestatefromremotemachine + */ + public MachineState checkMachineState(final String ip, final HypervisorType hypervisorType, final String user, + final String password) { + return checkMachineState(ip, hypervisorType, user, password, MachineOptions.builder().port(hypervisorType.defaultPort).build()); - } + } - /** - * Check the state of a remote machine. This feature is used to check the state from a remote - * machine giving its location, user, password and hypervisor type. This machine does not need - * to be managed by Abiquo. - * - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param options. - * @return The physical machine state if the machine is found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Checkthestatefromremotemachine - */ - public MachineState checkMachineState(final String ip, final HypervisorType hypervisorType, - final String user, final String password, final MachineOptions options) - { - MachineStateDto dto = - context.getApi().getInfrastructureApi() - .checkMachineState(target, ip, hypervisorType, user, password, options); + /** + * Check the state of a remote machine. This feature is used to check the + * state from a remote machine giving its location, user, password and + * hypervisor type. This machine does not need to be managed by Abiquo. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param options + * . + * @return The physical machine state if the machine is found or + * null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Checkthestatefromremotemachine + */ + public MachineState checkMachineState(final String ip, final HypervisorType hypervisorType, final String user, + final String password, final MachineOptions options) { + MachineStateDto dto = context.getApi().getInfrastructureApi() + .checkMachineState(target, ip, hypervisorType, user, password, options); - return dto.getState(); - } + return dto.getState(); + } - /** - * Check the ipmi configuration state of a remote machine. This feature is used to check the - * ipmi configuration state from a remote machine giving its location, user and password. This - * machine does not need to be managed by Abiquo. - * - * @param ip IP address of the remote hypervisor to connect. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine state if the machine is found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Checktheipmistatefromremotemachine - */ - public MachineIpmiState checkMachineIpmiState(final String ip, final String user, - final String password) - { - MachineIpmiStateDto dto = - context.getApi().getInfrastructureApi() - .checkMachineIpmiState(target, ip, user, password); - return dto.getState(); - } + /** + * Check the ipmi configuration state of a remote machine. This feature is + * used to check the ipmi configuration state from a remote machine giving + * its location, user and password. This machine does not need to be managed + * by Abiquo. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine state if the machine is found or + * null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Checktheipmistatefromremotemachine + */ + public MachineIpmiState checkMachineIpmiState(final String ip, final String user, final String password) { + MachineIpmiStateDto dto = context.getApi().getInfrastructureApi() + .checkMachineIpmiState(target, ip, user, password); + return dto.getState(); + } - /** - * Check the ipmi configuration state of a remote machine. This feature is used to check the - * ipmi configuration state from a remote machine giving its location, user and password. This - * machine does not need to be managed by Abiquo. - * - * @param ip IP address of the remote hypervisor to connect. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine state if the machine is found or null. - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Checktheipmistatefromremotemachine - */ - public MachineIpmiState checkMachineIpmiState(final String ip, final String user, - final String password, final IpmiOptions options) - { - MachineIpmiStateDto dto = - context.getApi().getInfrastructureApi() - .checkMachineIpmiState(target, ip, user, password, options); - return dto.getState(); - } + /** + * Check the ipmi configuration state of a remote machine. This feature is + * used to check the ipmi configuration state from a remote machine giving + * its location, user and password. This machine does not need to be managed + * by Abiquo. + * + * @param ip + * IP address of the remote hypervisor to connect. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine state if the machine is found or + * null. + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Checktheipmistatefromremotemachine + */ + public MachineIpmiState checkMachineIpmiState(final String ip, final String user, final String password, + final IpmiOptions options) { + MachineIpmiStateDto dto = context.getApi().getInfrastructureApi() + .checkMachineIpmiState(target, ip, user, password, options); + return dto.getState(); + } - /** - * Retrieve the list of virtual machine templates in the repository of this datacenter. - * - * @param enterprise Owner of the templates. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource# - * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates - * @return List of virtual machine templates in the repository of this datacenter. - */ - public List listTemplatesInRepository(final Enterprise enterprise) - { - VirtualMachineTemplatesDto dto = - context.getApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(enterprise.getId(), target.getId()); - return wrap(context, VirtualMachineTemplate.class, dto.getCollection()); - } + /** + * Retrieve the list of virtual machine templates in the repository of this + * datacenter. + * + * @param enterprise + * Owner of the templates. + * @see API: http://community.abiquo.com/display/ABI20/ + * VirtualMachineTemplateResource# + * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates + * @return List of virtual machine templates in the repository of this + * datacenter. + */ + public List listTemplatesInRepository(final Enterprise enterprise) { + VirtualMachineTemplatesDto dto = context.getApi().getVirtualMachineTemplateApi() + .listVirtualMachineTemplates(enterprise.getId(), target.getId()); + return wrap(context, VirtualMachineTemplate.class, dto.getCollection()); + } - /** - * Retrieve a filtered list of virtual machine templates in the repository of this datacenter. - * - * @param enterprise Owner of the templates. - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource# - * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates - * @return Filtered list of virtual machine templates in the repository of this datacenter. - */ - public List listTemplatesInRepository(final Enterprise enterprise, - final Predicate filter) - { - return Lists.newLinkedList(filter(listTemplatesInRepository(enterprise), filter)); - } + /** + * Retrieve a filtered list of virtual machine templates in the repository of + * this datacenter. + * + * @param enterprise + * Owner of the templates. + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/ + * VirtualMachineTemplateResource# + * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates + * @return Filtered list of virtual machine templates in the repository of + * this datacenter. + */ + public List listTemplatesInRepository(final Enterprise enterprise, + final Predicate filter) { + return Lists.newLinkedList(filter(listTemplatesInRepository(enterprise), filter)); + } - /** - * Retrieve the first virtual machine template within the list of templates of this datacenter - * from the given enterprise. - * - * @param enterprise Owner of the templates. - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource# - * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates - * @return First virtual machine template matching the filter or null if there is - * none. - */ - public VirtualMachineTemplate findTemplateInRepository(final Enterprise enterprise, - final Predicate filter) - { - return Iterables.getFirst(filter(listTemplatesInRepository(enterprise), filter), null); - } + /** + * Retrieve the first virtual machine template within the list of templates + * of this datacenter from the given enterprise. + * + * @param enterprise + * Owner of the templates. + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/ + * VirtualMachineTemplateResource# + * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates + * @return First virtual machine template matching the filter or + * null if there is none. + */ + public VirtualMachineTemplate findTemplateInRepository(final Enterprise enterprise, + final Predicate filter) { + return Iterables.getFirst(filter(listTemplatesInRepository(enterprise), filter), null); + } - /** - * Retrieve a single virtual machine template in of this datacenter from the given enterprise. - * - * @param enterprise Owner of the templates. - * @param id Unique ID of the template in the datacenter repository for the given enterprise. - * @see API: http://community.abiquo.com/display/ABI20/VirtualMachineTemplateResource# - * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates - * @return Virtual machine template with the given id in the given enterpriess or - * null if it does not exist. - */ - public VirtualMachineTemplate getTemplateInRepository(final Enterprise enterprise, - final Integer id) - { - VirtualMachineTemplateDto template = - context.getApi().getVirtualMachineTemplateApi() - .getVirtualMachineTemplate(enterprise.getId(), target.getId(), id); - return wrap(context, VirtualMachineTemplate.class, template); - } + /** + * Retrieve a single virtual machine template in of this datacenter from the + * given enterprise. + * + * @param enterprise + * Owner of the templates. + * @param id + * Unique ID of the template in the datacenter repository for the + * given enterprise. + * @see API: http://community.abiquo.com/display/ABI20/ + * VirtualMachineTemplateResource# + * VirtualMachineTemplateResource-Retrieveallvirtualmachinetemplates + * @return Virtual machine template with the given id in the given + * enterpriess or null if it does not exist. + */ + public VirtualMachineTemplate getTemplateInRepository(final Enterprise enterprise, final Integer id) { + VirtualMachineTemplateDto template = context.getApi().getVirtualMachineTemplateApi() + .getVirtualMachineTemplate(enterprise.getId(), target.getId(), id); + return wrap(context, VirtualMachineTemplate.class, template); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private String name; + private String name; - private String location; + private String location; - private String ip; + private String ip; - private AbiquoEdition edition; + private AbiquoEdition edition; - public Builder(final RestContext context) - { - super(); - this.context = context; - } + public Builder(final RestContext context) { + super(); + this.context = context; + } - public Builder remoteServices(final String ip, final AbiquoEdition edition) - { - this.ip = ip; - this.edition = edition; - return this; - } + public Builder remoteServices(final String ip, final AbiquoEdition edition) { + this.ip = ip; + this.edition = edition; + return this; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder location(final String location) - { - this.location = location; - return this; - } + public Builder location(final String location) { + this.location = location; + return this; + } - public Datacenter build() - { - DatacenterDto dto = new DatacenterDto(); - dto.setName(name); - dto.setLocation(location); - Datacenter datacenter = new Datacenter(context, dto); - datacenter.edition = edition; - datacenter.ip = ip; - return datacenter; - } + public Datacenter build() { + DatacenterDto dto = new DatacenterDto(); + dto.setName(name); + dto.setLocation(location); + Datacenter datacenter = new Datacenter(context, dto); + datacenter.edition = edition; + datacenter.ip = ip; + return datacenter; + } - public static Builder fromDatacenter(final Datacenter in) - { - return Datacenter.builder(in.context).name(in.getName()).location(in.getLocation()); - } - } + public static Builder fromDatacenter(final Datacenter in) { + return Datacenter.builder(in.context).name(in.getName()).location(in.getLocation()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getLocation() - { - return target.getLocation(); - } + public String getLocation() { + return target.getLocation(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setLocation(final String location) - { - target.setLocation(location); - } + public void setLocation(final String location) { + target.setLocation(location); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public String getUUID() - { - return target.getUuid(); - } + public String getUUID() { + return target.getUuid(); + } - @Override - public String toString() - { - return "Datacenter [id=" + getId() + ", location=" + getLocation() + ", name=" + getName() - + ", uuid=" + getUUID() + "]"; - } + @Override + public String toString() { + return "Datacenter [id=" + getId() + ", location=" + getLocation() + ", name=" + getName() + ", uuid=" + + getUUID() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datastore.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datastore.java index 65709d48cb..825583c7f7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datastore.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Datastore.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.infrastructure; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -33,69 +32,58 @@ import com.abiquo.server.core.infrastructure.DatastoreDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class Datastore extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. This resource cannot be created. - */ - private Datastore(final RestContext context, final DatastoreDto target) - { - super(context, target); - } +public class Datastore extends DomainWrapper { + /** + * Constructor to be used only by the builder. This resource cannot be + * created. + */ + private Datastore(final RestContext context, final DatastoreDto target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public String getDatastoreUUID() - { - return target.getDatastoreUUID(); - } + public String getDatastoreUUID() { + return target.getDatastoreUUID(); + } - public String getDirectory() - { - return target.getDirectory(); - } + public String getDirectory() { + return target.getDirectory(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getRootPath() - { - return target.getRootPath(); - } + public String getRootPath() { + return target.getRootPath(); + } - public long getSize() - { - return target.getSize(); - } + public long getSize() { + return target.getSize(); + } - public long getUsedSize() - { - return target.getUsedSize(); - } + public long getUsedSize() { + return target.getUsedSize(); + } - public boolean isEnabled() - { - return target.isEnabled(); - } + public boolean isEnabled() { + return target.isEnabled(); + } - public void setEnabled(final boolean enabled) - { - target.setEnabled(enabled); - } + public void setEnabled(final boolean enabled) { + target.setEnabled(enabled); + } - @Override - public String toString() - { - return "Datastore [id=" + getId() + ", uuid=" + getDatastoreUUID() + ", directory=" - + getDirectory() + ", name=" + getName() + ", rootPath=" + getRootPath() + ", size=" - + getSize() + ", usedSize=" + getUsedSize() + ", enabled=" + isEnabled() + "]"; - } + @Override + public String toString() { + return "Datastore [id=" + getId() + ", uuid=" + getDatastoreUUID() + ", directory=" + getDirectory() + ", name=" + + getName() + ", rootPath=" + getRootPath() + ", size=" + getSize() + ", usedSize=" + getUsedSize() + + ", enabled=" + isEnabled() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java index bdf59459e0..549c5af49d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Fsm.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.infrastructure; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -37,48 +36,40 @@ import com.abiquo.server.core.infrastructure.FsmDto; * http://community.abiquo.com/display/ABI20/Rack+Resource */ @EnterpriseEdition -public class Fsm extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Fsm(final RestContext context, final FsmDto target) - { - super(context, target); - } +public class Fsm extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Fsm(final RestContext context, final FsmDto target) { + super(context, target); + } - // Delegate Methods + // Delegate Methods - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public String getDn() - { - return target.getDn(); - } + public String getDn() { + return target.getDn(); + } - public String getError() - { - return target.getError(); - } + public String getError() { + return target.getError(); + } - public String getProgress() - { - return target.getProgress(); - } + public String getProgress() { + return target.getProgress(); + } - public String getStatus() - { - return target.getStatus(); - } + public String getStatus() { + return target.getStatus(); + } - @Override - public String toString() - { - return "Fsm [Dn=" + getDn() + ", Description=" + getDescription() + ", Error=" + getError() - + ", Progress=" + getProgress() + ", Status=" + getStatus() + "]"; - } + @Override + public String toString() { + return "Fsm [Dn=" + getDn() + ", Description=" + getDescription() + ", Error=" + getError() + ", Progress=" + + getProgress() + ", Status=" + getStatus() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java index 8969b85b77..8c668bc645 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/LogicServer.java @@ -39,64 +39,52 @@ import com.abiquo.server.core.infrastructure.LogicServerPolicyDto; * http://community.abiquo.com/display/ABI20/Rack+Resource */ @EnterpriseEdition -public class LogicServer extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected LogicServer(final RestContext context, final LogicServerDto target) - { - super(context, target); - } +public class LogicServer extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected LogicServer(final RestContext context, final LogicServerDto target) { + super(context, target); + } - // Delegate Methods + // Delegate Methods - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setType(final String value) - { - target.setType(value); - } + public void setType(final String value) { + target.setType(value); + } - public String getAssociated() - { - return target.getAssociated(); - } + public String getAssociated() { + return target.getAssociated(); + } - public String getType() - { - return target.getType(); - } + public String getType() { + return target.getType(); + } - public String getAssociatedTo() - { - return target.getAssociatedTo(); - } + public String getAssociatedTo() { + return target.getAssociatedTo(); + } - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public void setDescription(final String value) - { - target.setDescription(value); - } + public void setDescription(final String value) { + target.setDescription(value); + } - public List getCollection() - { - return target.getCollection(); - } + public List getCollection() { + return target.getCollection(); + } - @Override - public String toString() - { - return "LogicServer [name=" + getName() + ", associated=" + getAssociated() + ", type=" - + getType() + ", associatedTo=" + getAssociatedTo() + ", description=" - + getDescription() + "]"; - } + @Override + public String toString() { + return "LogicServer [name=" + getName() + ", associated=" + getAssociated() + ", type=" + getType() + + ", associatedTo=" + getAssociatedTo() + ", description=" + getDescription() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java index d3616852f9..177ba0dee1 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Machine.java @@ -54,496 +54,456 @@ import com.google.common.collect.Lists; import com.google.inject.TypeLiteral; /** - * Adds high level functionality to {@link MachineDto}. This resource allows you to manage physical - * machines in the cloud infrastructure. + * Adds high level functionality to {@link MachineDto}. This resource allows you + * to manage physical machines in the cloud infrastructure. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/MachineResource */ -public class Machine extends AbstractPhysicalMachine -{ - /** The rack where the machine belongs. */ - protected Rack rack; - - /** - * Constructor to be used only by the builder. - */ - protected Machine(final RestContext context, final MachineDto target) - { - super(context, target); - } - - /** - * Create a new physical machine in Abiquo. The best way to create a machine if first calling - * {@link Datacenter#discoverSingleMachine} or {@link Datacenter#discoverMultipleMachines}. This - * will return a new {@link Machine}. The following steps are: enabling a datastore, selecting a - * virtual switch and choosing a rack. Refer link for more information. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveremotemachineinformation - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * Createamachine - */ - public void save() - { - target = context.getApi().getInfrastructureApi().createMachine(rack.unwrap(), target); - } - - @Override - public MachineState check() - { - MachineStateDto dto = - context.getApi().getInfrastructureApi().checkMachineState(target, true); - MachineState state = dto.getState(); - target.setState(state); - return state; - } - - // Parent access - /** - * Retrieve the unmanaged rack where the machine is. - * - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource-RetrieveaRack - */ - public Rack getRack() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.RACK), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.RACK); - - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); - - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(RackDto.class)); - - return wrap(context, Rack.class, parser.apply(response)); - } - - // Children access - - @Override - public List getDatastores() - { - return wrap(context, Datastore.class, target.getDatastores().getCollection()); - } - - @Override - public Datastore findDatastore(final String name) - { - return find(getDatastores(), DatastorePredicates.name(name), null); - } - - /** - * Gets the list of virtual machines in the physical machine. - * - * @return The list of virtual machines in the physical machine. - * @see API: http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource- - * Retrievethelistofvirtualmachinesbymachine'shypervisor - */ - public List listVirtualMachines() - { - MachineOptions options = MachineOptions.builder().sync(false).build(); - VirtualMachinesWithNodeExtendedDto vms = - context.getApi().getInfrastructureApi().listVirtualMachinesByMachine(target, options); - return wrap(context, VirtualMachine.class, vms.getCollection()); - } - - /** - * Gets the list of virtual machines in the physical machine matching the given filter. - * - * @param filter The filter to apply. - * @return The list of virtual machines in the physical machine matching the given filter. - */ - public List listVirtualMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualMachines(), filter)); - } - - /** - * Gets a single virtual machine in the physical machine matching the given filter. - * - * @param filter The filter to apply. - * @return The virtual machine or null if none matched the given filter. - */ - public VirtualMachine findVirtualMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } - - /** - * Gets the list of virtual machines in the physical machine sinchronizing virtual machines from - * remote hypervisor with abiquo's database. - * - * @return The list of virtual machines in the physical machine. - * @see API: http://community.abiquo.com/display/ABI20/Machine+Resource#MachineResource- - * Retrievethelistofvirtualmachinesbymachine'shypervisor - */ - public List listRemoteVirtualMachines() - { - MachineOptions options = MachineOptions.builder().sync(true).build(); - VirtualMachinesWithNodeExtendedDto vms = - context.getApi().getInfrastructureApi().listVirtualMachinesByMachine(target, options); - return wrap(context, VirtualMachine.class, vms.getCollection()); - } - - /** - * Gets the list of virtual machines in the physical machine matching the given filter - * sinchronizing virtual machines from remote hypervisor with abiquo's database. - * - * @param filter The filter to apply. - * @return The list of remote virtual machines in the physical machine matching the given - * filter. - */ - public List listRemoteVirtualMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listVirtualMachines(), filter)); - } - - /** - * Gets a single virtual machine in the physical machine matching the given filter sinchronizing - * virtual machines from remote hypervisor with abiquo's database. - * - * @param filter The filter to apply. - * @return The virtual machine or null if none matched the given filter. - */ - public VirtualMachine findRemoteVirtualMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listVirtualMachines(), filter), null); - } - - /** - * Reserve the machine for the given enterprise. - *

- * When a {@link Machine} is reserved for an {@link Enterprise}, only the users of that - * enterprise will be able to deploy {@link VirtualMachine}s in it. - * - * @param enterprise The enterprise reserving the machine. - */ - public void reserveFor(final Enterprise enterprise) - { - target = - context.getApi().getInfrastructureApi().reserveMachine(enterprise.unwrap(), target); - } - - /** - * Cancels the machine reservation for the given enterprise. - * - * @param enterprise The enterprise to cancel reservation for. - */ - public void cancelReservationFor(final Enterprise enterprise) - { - context.getApi().getInfrastructureApi().cancelReservation(enterprise.unwrap(), target); - target.getLinks().remove(target.searchLink(ParentLinkName.ENTERPRISE)); - } - - /** - * Check if the machine is reserved. - * - * @return Boolean indicating if the machine is reserved for an enterprise. - */ - public boolean isReserved() - { - return target.searchLink(ParentLinkName.ENTERPRISE) != null; - } - - /** - * Get the enterprise that has reserved the machine or null if the machine is not - * reserved. - * - * @return The enterprise that has reserved the machine or null if the machine is - * not reserved. - */ - public Enterprise getOwnerEnterprise() - { - if (!isReserved()) - { - return null; - } - - EnterpriseDto enterprise = - context.getApi().getEnterpriseApi() - .getEnterprise(target.getIdFromLink(ParentLinkName.ENTERPRISE)); - - return wrap(context, Enterprise.class, enterprise); - } - - // Builder - - public static Builder builder(final RestContext context, - final Rack rack) - { - return new Builder(context, rack); - } - - public static class Builder - { - private RestContext context; - - private String name, description; - - private Integer virtualRamInMb; - - private Integer virtualRamUsedInMb = DEFAULT_VRAM_USED; - - private Integer virtualCpuCores; - - private Integer virtualCpusUsed = DEFAULT_VCPU_USED; - - private String virtualSwitch; - - private Integer port; - - private String ip; - - private MachineState state = MachineState.STOPPED; - - private String ipService; - - private HypervisorType type; - - private String user; - - private String password; - - private Iterable datastores; - - private String ipmiIp; - - private Integer ipmiPort; - - private String ipmiUser; - - private String ipmiPassword; - - private Rack rack; - - public Builder(final RestContext context, final Rack rack) - { - super(); - checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Rack.class); - this.rack = rack; - this.context = context; - } - - public Builder state(final MachineState state) - { - this.state = state; - return this; - } - - public Builder ipmiPassword(final String ipmiPassword) - { - this.ipmiPassword = ipmiPassword; - return this; - } - - public Builder ipmiUser(final String ipmiUser) - { - this.ipmiUser = ipmiUser; - return this; - } - - public Builder ipmiPort(final int ipmiPort) - { - this.ipmiPort = ipmiPort; - return this; - } - - public Builder ipmiIp(final String ipmiIp) - { - this.ipmiIp = ipmiIp; - return this; - } - - public Builder user(final String user) - { - this.user = user; - return this; - } - - public Builder ip(final String ip) - { - this.ip = ip; - if (ipService == null) - { - ipService = ip; - } - return this; - } - - public Builder ipService(final String ipService) - { - this.ipService = ipService; - return this; - } - - public Builder password(final String password) - { - this.password = password; - return this; - } - - public Builder virtualSwitch(final String virtualSwitch) - { - this.virtualSwitch = virtualSwitch; - return this; - } - - public Builder name(final String name) - { - this.name = name; - return this; - } - - public Builder description(final String description) - { - this.description = description; - return this; - } - - public Builder port(final int port) - { - this.port = port; - return this; - } - - public Builder datastores(final Iterable datastores) - { - this.datastores = datastores; - return this; - } - - public Builder virtualRamInMb(final int virtualRamInMb) - { - this.virtualRamInMb = virtualRamInMb; - return this; - } - - public Builder virtualRamUsedInMb(final int virtualRamUsedInMb) - { - this.virtualRamUsedInMb = virtualRamUsedInMb; - return this; - } - - public Builder virtualCpuCores(final int virtualCpuCores) - { - this.virtualCpuCores = virtualCpuCores; - return this; - } - - public Builder virtualCpusUsed(final int virtualCpusUsed) - { - this.virtualCpusUsed = virtualCpusUsed; - return this; - } - - public Builder hypervisorType(final HypervisorType hypervisorType) - { - this.type = hypervisorType; - - // Sets default hypervisor port - if (this.port == null) - { - this.port = hypervisorType.defaultPort; - } - - return this; - } - - public Builder rack(final Rack rack) - { - checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.rack = rack; - return this; - } - - public Machine build() - { - MachineDto dto = new MachineDto(); - dto.setName(name); - dto.setDescription(description); - dto.setVirtualRamInMb(virtualRamInMb); - dto.setVirtualRamUsedInMb(virtualRamUsedInMb); - dto.setVirtualCpuCores(virtualCpuCores); - dto.setVirtualCpusUsed(virtualCpusUsed); - dto.setVirtualSwitch(virtualSwitch); - if (port != null) - { - dto.setPort(port); - } - dto.setIp(ip); - dto.setIpService(ipService); - dto.setType(type); - dto.setUser(user); - dto.setPassword(password); - dto.setIpmiIP(ipmiIp); - dto.setIpmiPassword(ipmiPassword); - if (ipmiPort != null) - { - dto.setIpmiPort(ipmiPort); - } - dto.setIpmiUser(ipmiUser); - dto.setState(state); - - DatastoresDto datastoresDto = new DatastoresDto(); - datastoresDto.getCollection().addAll(unwrap(datastores)); - dto.setDatastores(datastoresDto); - - Machine machine = new Machine(context, dto); - machine.rack = rack; - - return machine; - } - - public static Builder fromMachine(final Machine in) - { - Builder builder = - Machine.builder(in.context, in.rack).name(in.getName()) - .description(in.getDescription()).virtualCpuCores(in.getVirtualCpuCores()) - .virtualCpusUsed(in.getVirtualCpusUsed()) - .virtualRamInMb(in.getVirtualRamInMb()) - .virtualRamUsedInMb(in.getVirtualRamUsedInMb()) - .virtualSwitch(in.getVirtualSwitch()).port(in.getPort()).ip(in.getIp()) - .ipService(in.getIpService()).hypervisorType(in.getType()).user(in.getUser()) - .password(in.getPassword()).ipmiIp(in.getIpmiIp()) - .ipmiPassword(in.getIpmiPassword()).ipmiUser(in.getIpmiUser()) - .state(in.getState()).datastores(in.getDatastores()); - - // Parameters that can be null - if (in.getIpmiPort() != null) - { - builder.ipmiPort(in.getIpmiPort()); - } - - return builder; - } - } - - // Delegate methods - - public void setRack(final Rack rack) - { - this.rack = rack; - } - - public VirtualMachine getVirtualMachine(final Integer virtualMachineId) - { - VirtualMachineWithNodeExtendedDto vm = - context.getApi().getInfrastructureApi().getVirtualMachine(target, virtualMachineId); - return wrap(context, VirtualMachine.class, vm); - } +public class Machine extends AbstractPhysicalMachine { + /** The rack where the machine belongs. */ + protected Rack rack; + + /** + * Constructor to be used only by the builder. + */ + protected Machine(final RestContext context, final MachineDto target) { + super(context, target); + } + + /** + * Create a new physical machine in Abiquo. The best way to create a machine + * if first calling {@link Datacenter#discoverSingleMachine} or + * {@link Datacenter#discoverMultipleMachines}. This will return a new + * {@link Machine}. The following steps are: enabling a datastore, selecting + * a virtual switch and choosing a rack. Refer link for more information. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveremotemachineinformation + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- Createamachine + */ + public void save() { + target = context.getApi().getInfrastructureApi().createMachine(rack.unwrap(), target); + } + + @Override + public MachineState check() { + MachineStateDto dto = context.getApi().getInfrastructureApi().checkMachineState(target, true); + MachineState state = dto.getState(); + target.setState(state); + return state; + } + + // Parent access + /** + * Retrieve the unmanaged rack where the machine is. + * + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveaRack + */ + public Rack getRack() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.RACK), ValidationErrors.MISSING_REQUIRED_LINK + " " + + ParentLinkName.RACK); + + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); + + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(RackDto.class)); + + return wrap(context, Rack.class, parser.apply(response)); + } + + // Children access + + @Override + public List getDatastores() { + return wrap(context, Datastore.class, target.getDatastores().getCollection()); + } + + @Override + public Datastore findDatastore(final String name) { + return find(getDatastores(), DatastorePredicates.name(name), null); + } + + /** + * Gets the list of virtual machines in the physical machine. + * + * @return The list of virtual machines in the physical machine. + * @see API: http://community.abiquo.com/display/ABI20/Machine+Resource# + * MachineResource- + * Retrievethelistofvirtualmachinesbymachine'shypervisor + */ + public List listVirtualMachines() { + MachineOptions options = MachineOptions.builder().sync(false).build(); + VirtualMachinesWithNodeExtendedDto vms = context.getApi().getInfrastructureApi() + .listVirtualMachinesByMachine(target, options); + return wrap(context, VirtualMachine.class, vms.getCollection()); + } + + /** + * Gets the list of virtual machines in the physical machine matching the + * given filter. + * + * @param filter + * The filter to apply. + * @return The list of virtual machines in the physical machine matching the + * given filter. + */ + public List listVirtualMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualMachines(), filter)); + } + + /** + * Gets a single virtual machine in the physical machine matching the given + * filter. + * + * @param filter + * The filter to apply. + * @return The virtual machine or null if none matched the given + * filter. + */ + public VirtualMachine findVirtualMachine(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualMachines(), filter), null); + } + + /** + * Gets the list of virtual machines in the physical machine sinchronizing + * virtual machines from remote hypervisor with abiquo's database. + * + * @return The list of virtual machines in the physical machine. + * @see API: http://community.abiquo.com/display/ABI20/Machine+Resource# + * MachineResource- + * Retrievethelistofvirtualmachinesbymachine'shypervisor + */ + public List listRemoteVirtualMachines() { + MachineOptions options = MachineOptions.builder().sync(true).build(); + VirtualMachinesWithNodeExtendedDto vms = context.getApi().getInfrastructureApi() + .listVirtualMachinesByMachine(target, options); + return wrap(context, VirtualMachine.class, vms.getCollection()); + } + + /** + * Gets the list of virtual machines in the physical machine matching the + * given filter sinchronizing virtual machines from remote hypervisor with + * abiquo's database. + * + * @param filter + * The filter to apply. + * @return The list of remote virtual machines in the physical machine + * matching the given filter. + */ + public List listRemoteVirtualMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listVirtualMachines(), filter)); + } + + /** + * Gets a single virtual machine in the physical machine matching the given + * filter sinchronizing virtual machines from remote hypervisor with abiquo's + * database. + * + * @param filter + * The filter to apply. + * @return The virtual machine or null if none matched the given + * filter. + */ + public VirtualMachine findRemoteVirtualMachine(final Predicate filter) { + return Iterables.getFirst(filter(listVirtualMachines(), filter), null); + } + + /** + * Reserve the machine for the given enterprise. + *

+ * When a {@link Machine} is reserved for an {@link Enterprise}, only the + * users of that enterprise will be able to deploy {@link VirtualMachine}s in + * it. + * + * @param enterprise + * The enterprise reserving the machine. + */ + public void reserveFor(final Enterprise enterprise) { + target = context.getApi().getInfrastructureApi().reserveMachine(enterprise.unwrap(), target); + } + + /** + * Cancels the machine reservation for the given enterprise. + * + * @param enterprise + * The enterprise to cancel reservation for. + */ + public void cancelReservationFor(final Enterprise enterprise) { + context.getApi().getInfrastructureApi().cancelReservation(enterprise.unwrap(), target); + target.getLinks().remove(target.searchLink(ParentLinkName.ENTERPRISE)); + } + + /** + * Check if the machine is reserved. + * + * @return Boolean indicating if the machine is reserved for an enterprise. + */ + public boolean isReserved() { + return target.searchLink(ParentLinkName.ENTERPRISE) != null; + } + + /** + * Get the enterprise that has reserved the machine or null if + * the machine is not reserved. + * + * @return The enterprise that has reserved the machine or null + * if the machine is not reserved. + */ + public Enterprise getOwnerEnterprise() { + if (!isReserved()) { + return null; + } + + EnterpriseDto enterprise = context.getApi().getEnterpriseApi() + .getEnterprise(target.getIdFromLink(ParentLinkName.ENTERPRISE)); + + return wrap(context, Enterprise.class, enterprise); + } + + // Builder + + public static Builder builder(final RestContext context, final Rack rack) { + return new Builder(context, rack); + } + + public static class Builder { + private RestContext context; + + private String name, description; + + private Integer virtualRamInMb; + + private Integer virtualRamUsedInMb = DEFAULT_VRAM_USED; + + private Integer virtualCpuCores; + + private Integer virtualCpusUsed = DEFAULT_VCPU_USED; + + private String virtualSwitch; + + private Integer port; + + private String ip; + + private MachineState state = MachineState.STOPPED; + + private String ipService; + + private HypervisorType type; + + private String user; + + private String password; + + private Iterable datastores; + + private String ipmiIp; + + private Integer ipmiPort; + + private String ipmiUser; + + private String ipmiPassword; + + private Rack rack; + + public Builder(final RestContext context, final Rack rack) { + super(); + checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Rack.class); + this.rack = rack; + this.context = context; + } + + public Builder state(final MachineState state) { + this.state = state; + return this; + } + + public Builder ipmiPassword(final String ipmiPassword) { + this.ipmiPassword = ipmiPassword; + return this; + } + + public Builder ipmiUser(final String ipmiUser) { + this.ipmiUser = ipmiUser; + return this; + } + + public Builder ipmiPort(final int ipmiPort) { + this.ipmiPort = ipmiPort; + return this; + } + + public Builder ipmiIp(final String ipmiIp) { + this.ipmiIp = ipmiIp; + return this; + } + + public Builder user(final String user) { + this.user = user; + return this; + } + + public Builder ip(final String ip) { + this.ip = ip; + if (ipService == null) { + ipService = ip; + } + return this; + } + + public Builder ipService(final String ipService) { + this.ipService = ipService; + return this; + } + + public Builder password(final String password) { + this.password = password; + return this; + } + + public Builder virtualSwitch(final String virtualSwitch) { + this.virtualSwitch = virtualSwitch; + return this; + } + + public Builder name(final String name) { + this.name = name; + return this; + } + + public Builder description(final String description) { + this.description = description; + return this; + } + + public Builder port(final int port) { + this.port = port; + return this; + } + + public Builder datastores(final Iterable datastores) { + this.datastores = datastores; + return this; + } + + public Builder virtualRamInMb(final int virtualRamInMb) { + this.virtualRamInMb = virtualRamInMb; + return this; + } + + public Builder virtualRamUsedInMb(final int virtualRamUsedInMb) { + this.virtualRamUsedInMb = virtualRamUsedInMb; + return this; + } + + public Builder virtualCpuCores(final int virtualCpuCores) { + this.virtualCpuCores = virtualCpuCores; + return this; + } + + public Builder virtualCpusUsed(final int virtualCpusUsed) { + this.virtualCpusUsed = virtualCpusUsed; + return this; + } + + public Builder hypervisorType(final HypervisorType hypervisorType) { + this.type = hypervisorType; + + // Sets default hypervisor port + if (this.port == null) { + this.port = hypervisorType.defaultPort; + } + + return this; + } + + public Builder rack(final Rack rack) { + checkNotNull(rack, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.rack = rack; + return this; + } + + public Machine build() { + MachineDto dto = new MachineDto(); + dto.setName(name); + dto.setDescription(description); + dto.setVirtualRamInMb(virtualRamInMb); + dto.setVirtualRamUsedInMb(virtualRamUsedInMb); + dto.setVirtualCpuCores(virtualCpuCores); + dto.setVirtualCpusUsed(virtualCpusUsed); + dto.setVirtualSwitch(virtualSwitch); + if (port != null) { + dto.setPort(port); + } + dto.setIp(ip); + dto.setIpService(ipService); + dto.setType(type); + dto.setUser(user); + dto.setPassword(password); + dto.setIpmiIP(ipmiIp); + dto.setIpmiPassword(ipmiPassword); + if (ipmiPort != null) { + dto.setIpmiPort(ipmiPort); + } + dto.setIpmiUser(ipmiUser); + dto.setState(state); + + DatastoresDto datastoresDto = new DatastoresDto(); + datastoresDto.getCollection().addAll(unwrap(datastores)); + dto.setDatastores(datastoresDto); + + Machine machine = new Machine(context, dto); + machine.rack = rack; + + return machine; + } + + public static Builder fromMachine(final Machine in) { + Builder builder = Machine.builder(in.context, in.rack).name(in.getName()).description(in.getDescription()) + .virtualCpuCores(in.getVirtualCpuCores()).virtualCpusUsed(in.getVirtualCpusUsed()) + .virtualRamInMb(in.getVirtualRamInMb()).virtualRamUsedInMb(in.getVirtualRamUsedInMb()) + .virtualSwitch(in.getVirtualSwitch()).port(in.getPort()).ip(in.getIp()).ipService(in.getIpService()) + .hypervisorType(in.getType()).user(in.getUser()).password(in.getPassword()).ipmiIp(in.getIpmiIp()) + .ipmiPassword(in.getIpmiPassword()).ipmiUser(in.getIpmiUser()).state(in.getState()) + .datastores(in.getDatastores()); + + // Parameters that can be null + if (in.getIpmiPort() != null) { + builder.ipmiPort(in.getIpmiPort()); + } + + return builder; + } + } + + // Delegate methods + + public void setRack(final Rack rack) { + this.rack = rack; + } + + public VirtualMachine getVirtualMachine(final Integer virtualMachineId) { + VirtualMachineWithNodeExtendedDto vm = context.getApi().getInfrastructureApi() + .getVirtualMachine(target, virtualMachineId); + return wrap(context, VirtualMachine.class, vm); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java index 94dba1d27f..2d5bd09735 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/ManagedRack.java @@ -51,736 +51,663 @@ import com.google.common.collect.Lists; * http://community.abiquo.com/display/ABI20/RackResource */ @EnterpriseEdition -public class ManagedRack extends DomainWrapper -{ - /** The default minimum VLAN id. */ - private static final int DEFAULT_VLAN_ID_MIN = 2; +public class ManagedRack extends DomainWrapper { + /** The default minimum VLAN id. */ + private static final int DEFAULT_VLAN_ID_MIN = 2; - /** The default maximum VLAN id. */ - private static final int DEFAULT_VLAN_ID_MAX = 4094; + /** The default maximum VLAN id. */ + private static final int DEFAULT_VLAN_ID_MAX = 4094; - /** The default maximum VLAN per virtual datacenter. */ - private static final int DEFAULT_VLAN_PER_VDC = 1; + /** The default maximum VLAN per virtual datacenter. */ + private static final int DEFAULT_VLAN_PER_VDC = 1; - /** The default nrsq factor. */ - private static final int DEFAULT_NRSQ = 10; + /** The default nrsq factor. */ + private static final int DEFAULT_NRSQ = 10; - /** The datacenter where the rack belongs. */ - private Datacenter datacenter; + /** The datacenter where the rack belongs. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected ManagedRack(final RestContext context, - final UcsRackDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected ManagedRack(final RestContext context, final UcsRackDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the managed rack. - * - * @see API: - * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource#RackResource- - * DeleteaRack - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteRack(target); - target = null; - } + /** + * Delete the managed rack. + * + * @see API: + * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource + * #RackResource- DeleteaRack + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteRack(target); + target = null; + } - /** - * Create a new managed rack in Abiquo. This method wil discover the blades configured in the - * UCS. If the data provided for the connection is invalid a UcsRack will be created in Abiquo - * but with no Physical Machines attached to it. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewUCSRack< - * /a> - */ - public void save() - { - target = - context.getApi().getInfrastructureApi() - .createManagedRack(datacenter.unwrap(), target); - } + /** + * Create a new managed rack in Abiquo. This method wil discover the blades + * configured in the UCS. If the data provided for the connection is invalid + * a UcsRack will be created in Abiquo but with no Physical Machines attached + * to it. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * -CreateanewUCSRack< /a> + */ + public void save() { + target = context.getApi().getInfrastructureApi().createManagedRack(datacenter.unwrap(), target); + } - /** - * Update rack information in the server with the data from this rack. The IP data member cannot - * be updated. If changed will be ignored and the old IP will remain. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource#RackResource- - * UpdateanexistingUCSrack - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateManagedRack(target); - } + /** + * Update rack information in the server with the data from this rack. The IP + * data member cannot be updated. If changed will be ignored and the old IP + * will remain. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * #RackResource- UpdateanexistingUCSrack + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateManagedRack(target); + } - // Parent access - /** - * Retrieve the datacenter where this rack is. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveadatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi() - .getDatacenter(datacenterId)); - } + // Parent access + /** + * Retrieve the datacenter where this rack is. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveadatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(datacenterId)); + } - // Children access + // Children access - /** - * Retrieve the list of blades in this rack. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public List listMachines() - { - MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target); - return wrap(context, Blade.class, machines.getCollection()); - } + /** + * Retrieve the list of blades in this rack. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public List listMachines() { + MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target); + return wrap(context, Blade.class, machines.getCollection()); + } - /** - * Retrieve a filtered list of blades in this rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public List listMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listMachines(), filter)); - } + /** + * Retrieve a filtered list of blades in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public List listMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listMachines(), filter)); + } - /** - * Retrieve the first blade matching the filter within the list of machines in this rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public Blade findMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listMachines(), filter), null); - } + /** + * Retrieve the first blade matching the filter within the list of machines + * in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public Blade findMachine(final Predicate filter) { + return Iterables.getFirst(filter(listMachines(), filter), null); + } - /** - * Retrieve the list of service profiles in this UCS rack. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofallservicesprofilesinaUCSrack - */ - public List listServiceProfiles() - { - LogicServersDto profiles = - context.getApi().getInfrastructureApi().listServiceProfiles(target); - return wrap(context, LogicServer.class, profiles.getCollection()); - } + /** + * Retrieve the list of service profiles in this UCS rack. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofallservicesprofilesinaUCSrack + */ + public List listServiceProfiles() { + LogicServersDto profiles = context.getApi().getInfrastructureApi().listServiceProfiles(target); + return wrap(context, LogicServer.class, profiles.getCollection()); + } - /** - * Retrieve a filtered list of service profiles in this UCS rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofallservicesprofilesinaUCSrack - */ - public List listServiceProfiles(final Predicate filter) - { - return Lists.newLinkedList(filter(listServiceProfiles(), filter)); - } + /** + * Retrieve a filtered list of service profiles in this UCS rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofallservicesprofilesinaUCSrack + */ + public List listServiceProfiles(final Predicate filter) { + return Lists.newLinkedList(filter(listServiceProfiles(), filter)); + } - /** - * Retrieve the first service profile matching the filter within the list of profiles in this - * rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrievealistofallservicesprofilesinaUCSrack - */ - public LogicServer findServiceProfile(final Predicate filter) - { - return Iterables.getFirst(filter(listServiceProfiles(), filter), null); - } + /** + * Retrieve the first service profile matching the filter within the list of + * profiles in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrievealistofallservicesprofilesinaUCSrack + */ + public LogicServer findServiceProfile(final Predicate filter) { + return Iterables.getFirst(filter(listServiceProfiles(), filter), null); + } - /** - * Retrieve the list of service profile templates in this UCS rack. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource- - * RetrievealistofallServicesProfilesTemplatesinaUCSRack - */ - public List listServiceProfileTemplates() - { - LogicServersDto templates = - context.getApi().getInfrastructureApi().listServiceProfileTemplates(target); - return wrap(context, LogicServer.class, templates.getCollection()); - } + /** + * Retrieve the list of service profile templates in this UCS rack. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource- + * RetrievealistofallServicesProfilesTemplatesinaUCSRack + */ + public List listServiceProfileTemplates() { + LogicServersDto templates = context.getApi().getInfrastructureApi().listServiceProfileTemplates(target); + return wrap(context, LogicServer.class, templates.getCollection()); + } - /** - * Retrieve a filtered list of service profile templates in this UCS rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource- - * RetrievealistofallServicesProfilesTemplatesinaUCSRack - */ - public List listServiceProfileTemplates(final Predicate filter) - { - return Lists.newLinkedList(filter(listServiceProfileTemplates(), filter)); - } + /** + * Retrieve a filtered list of service profile templates in this UCS rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource- + * RetrievealistofallServicesProfilesTemplatesinaUCSRack + */ + public List listServiceProfileTemplates(final Predicate filter) { + return Lists.newLinkedList(filter(listServiceProfileTemplates(), filter)); + } - /** - * Retrieve the first service profile template matching the filter within the list of templates - * in this rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/RackResource- - * RetrievealistofallServicesProfilesTemplatesinaUCSRack - */ - public LogicServer findServiceProfileTemplate(final Predicate filter) - { - return Iterables.getFirst(filter(listServiceProfileTemplates(), filter), null); - } + /** + * Retrieve the first service profile template matching the filter within the + * list of templates in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/RackResource- + * RetrievealistofallServicesProfilesTemplatesinaUCSRack + */ + public LogicServer findServiceProfileTemplate(final Predicate filter) { + return Iterables.getFirst(filter(listServiceProfileTemplates(), filter), null); + } - /** - * Retrieve the list of organization in this UCS rack. The credentials in the UcsRack - * configuration might not have enough rights in the UCS to retrieve all organizations. Then - * only the allowed ones are returned. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/ - */ - public List listOrganizations() - { - OrganizationsDto organizations = - context.getApi().getInfrastructureApi().listOrganizations(target); - return wrap(context, Organization.class, organizations.getCollection()); - } + /** + * Retrieve the list of organization in this UCS rack. The credentials in the + * UcsRack configuration might not have enough rights in the UCS to retrieve + * all organizations. Then only the allowed ones are returned. This data is + * not persisted in Abiquo. + * + * @see API: + * http://community.abiquo.com/display/ABI20/ + */ + public List listOrganizations() { + OrganizationsDto organizations = context.getApi().getInfrastructureApi().listOrganizations(target); + return wrap(context, Organization.class, organizations.getCollection()); + } - /** - * Retrieve a filtered list of organization in this UCS rack. The credentials in the UcsRack - * configuration might not have enough rights in the UCS to retrieve all organizations. Then - * only the allowed ones are returned. This data is not persisted in Abiquo. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrieveallorganizationsfromaUCS - */ - public List listOrganizations(final Predicate filter) - { - return Lists.newLinkedList(filter(listOrganizations(), filter)); - } + /** + * Retrieve a filtered list of organization in this UCS rack. The credentials + * in the UcsRack configuration might not have enough rights in the UCS to + * retrieve all organizations. Then only the allowed ones are returned. This + * data is not persisted in Abiquo. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveallorganizationsfromaUCS + */ + public List listOrganizations(final Predicate filter) { + return Lists.newLinkedList(filter(listOrganizations(), filter)); + } - /** - * Retrieve the first organization matching the filter within the list of organization in this - * rack. The credentials in the UcsRack configuration might not have enough rights in the UCS to - * retrieve all organizations. Then only the allowed ones are returned. This data is not - * persisted in Abiquo. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrieveallorganizationsfromaUCS - */ - public Organization findOrganization(final Predicate filter) - { - return Iterables.getFirst(filter(listOrganizations(), filter), null); - } + /** + * Retrieve the first organization matching the filter within the list of + * organization in this rack. The credentials in the UcsRack configuration + * might not have enough rights in the UCS to retrieve all organizations. + * Then only the allowed ones are returned. This data is not persisted in + * Abiquo. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * RetrieveallorganizationsfromaUCS + */ + public Organization findOrganization(final Predicate filter) { + return Iterables.getFirst(filter(listOrganizations(), filter), null); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * RetrieveFSMofanentityinUCS - */ - public List listFsm(final String entityName) - { - FsmsDto fsms = context.getApi().getInfrastructureApi().listFsms(target, entityName); - return wrap(context, Fsm.class, fsms.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - RetrieveFSMofanentityinUCS + */ + public List listFsm(final String entityName) { + FsmsDto fsms = context.getApi().getInfrastructureApi().listFsms(target, entityName); + return wrap(context, Fsm.class, fsms.getCollection()); + } - // Actions + // Actions - /** - * Clone a Service Profile this rack. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * ClonelogicserverinUCS - */ - public void cloneLogicServer(final LogicServer logicServer, final Organization organization, - final String newName) - { - context.getApi().getInfrastructureApi() + /** + * Clone a Service Profile this rack. This data is not persisted in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - ClonelogicserverinUCS + */ + public void cloneLogicServer(final LogicServer logicServer, final Organization organization, final String newName) { + context.getApi().getInfrastructureApi() .cloneLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), newName); - } + } - /** - * Associate a Service Profile and a Blade in UCS. If the Service Profile is already associated - * then the request cannot be completed. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * AssociatelogicserverwithabladeinUCS - */ - public void associateLogicServer(final String bladeName, final LogicServer logicServer, - final Organization organization) - { - context + /** + * Associate a Service Profile and a Blade in UCS. If the Service Profile is + * already associated then the request cannot be completed. This data is not + * persisted in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - AssociatelogicserverwithabladeinUCS + */ + public void associateLogicServer(final String bladeName, final LogicServer logicServer, + final Organization organization) { + context.getApi().getInfrastructureApi() + .associateLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName); + } + + /** + * Clone and associate a Service Profile and a Blade in UCS. If the Blade is + * already associated then Abiquo will dissociate it first. If the request + * cannot be completed successfully the Blade might be left with no Service + * Profile associated. This data is not persisted in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - CloneandassociateLogicServerwithabladeinUCS + */ + public void cloneAndAssociateLogicServer(final String bladeName, final LogicServer logicServer, + final Organization organization, final String logicServerName) { + context .getApi() .getInfrastructureApi() - .associateLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), - bladeName); - } - - /** - * Clone and associate a Service Profile and a Blade in UCS. If the Blade is already associated - * then Abiquo will dissociate it first. If the request cannot be completed successfully the - * Blade might be left with no Service Profile associated. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * CloneandassociateLogicServerwithabladeinUCS - */ - public void cloneAndAssociateLogicServer(final String bladeName, final LogicServer logicServer, - final Organization organization, final String logicServerName) - { - context - .getApi() - .getInfrastructureApi() - .cloneAndAssociateLogicServer(this.unwrap(), logicServer.unwrap(), - organization.unwrap(), bladeName, logicServerName); - } - - /** - * Instantiate and associate a Service Profile Template and a Blade in UCS. If the Service - * Profile is already associated the request cannot be successful. If the Blade is already - * associated then Abiquo will dissociate it first. If the request cannot be completed - * successfully the Blade might be left with no Service Profile associated. This data is not - * persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * AssociateabladewithaLogicServerTemplate - */ - public void associateLogicServerTemplate(final String bladeName, final LogicServer logicServer, - final Organization organization, final String logicServerName) - { - context - .getApi() - .getInfrastructureApi() - .associateTemplate(this.unwrap(), logicServer.unwrap(), organization.unwrap(), - bladeName, logicServerName); - } - - /** - * Dissociates a Service Profile and a Blade in UCS. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * DisassociatelogicserverfromabladeinUCS - */ - public void disassociateLogicServer(final LogicServer logicServer) - { - context.getApi().getInfrastructureApi() - .dissociateLogicServer(this.unwrap(), logicServer.unwrap()); - } - - /** - * Deletes a Service Profile in UCS. This data is not persisted in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource- - * DeletelogicserverwithabladeinUCS - */ - public void deleteLogicServer(final LogicServer logicServer) - { - context.getApi().getInfrastructureApi() - .deleteLogicServer(this.unwrap(), logicServer.unwrap()); - } - - // Builder - - public static Builder builder(final RestContext context, - final Datacenter datacenter) - { - return new Builder(context, datacenter); - } - - public static class Builder - { - private RestContext context; - - private Integer id; - - private String name; - - private String shortDescription; - - private boolean haEnabled = false; - - private Integer nrsq = DEFAULT_NRSQ; - - private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX; - - private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN; - - private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC; - - private String vlansIdAvoided; - - private Integer port; - - private String ip; - - private String password; - - private String user; - - private String defaultTemplate; - - private Integer maxMachinesOn; - - private Datacenter datacenter; - - public Builder(final RestContext context, - final Datacenter datacenter) - { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - this.context = context; - } - - public Builder port(final Integer port) - { - this.port = port; - return this; - } - - public Builder ipAddress(final String ip) - { - this.ip = ip; - return this; - } - - public Builder password(final String password) - { - this.password = password; - return this; - } - - public Builder user(final String user) - { - this.user = user; - return this; - } - - public Builder defaultTemplate(final String defaultTemplate) - { - this.defaultTemplate = defaultTemplate; - return this; - } - - public Builder maxMachinesOn(final Integer maxMachinesOn) - { - this.maxMachinesOn = maxMachinesOn; - return this; - } - - public Builder id(final Integer id) - { - this.id = id; - return this; - } - - public Builder name(final String name) - { - this.name = name; - return this; - } - - public Builder shortDescription(final String shortDescription) - { - this.shortDescription = shortDescription; - return this; - } - - public Builder haEnabled(final boolean haEnabled) - { - this.haEnabled = haEnabled; - return this; - } - - public Builder nrsq(final int nrsq) - { - this.nrsq = nrsq; - return this; - } - - public Builder vlanIdMax(final int vlanIdMax) - { - this.vlanIdMax = vlanIdMax; - return this; - } - - public Builder vlanIdMin(final int vlanIdMin) - { - this.vlanIdMin = vlanIdMin; - return this; - } - - public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) - { - this.vlanPerVdcReserved = vlanPerVdcExpected; - return this; - } - - public Builder VlansIdAvoided(final String vlansIdAvoided) - { - this.vlansIdAvoided = vlansIdAvoided; - return this; - } - - public Builder datacenter(final Datacenter datacenter) - { - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - return this; - } - - public ManagedRack build() - { - UcsRackDto dto = new UcsRackDto(); - dto.setId(id); - dto.setName(name); - dto.setShortDescription(shortDescription); - dto.setHaEnabled(haEnabled); - dto.setNrsq(nrsq); - dto.setVlanIdMax(vlanIdMax); - dto.setVlanIdMin(vlanIdMin); - dto.setVlanPerVdcReserved(vlanPerVdcReserved); - dto.setVlansIdAvoided(vlansIdAvoided); - dto.setPort(port); - dto.setIp(ip); - dto.setPassword(password); - dto.setUser(user); - dto.setDefaultTemplate(defaultTemplate); - dto.setMaxMachinesOn(maxMachinesOn); - - ManagedRack rack = new ManagedRack(context, dto); - rack.datacenter = datacenter; - return rack; - } - - public static Builder fromRack(final ManagedRack in) - { - return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) - .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()) - .nrsq(in.getNrsq()).vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) - .vlanPerVdcReserved(in.getVlanPerVdcReserved()) - .VlansIdAvoided(in.getVlansIdAvoided()).port(in.getPort()).ipAddress(in.getIp()) - .password(in.getPassword()).user(in.getUser()) - .defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn()); - } - } - - // Delegate methods - - public Integer getId() - { - return target.getId(); - } - - public String getName() - { - return target.getName(); - } - - public String getShortDescription() - { - return target.getShortDescription(); - } - - public void setShortDescription(final String description) - { - target.setShortDescription(description); - } - - public void setHaEnabled(final boolean haEnabled) - { - target.setHaEnabled(haEnabled); - } - - public boolean isHaEnabled() - { - return target.isHaEnabled(); - } - - public Integer getNrsq() - { - return target.getNrsq(); - } - - public Integer getVlanIdMax() - { - return target.getVlanIdMax(); - } - - public Integer getVlanIdMin() - { - return target.getVlanIdMin(); - } - - public Integer getVlanPerVdcReserved() - { - return target.getVlanPerVdcReserved(); - } - - public String getVlansIdAvoided() - { - return target.getVlansIdAvoided(); - } - - public void setNrsq(final Integer nrsq) - { - target.setNrsq(nrsq); - } - - public void setVlanIdMax(final Integer vlanIdMax) - { - target.setVlanIdMax(vlanIdMax); - } - - public void setVlanIdMin(final Integer vlanIdMin) - { - target.setVlanIdMin(vlanIdMin); - } - - public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) - { - target.setVlanPerVdcReserved(vlanPerVdcReserved); - } - - public void setVlansIdAvoided(final String vlansIdAvoided) - { - target.setVlansIdAvoided(vlansIdAvoided); - } - - public String getIp() - { - return target.getIp(); - } - - public String getLongDescription() - { - return target.getLongDescription(); - } - - public Integer getMaxMachinesOn() - { - return target.getMaxMachinesOn(); - } - - public String getPassword() - { - return target.getPassword(); - } - - public Integer getPort() - { - return target.getPort(); - } - - public String getUser() - { - return target.getUser(); - } - - public void setDefaultTemplate(final String defaultTemplate) - { - target.setDefaultTemplate(defaultTemplate); - } - - public String getDefaultTemplate() - { - return target.getDefaultTemplate(); - } - - public void setIp(final String ip) - { - target.setIp(ip); - } - - public void setMaxMachinesOn(final Integer maxMachinesOn) - { - target.setMaxMachinesOn(maxMachinesOn); - } - - public void setPassword(final String password) - { - target.setPassword(password); - } - - public void setPort(final Integer port) - { - target.setPort(port); - } - - public void setUser(final String user) - { - target.setUser(user); - } - - @Override - public String toString() - { - return "ManagedRack [id=" + getId() + ", name=" + getName() + ", shortDescription=" - + getShortDescription() + ", haEnabled=" + isHaEnabled() + ", nrsq=" + getNrsq() - + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin() - + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" + .cloneAndAssociateLogicServer(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName, + logicServerName); + } + + /** + * Instantiate and associate a Service Profile Template and a Blade in UCS. + * If the Service Profile is already associated the request cannot be + * successful. If the Blade is already associated then Abiquo will dissociate + * it first. If the request cannot be completed successfully the Blade might + * be left with no Service Profile associated. This data is not persisted in + * Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - AssociateabladewithaLogicServerTemplate + */ + public void associateLogicServerTemplate(final String bladeName, final LogicServer logicServer, + final Organization organization, final String logicServerName) { + context.getApi().getInfrastructureApi() + .associateTemplate(this.unwrap(), logicServer.unwrap(), organization.unwrap(), bladeName, logicServerName); + } + + /** + * Dissociates a Service Profile and a Blade in UCS. This data is not + * persisted in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - DisassociatelogicserverfromabladeinUCS + */ + public void disassociateLogicServer(final LogicServer logicServer) { + context.getApi().getInfrastructureApi().dissociateLogicServer(this.unwrap(), logicServer.unwrap()); + } + + /** + * Deletes a Service Profile in UCS. This data is not persisted in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * - DeletelogicserverwithabladeinUCS + */ + public void deleteLogicServer(final LogicServer logicServer) { + context.getApi().getInfrastructureApi().deleteLogicServer(this.unwrap(), logicServer.unwrap()); + } + + // Builder + + public static Builder builder(final RestContext context, final Datacenter datacenter) { + return new Builder(context, datacenter); + } + + public static class Builder { + private RestContext context; + + private Integer id; + + private String name; + + private String shortDescription; + + private boolean haEnabled = false; + + private Integer nrsq = DEFAULT_NRSQ; + + private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX; + + private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN; + + private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC; + + private String vlansIdAvoided; + + private Integer port; + + private String ip; + + private String password; + + private String user; + + private String defaultTemplate; + + private Integer maxMachinesOn; + + private Datacenter datacenter; + + public Builder(final RestContext context, final Datacenter datacenter) { + super(); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + this.context = context; + } + + public Builder port(final Integer port) { + this.port = port; + return this; + } + + public Builder ipAddress(final String ip) { + this.ip = ip; + return this; + } + + public Builder password(final String password) { + this.password = password; + return this; + } + + public Builder user(final String user) { + this.user = user; + return this; + } + + public Builder defaultTemplate(final String defaultTemplate) { + this.defaultTemplate = defaultTemplate; + return this; + } + + public Builder maxMachinesOn(final Integer maxMachinesOn) { + this.maxMachinesOn = maxMachinesOn; + return this; + } + + public Builder id(final Integer id) { + this.id = id; + return this; + } + + public Builder name(final String name) { + this.name = name; + return this; + } + + public Builder shortDescription(final String shortDescription) { + this.shortDescription = shortDescription; + return this; + } + + public Builder haEnabled(final boolean haEnabled) { + this.haEnabled = haEnabled; + return this; + } + + public Builder nrsq(final int nrsq) { + this.nrsq = nrsq; + return this; + } + + public Builder vlanIdMax(final int vlanIdMax) { + this.vlanIdMax = vlanIdMax; + return this; + } + + public Builder vlanIdMin(final int vlanIdMin) { + this.vlanIdMin = vlanIdMin; + return this; + } + + public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) { + this.vlanPerVdcReserved = vlanPerVdcExpected; + return this; + } + + public Builder VlansIdAvoided(final String vlansIdAvoided) { + this.vlansIdAvoided = vlansIdAvoided; + return this; + } + + public Builder datacenter(final Datacenter datacenter) { + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + return this; + } + + public ManagedRack build() { + UcsRackDto dto = new UcsRackDto(); + dto.setId(id); + dto.setName(name); + dto.setShortDescription(shortDescription); + dto.setHaEnabled(haEnabled); + dto.setNrsq(nrsq); + dto.setVlanIdMax(vlanIdMax); + dto.setVlanIdMin(vlanIdMin); + dto.setVlanPerVdcReserved(vlanPerVdcReserved); + dto.setVlansIdAvoided(vlansIdAvoided); + dto.setPort(port); + dto.setIp(ip); + dto.setPassword(password); + dto.setUser(user); + dto.setDefaultTemplate(defaultTemplate); + dto.setMaxMachinesOn(maxMachinesOn); + + ManagedRack rack = new ManagedRack(context, dto); + rack.datacenter = datacenter; + return rack; + } + + public static Builder fromRack(final ManagedRack in) { + return ManagedRack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) + .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) + .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) + .vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided()) + .port(in.getPort()).ipAddress(in.getIp()).password(in.getPassword()).user(in.getUser()) + .defaultTemplate(in.getDefaultTemplate()).maxMachinesOn(in.getMaxMachinesOn()); + } + } + + // Delegate methods + + public Integer getId() { + return target.getId(); + } + + public String getName() { + return target.getName(); + } + + public String getShortDescription() { + return target.getShortDescription(); + } + + public void setShortDescription(final String description) { + target.setShortDescription(description); + } + + public void setHaEnabled(final boolean haEnabled) { + target.setHaEnabled(haEnabled); + } + + public boolean isHaEnabled() { + return target.isHaEnabled(); + } + + public Integer getNrsq() { + return target.getNrsq(); + } + + public Integer getVlanIdMax() { + return target.getVlanIdMax(); + } + + public Integer getVlanIdMin() { + return target.getVlanIdMin(); + } + + public Integer getVlanPerVdcReserved() { + return target.getVlanPerVdcReserved(); + } + + public String getVlansIdAvoided() { + return target.getVlansIdAvoided(); + } + + public void setNrsq(final Integer nrsq) { + target.setNrsq(nrsq); + } + + public void setVlanIdMax(final Integer vlanIdMax) { + target.setVlanIdMax(vlanIdMax); + } + + public void setVlanIdMin(final Integer vlanIdMin) { + target.setVlanIdMin(vlanIdMin); + } + + public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) { + target.setVlanPerVdcReserved(vlanPerVdcReserved); + } + + public void setVlansIdAvoided(final String vlansIdAvoided) { + target.setVlansIdAvoided(vlansIdAvoided); + } + + public String getIp() { + return target.getIp(); + } + + public String getLongDescription() { + return target.getLongDescription(); + } + + public Integer getMaxMachinesOn() { + return target.getMaxMachinesOn(); + } + + public String getPassword() { + return target.getPassword(); + } + + public Integer getPort() { + return target.getPort(); + } + + public String getUser() { + return target.getUser(); + } + + public void setDefaultTemplate(final String defaultTemplate) { + target.setDefaultTemplate(defaultTemplate); + } + + public String getDefaultTemplate() { + return target.getDefaultTemplate(); + } + + public void setIp(final String ip) { + target.setIp(ip); + } + + public void setMaxMachinesOn(final Integer maxMachinesOn) { + target.setMaxMachinesOn(maxMachinesOn); + } + + public void setPassword(final String password) { + target.setPassword(password); + } + + public void setPort(final Integer port) { + target.setPort(port); + } + + public void setUser(final String user) { + target.setUser(user); + } + + @Override + public String toString() { + return "ManagedRack [id=" + getId() + ", name=" + getName() + ", shortDescription=" + getShortDescription() + + ", haEnabled=" + isHaEnabled() + ", nrsq=" + getNrsq() + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + + getVlanIdMin() + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" + getVlansIdAvoided() + ", ip=" + getIp() + ", longDescription=" + getLongDescription() - + ", maxMachinesOn=" + getMaxMachinesOn() + ", password=**PROTECTED**, port=" - + getPort() + ", user=" + getUser() + ", defaultTemplate=" + getDefaultTemplate() + "]"; - } + + ", maxMachinesOn=" + getMaxMachinesOn() + ", password=**PROTECTED**, port=" + getPort() + ", user=" + + getUser() + ", defaultTemplate=" + getDefaultTemplate() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java index 6fafe38e53..f25c104804 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Organization.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.infrastructure; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -37,72 +36,59 @@ import com.abiquo.server.core.infrastructure.OrganizationDto; * http://community.abiquo.com/display/ABI20/RackResource */ @EnterpriseEdition -public class Organization extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Organization(final RestContext context, final OrganizationDto target) - { - super(context, target); - } +public class Organization extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Organization(final RestContext context, final OrganizationDto target) { + super(context, target); + } - // Delegate Methods + // Delegate Methods - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public String getDn() - { - return target.getDn(); - } + public String getDn() { + return target.getDn(); + } - public String getLevel() - { - return target.getLevel(); - } + public String getLevel() { + return target.getLevel(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getStatus() - { - return target.getStatus(); - } + public String getStatus() { + return target.getStatus(); + } - public void setDescription(final String value) - { - target.setDescription(value); - } + public void setDescription(final String value) { + target.setDescription(value); + } - public void setDn(final String dn) - { - target.setDn(dn); - } + public void setDn(final String dn) { + target.setDn(dn); + } - public void setLevel(final String value) - { - target.setLevel(value); - } + public void setLevel(final String value) { + target.setLevel(value); + } - public void setName(final String value) - { - target.setName(value); - } + public void setName(final String value) { + target.setName(value); + } - public void setStatus(final String value) - { - target.setStatus(value); - } + public void setStatus(final String value) { + target.setStatus(value); + } - @Override - public String toString() - { - return "Organization [name=" + getName() + ", description=" + getDescription() + ", dn=" - + getDn() + ", level=" + getLevel() + ", status=" + getStatus() + "]"; - } + @Override + public String toString() { + return "Organization [name=" + getName() + ", description=" + getDescription() + ", dn=" + getDn() + ", level=" + + getLevel() + ", status=" + getStatus() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java index 6777facade..945853f042 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Rack.java @@ -39,383 +39,339 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; /** - * Adds high level functionality to {@link RackDto}. Represents unmanaged racks in the Abiquo - * platform. + * Adds high level functionality to {@link RackDto}. Represents unmanaged racks + * in the Abiquo platform. * * @author Ignasi Barrera * @author Francesc Montserrat * @see API: * http://community.abiquo.com/display/ABI20/RackResource */ -public class Rack extends DomainWrapper -{ - /** The default minimum VLAN id. */ - private static final int DEFAULT_VLAN_ID_MIN = 2; +public class Rack extends DomainWrapper { + /** The default minimum VLAN id. */ + private static final int DEFAULT_VLAN_ID_MIN = 2; - /** The default maximum VLAN id. */ - private static final int DEFAULT_VLAN_ID_MAX = 4094; + /** The default maximum VLAN id. */ + private static final int DEFAULT_VLAN_ID_MAX = 4094; - /** The default maximum VLAN per virtual datacenter. */ - private static final int DEFAULT_VLAN_PER_VDC = 1; + /** The default maximum VLAN per virtual datacenter. */ + private static final int DEFAULT_VLAN_PER_VDC = 1; - /** The default nrsq factor. */ - private static final int DEFAULT_NRSQ = 10; + /** The default nrsq factor. */ + private static final int DEFAULT_NRSQ = 10; - /** The datacenter where the rack belongs. */ - private Datacenter datacenter; + /** The datacenter where the rack belongs. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected Rack(final RestContext context, final RackDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Rack(final RestContext context, final RackDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the unmanaged rack. - * - * @see API: - * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource#RackResource- - * DeleteaRack - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteRack(target); - target = null; - } + /** + * Delete the unmanaged rack. + * + * @see API: + * http://community.abiquo.com/display/ABI20/Rack+Resource#RackResource + * #RackResource- DeleteaRack + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteRack(target); + target = null; + } - /** - * Create a new unmanaged rack in Abiquo. - * - * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource-CreateanewRack - */ - public void save() - { - target = context.getApi().getInfrastructureApi().createRack(datacenter.unwrap(), target); - } + /** + * Create a new unmanaged rack in Abiquo. + * + * @see API: http://community.abiquo.com/display/ABI20/RackResource#RackResource + * -CreateanewRack + */ + public void save() { + target = context.getApi().getInfrastructureApi().createRack(datacenter.unwrap(), target); + } - /** - * Update rack information in the server with the data from this rack. - * - * @see API: - * http://community.abiquo.com/display/ABI20/RackResource#RackResource-UpdateanexistingRack - * - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateRack(target); - } + /** + * Update rack information in the server with the data from this rack. + * + * @see API: + * http://community.abiquo.com/display/ABI20/RackResource#RackResource- + * UpdateanexistingRack + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateRack(target); + } - // Parent access - /** - * Retrieve the datacenter where this rack is. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveadatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi() - .getDatacenter(datacenterId)); - } + // Parent access + /** + * Retrieve the datacenter where this rack is. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveadatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + return wrap(context, Datacenter.class, context.getApi().getInfrastructureApi().getDatacenter(datacenterId)); + } - // Children access + // Children access - /** - * Retrieve the list of physical machines in this rack. - * - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public List listMachines() - { - MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target); - return wrap(context, Machine.class, machines.getCollection()); - } + /** + * Retrieve the list of physical machines in this rack. + * + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public List listMachines() { + MachinesDto machines = context.getApi().getInfrastructureApi().listMachines(target); + return wrap(context, Machine.class, machines.getCollection()); + } - /** - * Retrieve a filtered list of physical machines in this rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public List listMachines(final Predicate filter) - { - return Lists.newLinkedList(filter(listMachines(), filter)); - } + /** + * Retrieve a filtered list of physical machines in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public List listMachines(final Predicate filter) { + return Lists.newLinkedList(filter(listMachines(), filter)); + } - /** - * Retrieve the first physical machine matching the filter within the list of machines in this - * rack. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/MachineResource#MachineResource- - * RetrievealistofMachines - */ - public Machine findMachine(final Predicate filter) - { - return Iterables.getFirst(filter(listMachines(), filter), null); - } + /** + * Retrieve the first physical machine matching the filter within the list of + * machines in this rack. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource- RetrievealistofMachines + */ + public Machine findMachine(final Predicate filter) { + return Iterables.getFirst(filter(listMachines(), filter), null); + } - /** - * Retrieve a single physical machine. - * - * @param id Unique ID of the physical machine in this rack. - * @see API: - * http://community.abiquo.com/display/ABI20/MachineResource#MachineResource-RetrieveaMachine - * - * @return Unmanaged rack with the given id or null if it does not exist. - */ - public Machine getMachine(final Integer id) - { - MachineDto machine = context.getApi().getInfrastructureApi().getMachine(target, id); - return wrap(context, Machine.class, machine); - } + /** + * Retrieve a single physical machine. + * + * @param id + * Unique ID of the physical machine in this rack. + * @see API: http://community.abiquo.com/display/ABI20/MachineResource# + * MachineResource-RetrieveaMachine + * @return Unmanaged rack with the given id or null if it does + * not exist. + */ + public Machine getMachine(final Integer id) { + MachineDto machine = context.getApi().getInfrastructureApi().getMachine(target, id); + return wrap(context, Machine.class, machine); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Datacenter datacenter) - { - return new Builder(context, datacenter); - } + public static Builder builder(final RestContext context, final Datacenter datacenter) { + return new Builder(context, datacenter); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Integer id; + private Integer id; - private String name; + private String name; - private String shortDescription; + private String shortDescription; - private boolean haEnabled = false; + private boolean haEnabled = false; - private Integer nrsq = DEFAULT_NRSQ; + private Integer nrsq = DEFAULT_NRSQ; - private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX; + private Integer vlanIdMax = DEFAULT_VLAN_ID_MAX; - private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN; + private Integer vlanIdMin = DEFAULT_VLAN_ID_MIN; - private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC; + private Integer vlanPerVdcReserved = DEFAULT_VLAN_PER_VDC; - private String vlansIdAvoided; + private String vlansIdAvoided; - private Datacenter datacenter; + private Datacenter datacenter; - public Builder(final RestContext context, - final Datacenter datacenter) - { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter) { + super(); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + this.context = context; + } - public Builder id(final Integer id) - { - this.id = id; - return this; - } + public Builder id(final Integer id) { + this.id = id; + return this; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - public Builder shortDescription(final String shortDescription) - { - this.shortDescription = shortDescription; - return this; - } + public Builder shortDescription(final String shortDescription) { + this.shortDescription = shortDescription; + return this; + } - public Builder haEnabled(final boolean haEnabled) - { - this.haEnabled = haEnabled; - return this; - } + public Builder haEnabled(final boolean haEnabled) { + this.haEnabled = haEnabled; + return this; + } - public Builder nrsq(final int nrsq) - { - this.nrsq = nrsq; - return this; - } + public Builder nrsq(final int nrsq) { + this.nrsq = nrsq; + return this; + } - public Builder vlanIdMax(final int vlanIdMax) - { - this.vlanIdMax = vlanIdMax; - return this; - } + public Builder vlanIdMax(final int vlanIdMax) { + this.vlanIdMax = vlanIdMax; + return this; + } - public Builder vlanIdMin(final int vlanIdMin) - { - this.vlanIdMin = vlanIdMin; - return this; - } + public Builder vlanIdMin(final int vlanIdMin) { + this.vlanIdMin = vlanIdMin; + return this; + } - public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) - { - this.vlanPerVdcReserved = vlanPerVdcExpected; - return this; - } + public Builder vlanPerVdcReserved(final int vlanPerVdcExpected) { + this.vlanPerVdcReserved = vlanPerVdcExpected; + return this; + } - public Builder VlansIdAvoided(final String vlansIdAvoided) - { - this.vlansIdAvoided = vlansIdAvoided; - return this; - } + public Builder VlansIdAvoided(final String vlansIdAvoided) { + this.vlansIdAvoided = vlansIdAvoided; + return this; + } - public Builder datacenter(final Datacenter datacenter) - { - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + return this; + } - public Rack build() - { - RackDto dto = new RackDto(); - dto.setId(id); - dto.setName(name); - dto.setShortDescription(shortDescription); - dto.setHaEnabled(haEnabled); - dto.setNrsq(nrsq); - dto.setVlanIdMax(vlanIdMax); - dto.setVlanIdMin(vlanIdMin); - dto.setVlanPerVdcReserved(vlanPerVdcReserved); - dto.setVlansIdAvoided(vlansIdAvoided); - Rack rack = new Rack(context, dto); - rack.datacenter = datacenter; - return rack; - } + public Rack build() { + RackDto dto = new RackDto(); + dto.setId(id); + dto.setName(name); + dto.setShortDescription(shortDescription); + dto.setHaEnabled(haEnabled); + dto.setNrsq(nrsq); + dto.setVlanIdMax(vlanIdMax); + dto.setVlanIdMin(vlanIdMin); + dto.setVlanPerVdcReserved(vlanPerVdcReserved); + dto.setVlansIdAvoided(vlansIdAvoided); + Rack rack = new Rack(context, dto); + rack.datacenter = datacenter; + return rack; + } - public static Builder fromRack(final Rack in) - { - return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) - .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()) - .nrsq(in.getNrsq()).vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) - .vlanPerVdcReserved(in.getVlanPerVdcReserved()) - .VlansIdAvoided(in.getVlansIdAvoided()); - } - } + public static Builder fromRack(final Rack in) { + return Rack.builder(in.context, in.datacenter).id(in.getId()).name(in.getName()) + .shortDescription(in.getShortDescription()).haEnabled(in.isHaEnabled()).nrsq(in.getNrsq()) + .vlanIdMax(in.getVlanIdMax()).vlanIdMin(in.getVlanIdMin()) + .vlanPerVdcReserved(in.getVlanPerVdcReserved()).VlansIdAvoided(in.getVlansIdAvoided()); + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getShortDescription() - { - return target.getShortDescription(); - } + public String getShortDescription() { + return target.getShortDescription(); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setShortDescription(final String description) - { - target.setShortDescription(description); - } + public void setShortDescription(final String description) { + target.setShortDescription(description); + } - public void setHaEnabled(final boolean haEnabled) - { - target.setHaEnabled(haEnabled); - } + public void setHaEnabled(final boolean haEnabled) { + target.setHaEnabled(haEnabled); + } - public boolean isHaEnabled() - { - return target.isHaEnabled(); - } + public boolean isHaEnabled() { + return target.isHaEnabled(); + } - public Integer getNrsq() - { - return target.getNrsq(); - } + public Integer getNrsq() { + return target.getNrsq(); + } - public Integer getVlanIdMax() - { - return target.getVlanIdMax(); - } + public Integer getVlanIdMax() { + return target.getVlanIdMax(); + } - public Integer getVlanIdMin() - { - return target.getVlanIdMin(); - } + public Integer getVlanIdMin() { + return target.getVlanIdMin(); + } - public Integer getVlanPerVdcReserved() - { - return target.getVlanPerVdcReserved(); - } + public Integer getVlanPerVdcReserved() { + return target.getVlanPerVdcReserved(); + } - public String getVlansIdAvoided() - { - return target.getVlansIdAvoided(); - } + public String getVlansIdAvoided() { + return target.getVlansIdAvoided(); + } - public void setNrsq(final Integer nrsq) - { - target.setNrsq(nrsq); - } + public void setNrsq(final Integer nrsq) { + target.setNrsq(nrsq); + } - public void setVlanIdMax(final Integer vlanIdMax) - { - target.setVlanIdMax(vlanIdMax); - } + public void setVlanIdMax(final Integer vlanIdMax) { + target.setVlanIdMax(vlanIdMax); + } - public void setVlanIdMin(final Integer vlanIdMin) - { - target.setVlanIdMin(vlanIdMin); - } + public void setVlanIdMin(final Integer vlanIdMin) { + target.setVlanIdMin(vlanIdMin); + } - public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) - { - target.setVlanPerVdcReserved(vlanPerVdcReserved); - } + public void setVlanPerVdcReserved(final Integer vlanPerVdcReserved) { + target.setVlanPerVdcReserved(vlanPerVdcReserved); + } - public void setVlansIdAvoided(final String vlansIdAvoided) - { - target.setVlansIdAvoided(vlansIdAvoided); - } + public void setVlansIdAvoided(final String vlansIdAvoided) { + target.setVlansIdAvoided(vlansIdAvoided); + } - @Override - public String toString() - { - return "Rack [id=" + getId() + ", name=" + getName() + ", description=" - + getShortDescription() + ", haEnabled=" + isHaEnabled() + ", nrsq=" + getNrsq() - + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin() - + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" - + getVlansIdAvoided() + "]"; - } + @Override + public String toString() { + return "Rack [id=" + getId() + ", name=" + getName() + ", description=" + getShortDescription() + ", haEnabled=" + + isHaEnabled() + ", nrsq=" + getNrsq() + ", vlanIdMax=" + getVlanIdMax() + ", vlanIdMin=" + getVlanIdMin() + + ", vlanPerVdcReserved=" + getVlanPerVdcReserved() + ", vlansIdAvoided=" + getVlansIdAvoided() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java index 568a742b59..aa58936208 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/RemoteService.java @@ -33,245 +33,217 @@ import com.abiquo.server.core.infrastructure.DatacenterDto; import com.abiquo.server.core.infrastructure.RemoteServiceDto; /** - * Adds high level functionality to {@link RemoteServiceDto}. The Remote Service resource offers the - * functionality of managing the remote services of a datacenter in a logical way. + * Adds high level functionality to {@link RemoteServiceDto}. The Remote Service + * resource offers the functionality of managing the remote services of a + * datacenter in a logical way. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/RemoteServiceResource */ -public class RemoteService extends DomainWrapper -{ - /** The default status. */ - private static final int DEFAULT_STATUS = 0; +public class RemoteService extends DomainWrapper { + /** The default status. */ + private static final int DEFAULT_STATUS = 0; - /** The datacenter using the remote service. */ - private Datacenter datacenter; + /** The datacenter using the remote service. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected RemoteService(final RestContext context, final RemoteServiceDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected RemoteService(final RestContext context, final RemoteServiceDto target) { + super(context, target); + } - /** - * Delete the remote service. - * - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * DeleteaRemoteService - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteRemoteService(target); - target = null; - } + /** + * Delete the remote service. + * + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- DeleteaRemoteService + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteRemoteService(target); + target = null; + } - /** - * Create the remote service. - * - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * CreateaRemoteService - */ - public void save() - { - target = - context.getApi().getInfrastructureApi() - .createRemoteService(datacenter.unwrap(), target); - } + /** + * Create the remote service. + * + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- CreateaRemoteService + */ + public void save() { + target = context.getApi().getInfrastructureApi().createRemoteService(datacenter.unwrap(), target); + } - /** - * Update remote service information in the server with the data from this remote service. - * - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * UpdateanexistingRemoteService - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateRemoteService(target); - } + /** + * Update remote service information in the server with the data from this + * remote service. + * + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- UpdateanexistingRemoteService + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateRemoteService(target); + } - /** - * Check remote service availability. - * - * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource#RemoteServiceResource- - * CheckthestatusofaRemoteService - */ - public boolean isAvailable() - { - // If the remote service can not be checked, assume it is available - return !getType().canBeChecked() ? true : context.getApi().getInfrastructureApi() - .isAvailable(target); - } + /** + * Check remote service availability. + * + * @see API: http://community.abiquo.com/display/ABI20/RemoteServiceResource# + * RemoteServiceResource- CheckthestatusofaRemoteService + */ + public boolean isAvailable() { + // If the remote service can not be checked, assume it is available + return !getType().canBeChecked() ? true : context.getApi().getInfrastructureApi().isAvailable(target); + } - // Parent access + // Parent access - /** - * Retrieve the datacenter using this remotes service. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveadatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - datacenter = wrap(context, Datacenter.class, dto); - return datacenter; - } + /** + * Retrieve the datacenter using this remotes service. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveadatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); + datacenter = wrap(context, Datacenter.class, dto); + return datacenter; + } - public static Builder builder(final RestContext context, final Datacenter datacenter) - { - return new Builder(context, datacenter); - } + public static Builder builder(final RestContext context, final Datacenter datacenter) { + return new Builder(context, datacenter); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private Integer id; + private Integer id; - private Datacenter datacenter; + private Datacenter datacenter; - private String ip; + private String ip; - private Integer port; + private Integer port; - private RemoteServiceType type; + private RemoteServiceType type; - private Integer status = DEFAULT_STATUS; + private Integer status = DEFAULT_STATUS; - // To be used only internally by the builder - private String uri; + // To be used only internally by the builder + private String uri; - public Builder(final RestContext context, final Datacenter datacenter) - { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter) { + super(); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + this.context = context; + } - public Builder datacenter(final Datacenter datacenter) - { - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + return this; + } - public Builder status(final int status) - { - this.status = status; - return this; - } + public Builder status(final int status) { + this.status = status; + return this; + } - public Builder type(final RemoteServiceType type) - { - this.type = type; - return this; - } + public Builder type(final RemoteServiceType type) { + this.type = type; + return this; + } - public Builder ip(final String ip) - { - this.ip = ip; - return this; - } + public Builder ip(final String ip) { + this.ip = ip; + return this; + } - public Builder port(final int port) - { - this.port = port; - return this; - } + public Builder port(final int port) { + this.port = port; + return this; + } - private String generateUri(final String ip, final Integer port, final RemoteServiceType type) - { - return type.getDefaultProtocol() + ip + ":" + port + "/" + type.getServiceMapping(); - } + private String generateUri(final String ip, final Integer port, final RemoteServiceType type) { + return type.getDefaultProtocol() + ip + ":" + port + "/" + type.getServiceMapping(); + } - public RemoteService build() - { - if (uri == null) - { - checkNotNull(ip, ValidationErrors.MISSING_REQUIRED_FIELD + "ip"); - checkNotNull(type, ValidationErrors.MISSING_REQUIRED_FIELD + "type"); + public RemoteService build() { + if (uri == null) { + checkNotNull(ip, ValidationErrors.MISSING_REQUIRED_FIELD + "ip"); + checkNotNull(type, ValidationErrors.MISSING_REQUIRED_FIELD + "type"); - uri = generateUri(ip, port == null ? type.getDefaultPort() : port, type); - } + uri = generateUri(ip, port == null ? type.getDefaultPort() : port, type); + } - RemoteServiceDto dto = new RemoteServiceDto(); - dto.setId(id); - dto.setType(type); - dto.setUri(uri); - dto.setStatus(status); - RemoteService remoteservice = new RemoteService(context, dto); - remoteservice.datacenter = datacenter; - return remoteservice; - } + RemoteServiceDto dto = new RemoteServiceDto(); + dto.setId(id); + dto.setType(type); + dto.setUri(uri); + dto.setStatus(status); + RemoteService remoteservice = new RemoteService(context, dto); + remoteservice.datacenter = datacenter; + return remoteservice; + } - public static Builder fromRemoteService(final RemoteService in) - { - Builder builder = - RemoteService.builder(in.context, in.getDatacenter()).status(in.getStatus()) - .type(in.getType()); - builder.uri = in.getUri(); - return builder; - } - } + public static Builder fromRemoteService(final RemoteService in) { + Builder builder = RemoteService.builder(in.context, in.getDatacenter()).status(in.getStatus()) + .type(in.getType()); + builder.uri = in.getUri(); + return builder; + } + } - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public RemoteServiceType getType() - { - return target.getType(); - } + public RemoteServiceType getType() { + return target.getType(); + } - public int getStatus() - { - return target.getStatus(); - } + public int getStatus() { + return target.getStatus(); + } - public String getUri() - { - return target.getUri(); - } + public String getUri() { + return target.getUri(); + } - public void setStatus(final int status) - { - target.setStatus(status); - } + public void setStatus(final int status) { + target.setStatus(status); + } - public void setType(final RemoteServiceType type) - { - target.setType(type); - } + public void setType(final RemoteServiceType type) { + target.setType(type); + } - public void setUri(final String uri) - { - target.setUri(uri); - } + public void setUri(final String uri) { + target.setUri(uri); + } - @Override - public String toString() - { - return "RemoteService [id=" + getId() + ", available=" + isAvailable() + ", type=" - + getType() + ", status=" + getStatus() + ", uri" + getUri() + "]"; - } + @Override + public String toString() { + return "RemoteService [id=" + getId() + ", available=" + isAvailable() + ", type=" + getType() + ", status=" + + getStatus() + ", uri" + getUri() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java index de0360ca4c..a56d74962e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDevice.java @@ -43,490 +43,440 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; /** - * Adds high level functionality to {@link StorageDeviceDto}. The Storage Device Resource offers the - * functionality of managing the external storage. + * Adds high level functionality to {@link StorageDeviceDto}. The Storage Device + * Resource offers the functionality of managing the external storage. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/StorageDeviceResource */ @EnterpriseEdition -public class StorageDevice extends DomainWrapper -{ - /** The datacenter where the storage device is. */ - private Datacenter datacenter; - - /** - * Constructor to be used only by the builder. - */ - protected StorageDevice(final RestContext context, - final StorageDeviceDto target) - { - super(context, target); - } - - /** - * Delete the storage device. - * - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Deleteastoragedevice - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteStorageDevice(target); - target = null; - } - - /** - * Create a new storage device. - * - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Createastoragedevice - */ - public void save() - { - target = - context.getApi().getInfrastructureApi() - .createStorageDevice(datacenter.unwrap(), target); - } - - /** - * Update storage device information in the server with the data from this device. - * - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Updateastoragedevice - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateStorageDevice(target); - } - - // Parent access - - /** - * Retrieve the datacenter where this storage device is. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveadatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - datacenter = wrap(context, Datacenter.class, dto); - return datacenter; - } - - // Children access - - /** - * Retrieve the list of storage pools in this device (synchronized with the device). - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return Synchronized list of storage pools in this device. - */ - public List listRemoteStoragePools() - { - StoragePoolsDto storagePools = - context.getApi().getInfrastructureApi() - .listStoragePools(target, StoragePoolOptions.builder().sync(true).build()); - - List storagePoolList = - wrap(context, StoragePool.class, storagePools.getCollection()); - - for (StoragePool storagePool : storagePoolList) - { - storagePool.storageDevice = this; - } - - return storagePoolList; - } - - /** - * Retrieve a filtered list of storage pools in this device (synchronized with the device). - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return Filtered synchronized list of storage pools in this device. - */ - public List listRemoteStoragePools(final Predicate filter) - { - return Lists.newLinkedList(filter(listRemoteStoragePools(), filter)); - } - - /** - * Retrieve the first storage pool matching the filter within the list of storage pools in this - * device (synchronized with the device). - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return First storage pool (synchronized) matching the filter or null if there - * is none. - */ - public StoragePool findRemoteStoragePool(final Predicate filter) - { - return Iterables.getFirst(filter(listRemoteStoragePools(), filter), null); - } - - /** - * Retrieve the list of storage pools in this device from Abiquo database (may not be - * synchronized with the device). - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return Unsynchronized list of storage pools in this device. - */ - public List listStoragePools() - { - StoragePoolsDto storagePools = - context.getApi().getInfrastructureApi() - .listStoragePools(target, StoragePoolOptions.builder().sync(false).build()); - return wrap(context, StoragePool.class, storagePools.getCollection()); - } - - /** - * Retrieve a filtered list of storage pools in this device from Abiquo database (may not be - * synchronized with the device). - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return Filtered unsynchronized list of storage pools in this device. - */ - public List listStoragePools(final Predicate filter) - { - return Lists.newLinkedList(filter(listStoragePools(), filter)); - } - - /** - * Retrieve the first storage pool matching the filter within the list of storage pools in this - * device (unsynchronized with the device). - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return First storage pool (unsynchronized) matching the filter or null if there - * is none. - */ - public StoragePool findStoragePool(final Predicate filter) - { - return Iterables.getFirst(filter(listStoragePools(), filter), null); - } - - /** - * Retrieve a single storage pool in this device from Abiquo database. - * - * @param id Unique ID of the storage device in this datacenter. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievearegisteredpool - * @return Storage pool with the given id or null if it does not exist. - */ - public StoragePool getStoragePool(final String id) - { - StoragePoolDto storagePool = - context.getApi().getInfrastructureApi().getStoragePool(target, id); - return wrap(context, StoragePool.class, storagePool); - } - - /** - * Retrieve the list of tiers in the datacenter using this device. - * - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers - * - * @return List of tiers in the datacenter using this device. - */ - public List listTiersFromDatacenter() - { - DatacenterDto datacenter; - - if (this.datacenter == null) - { - datacenter = new DatacenterDto(); - datacenter.setId(target.getIdFromLink(ParentLinkName.DATACENTER)); - } - else - { - datacenter = this.getDatacenter().unwrap(); - } - - TiersDto dto = context.getApi().getInfrastructureApi().listTiers(datacenter); - return DomainWrapper.wrap(context, Tier.class, dto.getCollection()); - } - - /** - * Retrieve a filtered list of tiers in the datacenter using this device. - * - * @param filter Filter to be applied to the list. - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource#TierResource-Retrievethelistoftiers - * - * @return Filtered list of tiers in the datacenter using this device. - */ - public List listTiersFromDatacenter(final Predicate filter) - { - return Lists.newLinkedList(filter(listTiersFromDatacenter(), filter)); - } - - /** - * Retrieve the first tier matching the filter within the list of tiers in the datacenter. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrievethelistofstoragedevices - * @return First tier matching the filter or null if there is none. - */ - public Tier findTierInDatacenter(final Predicate filter) - { - return Iterables.getFirst(filter(listTiersFromDatacenter(), filter), null); - } - - public static Builder builder(final RestContext context, - final Datacenter datacenter) - { - return new Builder(context, datacenter); - } - - public static class Builder - { - private RestContext context; - - private Datacenter datacenter; - - private String iscsiIp; - - private Integer iscsiPort; - - private String managementIp; - - private Integer managementPort; - - private String name; - - private String password; - - private String type; - - private String username; - - public Builder(final RestContext context, - final Datacenter datacenter) - { - super(); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - this.context = context; - } - - public Builder datacenter(final Datacenter datacenter) - { - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - this.datacenter = datacenter; - return this; - } - - public Builder iscsiIp(final String iscsiIp) - { - this.iscsiIp = iscsiIp; - return this; - } - - public Builder iscsiPort(final int iscsiPort) - { - this.iscsiPort = iscsiPort; - return this; - } - - public Builder password(final String password) - { - this.password = password; - return this; - } - - public Builder name(final String name) - { - this.name = name; - return this; - } - - public Builder managementPort(final int managementPort) - { - this.managementPort = managementPort; - return this; - } - - public Builder managementIp(final String managementIp) - { - this.managementIp = managementIp; - return this; - } - - public Builder type(final String type) - { - this.type = type; - return this; - } - - public Builder username(final String username) - { - this.username = username; - return this; - } - - public StorageDevice build() - { - StorageDeviceDto dto = new StorageDeviceDto(); - dto.setIscsiIp(iscsiIp); - dto.setIscsiPort(iscsiPort); - dto.setManagementIp(managementIp); - dto.setManagementPort(managementPort); - dto.setName(name); - dto.setPassword(password); - dto.setStorageTechnology(type); - dto.setUsername(username); - StorageDevice storageDevice = new StorageDevice(context, dto); - storageDevice.datacenter = datacenter; - return storageDevice; - } - - public static Builder fromStorageDevice(final StorageDevice in) - { - Builder builder = - StorageDevice.builder(in.context, in.getDatacenter()).iscsiIp(in.getIscsiIp()) - .iscsiPort(in.getIscsiPort()).managementIp(in.getManagementIp()) - .managementPort(in.getManagementPort()).name(in.getName()) - .password(in.getPassword()).type(in.getType()).username(in.getUsername()); - - return builder; - } - } - - // Delegate methods - - public Integer getId() - { - return target.getId(); - } - - public String getIscsiIp() - { - return target.getIscsiIp(); - } - - public int getIscsiPort() - { - return target.getIscsiPort(); - } - - public String getManagementIp() - { - return target.getManagementIp(); - } - - public int getManagementPort() - { - return target.getManagementPort(); - } - - public String getName() - { - return target.getName(); - } - - public String getPassword() - { - return target.getPassword(); - } - - public String getType() - { - return target.getStorageTechnology(); - } - - public String getUsername() - { - return target.getUsername(); - } - - public void setIscsiIp(final String iscsiIp) - { - target.setIscsiIp(iscsiIp); - } - - public void setIscsiPort(final int iscsiPort) - { - target.setIscsiPort(iscsiPort); - } - - public void setManagementIp(final String managementIp) - { - target.setManagementIp(managementIp); - } - - public void setManagementPort(final int managementPort) - { - target.setManagementPort(managementPort); - } - - public void setName(final String name) - { - target.setName(name); - } - - public void setPassword(final String password) - { - target.setPassword(password); - } - - public void setType(final String type) - { - target.setStorageTechnology(type); - } - - public void setUsername(final String username) - { - target.setUsername(username); - } - - @Override - public String toString() - { - return "StorageDevice [id=" + getId() + ", iscsiIp=" + getIscsiIp() + ", iscsiPort=" - + getIscsiPort() + ", managementIp=" + getManagementIp() + ", managementPort=" - + getManagementPort() + ", name=" + getName() + ", password=" + getPassword() - + ", type=" + getType() + ", user=" + getUsername() + "]"; - } +public class StorageDevice extends DomainWrapper { + /** The datacenter where the storage device is. */ + private Datacenter datacenter; + + /** + * Constructor to be used only by the builder. + */ + protected StorageDevice(final RestContext context, final StorageDeviceDto target) { + super(context, target); + } + + /** + * Delete the storage device. + * + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Deleteastoragedevice + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteStorageDevice(target); + target = null; + } + + /** + * Create a new storage device. + * + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Createastoragedevice + */ + public void save() { + target = context.getApi().getInfrastructureApi().createStorageDevice(datacenter.unwrap(), target); + } + + /** + * Update storage device information in the server with the data from this + * device. + * + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Updateastoragedevice + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateStorageDevice(target); + } + + // Parent access + + /** + * Retrieve the datacenter where this storage device is. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveadatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); + datacenter = wrap(context, Datacenter.class, dto); + return datacenter; + } + + // Children access + + /** + * Retrieve the list of storage pools in this device (synchronized with the + * device). + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return Synchronized list of storage pools in this device. + */ + public List listRemoteStoragePools() { + StoragePoolsDto storagePools = context.getApi().getInfrastructureApi() + .listStoragePools(target, StoragePoolOptions.builder().sync(true).build()); + + List storagePoolList = wrap(context, StoragePool.class, storagePools.getCollection()); + + for (StoragePool storagePool : storagePoolList) { + storagePool.storageDevice = this; + } + + return storagePoolList; + } + + /** + * Retrieve a filtered list of storage pools in this device (synchronized + * with the device). + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return Filtered synchronized list of storage pools in this device. + */ + public List listRemoteStoragePools(final Predicate filter) { + return Lists.newLinkedList(filter(listRemoteStoragePools(), filter)); + } + + /** + * Retrieve the first storage pool matching the filter within the list of + * storage pools in this device (synchronized with the device). + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return First storage pool (synchronized) matching the filter or + * null if there is none. + */ + public StoragePool findRemoteStoragePool(final Predicate filter) { + return Iterables.getFirst(filter(listRemoteStoragePools(), filter), null); + } + + /** + * Retrieve the list of storage pools in this device from Abiquo database + * (may not be synchronized with the device). + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return Unsynchronized list of storage pools in this device. + */ + public List listStoragePools() { + StoragePoolsDto storagePools = context.getApi().getInfrastructureApi() + .listStoragePools(target, StoragePoolOptions.builder().sync(false).build()); + return wrap(context, StoragePool.class, storagePools.getCollection()); + } + + /** + * Retrieve a filtered list of storage pools in this device from Abiquo + * database (may not be synchronized with the device). + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return Filtered unsynchronized list of storage pools in this device. + */ + public List listStoragePools(final Predicate filter) { + return Lists.newLinkedList(filter(listStoragePools(), filter)); + } + + /** + * Retrieve the first storage pool matching the filter within the list of + * storage pools in this device (unsynchronized with the device). + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return First storage pool (unsynchronized) matching the filter or + * null if there is none. + */ + public StoragePool findStoragePool(final Predicate filter) { + return Iterables.getFirst(filter(listStoragePools(), filter), null); + } + + /** + * Retrieve a single storage pool in this device from Abiquo database. + * + * @param id + * Unique ID of the storage device in this datacenter. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievearegisteredpool + * @return Storage pool with the given id or null if it does not + * exist. + */ + public StoragePool getStoragePool(final String id) { + StoragePoolDto storagePool = context.getApi().getInfrastructureApi().getStoragePool(target, id); + return wrap(context, StoragePool.class, storagePool); + } + + /** + * Retrieve the list of tiers in the datacenter using this device. + * + * @see API: + * http://community.abiquo.com/display/ABI20/TierResource#TierResource- + * Retrievethelistoftiers + * @return List of tiers in the datacenter using this device. + */ + public List listTiersFromDatacenter() { + DatacenterDto datacenter; + + if (this.datacenter == null) { + datacenter = new DatacenterDto(); + datacenter.setId(target.getIdFromLink(ParentLinkName.DATACENTER)); + } else { + datacenter = this.getDatacenter().unwrap(); + } + + TiersDto dto = context.getApi().getInfrastructureApi().listTiers(datacenter); + return DomainWrapper.wrap(context, Tier.class, dto.getCollection()); + } + + /** + * Retrieve a filtered list of tiers in the datacenter using this device. + * + * @param filter + * Filter to be applied to the list. + * @see API: + * http://community.abiquo.com/display/ABI20/TierResource#TierResource- + * Retrievethelistoftiers + * @return Filtered list of tiers in the datacenter using this device. + */ + public List listTiersFromDatacenter(final Predicate filter) { + return Lists.newLinkedList(filter(listTiersFromDatacenter(), filter)); + } + + /** + * Retrieve the first tier matching the filter within the list of tiers in + * the datacenter. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrievethelistofstoragedevices + * @return First tier matching the filter or null if there is + * none. + */ + public Tier findTierInDatacenter(final Predicate filter) { + return Iterables.getFirst(filter(listTiersFromDatacenter(), filter), null); + } + + public static Builder builder(final RestContext context, final Datacenter datacenter) { + return new Builder(context, datacenter); + } + + public static class Builder { + private RestContext context; + + private Datacenter datacenter; + + private String iscsiIp; + + private Integer iscsiPort; + + private String managementIp; + + private Integer managementPort; + + private String name; + + private String password; + + private String type; + + private String username; + + public Builder(final RestContext context, final Datacenter datacenter) { + super(); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + this.context = context; + } + + public Builder datacenter(final Datacenter datacenter) { + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + this.datacenter = datacenter; + return this; + } + + public Builder iscsiIp(final String iscsiIp) { + this.iscsiIp = iscsiIp; + return this; + } + + public Builder iscsiPort(final int iscsiPort) { + this.iscsiPort = iscsiPort; + return this; + } + + public Builder password(final String password) { + this.password = password; + return this; + } + + public Builder name(final String name) { + this.name = name; + return this; + } + + public Builder managementPort(final int managementPort) { + this.managementPort = managementPort; + return this; + } + + public Builder managementIp(final String managementIp) { + this.managementIp = managementIp; + return this; + } + + public Builder type(final String type) { + this.type = type; + return this; + } + + public Builder username(final String username) { + this.username = username; + return this; + } + + public StorageDevice build() { + StorageDeviceDto dto = new StorageDeviceDto(); + dto.setIscsiIp(iscsiIp); + dto.setIscsiPort(iscsiPort); + dto.setManagementIp(managementIp); + dto.setManagementPort(managementPort); + dto.setName(name); + dto.setPassword(password); + dto.setStorageTechnology(type); + dto.setUsername(username); + StorageDevice storageDevice = new StorageDevice(context, dto); + storageDevice.datacenter = datacenter; + return storageDevice; + } + + public static Builder fromStorageDevice(final StorageDevice in) { + Builder builder = StorageDevice.builder(in.context, in.getDatacenter()).iscsiIp(in.getIscsiIp()) + .iscsiPort(in.getIscsiPort()).managementIp(in.getManagementIp()).managementPort(in.getManagementPort()) + .name(in.getName()).password(in.getPassword()).type(in.getType()).username(in.getUsername()); + + return builder; + } + } + + // Delegate methods + + public Integer getId() { + return target.getId(); + } + + public String getIscsiIp() { + return target.getIscsiIp(); + } + + public int getIscsiPort() { + return target.getIscsiPort(); + } + + public String getManagementIp() { + return target.getManagementIp(); + } + + public int getManagementPort() { + return target.getManagementPort(); + } + + public String getName() { + return target.getName(); + } + + public String getPassword() { + return target.getPassword(); + } + + public String getType() { + return target.getStorageTechnology(); + } + + public String getUsername() { + return target.getUsername(); + } + + public void setIscsiIp(final String iscsiIp) { + target.setIscsiIp(iscsiIp); + } + + public void setIscsiPort(final int iscsiPort) { + target.setIscsiPort(iscsiPort); + } + + public void setManagementIp(final String managementIp) { + target.setManagementIp(managementIp); + } + + public void setManagementPort(final int managementPort) { + target.setManagementPort(managementPort); + } + + public void setName(final String name) { + target.setName(name); + } + + public void setPassword(final String password) { + target.setPassword(password); + } + + public void setType(final String type) { + target.setStorageTechnology(type); + } + + public void setUsername(final String username) { + target.setUsername(username); + } + + @Override + public String toString() { + return "StorageDevice [id=" + getId() + ", iscsiIp=" + getIscsiIp() + ", iscsiPort=" + getIscsiPort() + + ", managementIp=" + getManagementIp() + ", managementPort=" + getManagementPort() + ", name=" + getName() + + ", password=" + getPassword() + ", type=" + getType() + ", user=" + getUsername() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java index 853b8d95bb..2e4e436221 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceMetadata.java @@ -31,37 +31,31 @@ import com.abiquo.server.core.infrastructure.storage.StorageDeviceMetadataDto; * * @author Ignasi Barrera */ -public class StorageDeviceMetadata extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected StorageDeviceMetadata(final RestContext context, - final StorageDeviceMetadataDto target) - { - super(context, target); - } +public class StorageDeviceMetadata extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected StorageDeviceMetadata(final RestContext context, + final StorageDeviceMetadataDto target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public String getType() - { - return target.getType(); - } + public String getType() { + return target.getType(); + } - public int getDefaultManagementPort() - { - return target.getDefaultManagementPort(); - } + public int getDefaultManagementPort() { + return target.getDefaultManagementPort(); + } - public int getDefaultIscsiPort() - { - return target.getDefaultIscsiPort(); - } + public int getDefaultIscsiPort() { + return target.getDefaultIscsiPort(); + } - public boolean requiresAuthentication() - { - return target.isRequiresAuthentication(); - } + public boolean requiresAuthentication() { + return target.isRequiresAuthentication(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java index 579e0c40bd..5468bde79d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/StoragePool.java @@ -41,336 +41,314 @@ import com.abiquo.server.core.infrastructure.storage.TierDto; import com.google.inject.TypeLiteral; /** - * Adds high level functionality to {@link StoragePoolDto}. The Storage Pool Resource allows you to - * perform any administrative task for remote pools. + * Adds high level functionality to {@link StoragePoolDto}. The Storage Pool + * Resource allows you to perform any administrative task for remote pools. * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: + * @see API: * http://community.abiquo.com/display/ABI20/StoragePoolResource */ @EnterpriseEdition -public class StoragePool extends DomainWrapper -{ - /** The default value for the used space. */ - private static final long DEFAULT_USED_SIZE = 0; +public class StoragePool extends DomainWrapper { + /** The default value for the used space. */ + private static final long DEFAULT_USED_SIZE = 0; - /** The datacenter where the storage device is. */ - // Package protected to allow the storage device to be set automatically when discovering the - // pools in a device. - StorageDevice storageDevice; + /** The datacenter where the storage device is. */ + // Package protected to allow the storage device to be set automatically when + // discovering the + // pools in a device. + StorageDevice storageDevice; - /** - * Constructor to be used only by the builder. - */ - protected StoragePool(final RestContext context, final StoragePoolDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected StoragePool(final RestContext context, final StoragePoolDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Delete the storage pool. - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Deleteastoragepool - */ - public void delete() - { - context.getApi().getInfrastructureApi().deleteStoragePool(target); - target = null; - } + /** + * Delete the storage pool. + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Deleteastoragepool + */ + public void delete() { + context.getApi().getInfrastructureApi().deleteStoragePool(target); + target = null; + } - /** - * Create a storage pool. Create a storage pool means registering an existing storage pool - * obtained from {@link StorageDevice#listRemoteStoragePools} method and saving it. The Storage - * Pools must be associated with a Tier using {@link #setTier}. - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Createastoragepoolwithatierlink - */ - public void save() - { - target = - context.getApi().getInfrastructureApi() - .createStoragePool(storageDevice.unwrap(), target); - } + /** + * Create a storage pool. Create a storage pool means registering an existing + * storage pool obtained from {@link StorageDevice#listRemoteStoragePools} + * method and saving it. The Storage Pools must be associated with a Tier + * using {@link #setTier}. + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Createastoragepoolwithatierlink + */ + public void save() { + target = context.getApi().getInfrastructureApi().createStoragePool(storageDevice.unwrap(), target); + } - /** - * Update pool information in the server with the data from this pool. Storage pool parameters - * cannot be updated by a user, so the parameters are only a representation of the remote pool. - * Although the whole storage pool entity is sent to the API in the update call, the only thing - * a user can change is the tier that the pool belongs to by calling {@link #setTier}. - * - * @see API: http://community.abiquo.com/display/ABI20/Storage+Pool+Resource#StoragePoolResource- - * UpdateaStoragePool - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateStoragePool(target); - } + /** + * Update pool information in the server with the data from this pool. + * Storage pool parameters cannot be updated by a user, so the parameters are + * only a representation of the remote pool. Although the whole storage pool + * entity is sent to the API in the update call, the only thing a user can + * change is the tier that the pool belongs to by calling {@link #setTier}. + * + * @see API: http://community.abiquo.com/display/ABI20/Storage+Pool+Resource# + * StoragePoolResource- UpdateaStoragePool + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateStoragePool(target); + } - public void refresh() - { - target = - context.getApi().getInfrastructureApi() - .refreshStoragePool(target, StoragePoolOptions.builder().sync(true).build()); - } + public void refresh() { + target = context.getApi().getInfrastructureApi() + .refreshStoragePool(target, StoragePoolOptions.builder().sync(true).build()); + } - /** - * Define the tier in which the pool will be added. - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Createastoragepoolwithatierlink - */ - public void setTier(final Tier tier) - { - checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Privilege.class); - checkNotNull(tier.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Tier.class); + /** + * Define the tier in which the pool will be added. + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Createastoragepoolwithatierlink + */ + public void setTier(final Tier tier) { + checkNotNull(tier, ValidationErrors.NULL_RESOURCE + Privilege.class); + checkNotNull(tier.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Tier.class); - this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit"); - } + this.updateLink(target, ParentLinkName.TIER, tier.unwrap(), "edit"); + } - // Parent access + // Parent access - /** - * Get the device where the pool belongs. - * - * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource#StorageDeviceResource- - * Retrieveastoragedevice - */ - public StorageDevice getStorageDevice() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.STORAGE_DEVICE), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.STORAGE_DEVICE); + /** + * Get the device where the pool belongs. + * + * @see API: http://community.abiquo.com/display/ABI20/StorageDeviceResource# + * StorageDeviceResource- Retrieveastoragedevice + */ + public StorageDevice getStorageDevice() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.STORAGE_DEVICE), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.STORAGE_DEVICE); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(StorageDeviceDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(StorageDeviceDto.class)); - return wrap(context, StorageDevice.class, parser.apply(response)); - } + return wrap(context, StorageDevice.class, parser.apply(response)); + } - // Children access + // Children access - /** - * Get the tier assigned to the pool. The storage pool needs to be persisted in Abiquo first. - * - * @return The tier assinged to this storage pool. - */ - public Tier getTier() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.TIER), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.TIER); + /** + * Get the tier assigned to the pool. The storage pool needs to be persisted + * in Abiquo first. + * + * @return The tier assinged to this storage pool. + */ + public Tier getTier() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.TIER), ValidationErrors.MISSING_REQUIRED_LINK + " " + + ParentLinkName.TIER); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(TierDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), TypeLiteral.get(TierDto.class)); - return wrap(context, Tier.class, parser.apply(response)); - } + return wrap(context, Tier.class, parser.apply(response)); + } - // Builder + // Builder - public static Builder builder(final RestContext context, final StorageDevice storageDevice) - { - return new Builder(context, storageDevice); - } + public static Builder builder(final RestContext context, final StorageDevice storageDevice) { + return new Builder(context, storageDevice); + } - public static class Builder - { - private RestContext context; + public static class Builder { + private RestContext context; - private StorageDevice storageDevice; + private StorageDevice storageDevice; - private Long availableSizeInMb; + private Long availableSizeInMb; - // The enabled flag is still not used. It will be added when Abiquo includes anstorage - // allocator + // The enabled flag is still not used. It will be added when Abiquo + // includes anstorage + // allocator - // private Boolean enabled; + // private Boolean enabled; - private String name; + private String name; - private Long totalSizeInMb; + private Long totalSizeInMb; - private Long usedSizeInMb = DEFAULT_USED_SIZE; + private Long usedSizeInMb = DEFAULT_USED_SIZE; - public Builder(final RestContext context, final StorageDevice storageDevice) - { - super(); - checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class); - this.storageDevice = storageDevice; - this.context = context; - } + public Builder(final RestContext context, final StorageDevice storageDevice) { + super(); + checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class); + this.storageDevice = storageDevice; + this.context = context; + } - public Builder storageDevice(final StorageDevice storageDevice) - { - checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class); - this.storageDevice = storageDevice; - return this; - } + public Builder storageDevice(final StorageDevice storageDevice) { + checkNotNull(storageDevice, ValidationErrors.NULL_RESOURCE + StorageDevice.class); + this.storageDevice = storageDevice; + return this; + } - /** - * @deprecated This value is no longer used in Abiquo and will be removed in future - * versions. - */ - @Deprecated - public Builder availableSizeInMb(final long availableSizeInMb) - { - this.availableSizeInMb = availableSizeInMb; - return this; - } + /** + * @deprecated This value is no longer used in Abiquo and will be removed + * in future versions. + */ + @Deprecated + public Builder availableSizeInMb(final long availableSizeInMb) { + this.availableSizeInMb = availableSizeInMb; + return this; + } - public Builder name(final String name) - { - this.name = name; - return this; - } + public Builder name(final String name) { + this.name = name; + return this; + } - // The enabled flag is still not used. It will be added when Abiquo includes anstorage - // allocator + // The enabled flag is still not used. It will be added when Abiquo + // includes anstorage + // allocator - // public Builder enabled(final boolean enabled) - // { - // this.enabled = enabled; - // return this; - // } + // public Builder enabled(final boolean enabled) + // { + // this.enabled = enabled; + // return this; + // } - public Builder totalSizeInMb(final long totalSizeInMb) - { - this.totalSizeInMb = totalSizeInMb; - if (availableSizeInMb == null) - { - availableSizeInMb = totalSizeInMb; - } - return this; - } + public Builder totalSizeInMb(final long totalSizeInMb) { + this.totalSizeInMb = totalSizeInMb; + if (availableSizeInMb == null) { + availableSizeInMb = totalSizeInMb; + } + return this; + } - /** - * @deprecated This value is no longer used in Abiquo and will be removed in future - * versions. - */ - @Deprecated - public Builder usedSizeInMb(final long usedSizeInMb) - { - this.usedSizeInMb = usedSizeInMb; - return this; - } + /** + * @deprecated This value is no longer used in Abiquo and will be removed + * in future versions. + */ + @Deprecated + public Builder usedSizeInMb(final long usedSizeInMb) { + this.usedSizeInMb = usedSizeInMb; + return this; + } - public StoragePool build() - { - StoragePoolDto dto = new StoragePoolDto(); - dto.setAvailableSizeInMb(availableSizeInMb); + public StoragePool build() { + StoragePoolDto dto = new StoragePoolDto(); + dto.setAvailableSizeInMb(availableSizeInMb); - // The enabled flag is still not used. It will be added when Abiquo includes anstorage - // allocator - // dto.setEnabled(enabled); + // The enabled flag is still not used. It will be added when Abiquo + // includes anstorage + // allocator + // dto.setEnabled(enabled); - dto.setName(name); - dto.setTotalSizeInMb(totalSizeInMb); - dto.setUsedSizeInMb(usedSizeInMb); - StoragePool storagePool = new StoragePool(context, dto); - storagePool.storageDevice = storageDevice; - return storagePool; - } + dto.setName(name); + dto.setTotalSizeInMb(totalSizeInMb); + dto.setUsedSizeInMb(usedSizeInMb); + StoragePool storagePool = new StoragePool(context, dto); + storagePool.storageDevice = storageDevice; + return storagePool; + } - public static Builder fromStoragePool(final StoragePool in) - { - Builder builder = - StoragePool.builder(in.context, in.getStorageDevice()) - .availableSizeInMb(in.getAvailableSizeInMb())/* .enabled(in.getEnabled()) */ - .totalSizeInMb(in.getTotalSizeInMb()).usedSizeInMb(in.getUsedSizeInMb()); + public static Builder fromStoragePool(final StoragePool in) { + Builder builder = StoragePool.builder(in.context, in.getStorageDevice()) + .availableSizeInMb(in.getAvailableSizeInMb())/* + * .enabled(in. + * getEnabled()) + */ + .totalSizeInMb(in.getTotalSizeInMb()).usedSizeInMb(in.getUsedSizeInMb()); - return builder; - } - } + return builder; + } + } - // Delegate methods + // Delegate methods - /** - * @deprecated This value is no longer used in Abiquo and will be removed in future versions. - */ - @Deprecated - public long getAvailableSizeInMb() - { - return target.getAvailableSizeInMb(); - } + /** + * @deprecated This value is no longer used in Abiquo and will be removed in + * future versions. + */ + @Deprecated + public long getAvailableSizeInMb() { + return target.getAvailableSizeInMb(); + } - // The enabled flag is still not used. It will be added when Abiquo includes anstorage - // allocator + // The enabled flag is still not used. It will be added when Abiquo includes + // anstorage + // allocator - // public boolean getEnabled() - // { - // return target.getEnabled(); - // } + // public boolean getEnabled() + // { + // return target.getEnabled(); + // } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public long getTotalSizeInMb() - { - return target.getTotalSizeInMb(); - } + public long getTotalSizeInMb() { + return target.getTotalSizeInMb(); + } - /** - * @deprecated This value is no longer used in Abiquo and will be removed in future versions. - */ - @Deprecated - public long getUsedSizeInMb() - { - return target.getUsedSizeInMb(); - } + /** + * @deprecated This value is no longer used in Abiquo and will be removed in + * future versions. + */ + @Deprecated + public long getUsedSizeInMb() { + return target.getUsedSizeInMb(); + } - // The enabled flag is still not used. It will be added when Abiquo includes anstorage - // allocator + // The enabled flag is still not used. It will be added when Abiquo includes + // anstorage + // allocator - // public void setEnabled(final boolean enabled) - // { - // target.setEnabled(enabled); - // } + // public void setEnabled(final boolean enabled) + // { + // target.setEnabled(enabled); + // } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setTotalSizeInMb(final long totalSizeInMb) - { - target.setTotalSizeInMb(totalSizeInMb); - } + public void setTotalSizeInMb(final long totalSizeInMb) { + target.setTotalSizeInMb(totalSizeInMb); + } - // Readonly property - public String getUUID() - { - return target.getIdStorage(); - } + // Readonly property + public String getUUID() { + return target.getIdStorage(); + } - @Override - public String toString() - { - return "StoragePool [name=" + getName() + ", totalSizeInMb=" + getTotalSizeInMb() - + ", uuid=" + getUUID() + "]"; - } + @Override + public String toString() { + return "StoragePool [name=" + getName() + ", totalSizeInMb=" + getTotalSizeInMb() + ", uuid=" + getUUID() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java index c39db98d54..f8c8aa0e4d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/Tier.java @@ -38,10 +38,10 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; /** - * Adds high level functionality to {@link TierDto}. The Tier Resource offers the functionality of - * managing the logic of QoS volume management. These are only logical levels of QoS and the real - * QoS (networking speed, volume replication, availability) must be configured manually in the - * infrastructure. + * Adds high level functionality to {@link TierDto}. The Tier Resource offers + * the functionality of managing the logic of QoS volume management. These are + * only logical levels of QoS and the real QoS (networking speed, volume + * replication, availability) must be configured manually in the infrastructure. * * @author Ignasi Barrera * @author Francesc Montserrat @@ -49,139 +49,129 @@ import com.google.common.collect.Lists; * http://community.abiquo.com/display/ABI20/TierResource */ @EnterpriseEdition -public class Tier extends DomainWrapper -{ - /** The datacenter where the tier belongs. */ - private Datacenter datacenter; +public class Tier extends DomainWrapper { + /** The datacenter where the tier belongs. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected Tier(final RestContext context, final TierDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected Tier(final RestContext context, final TierDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Update tier information in the server with the data from this tier. - * - * @see API: - * http://community.abiquo.com/display/ABI20/TierResource#TierResource-Updateatier - */ - public void update() - { - target = context.getApi().getInfrastructureApi().updateTier(target); - } + /** + * Update tier information in the server with the data from this tier. + * + * @see API: + * http://community.abiquo.com/display/ABI20/TierResource#TierResource- + * Updateatier + */ + public void update() { + target = context.getApi().getInfrastructureApi().updateTier(target); + } - /** - * Retrieve the list of storage pools in this tier. - * - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return List of storage pools in this tier. - */ - public List listStoragePools() - { - StoragePoolsDto storagePools = - context.getApi().getInfrastructureApi().listStoragePools(target); - return wrap(context, StoragePool.class, storagePools.getCollection()); - } + /** + * Retrieve the list of storage pools in this tier. + * + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return List of storage pools in this tier. + */ + public List listStoragePools() { + StoragePoolsDto storagePools = context.getApi().getInfrastructureApi().listStoragePools(target); + return wrap(context, StoragePool.class, storagePools.getCollection()); + } - /** - * Retrieve a filtered list of storage pools in this tier. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return Filtered list of storage pools in this tier. - */ - public List listStoragePools(final Predicate filter) - { - return Lists.newLinkedList(filter(listStoragePools(), filter)); - } + /** + * Retrieve a filtered list of storage pools in this tier. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return Filtered list of storage pools in this tier. + */ + public List listStoragePools(final Predicate filter) { + return Lists.newLinkedList(filter(listStoragePools(), filter)); + } - /** - * Retrieve the first storage pool matching the filter within the list of pools in this tier. - * - * @param filter Filter to be applied to the list. - * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource#StoragePoolResource- - * Retrievestoragepools - * @return First storage pool matching the filter or null if there is none. - */ - public StoragePool findStoragePool(final Predicate filter) - { - return Iterables.getFirst(filter(listStoragePools(), filter), null); - } + /** + * Retrieve the first storage pool matching the filter within the list of + * pools in this tier. + * + * @param filter + * Filter to be applied to the list. + * @see API: http://community.abiquo.com/display/ABI20/StoragePoolResource# + * StoragePoolResource- Retrievestoragepools + * @return First storage pool matching the filter or null if + * there is none. + */ + public StoragePool findStoragePool(final Predicate filter) { + return Iterables.getFirst(filter(listStoragePools(), filter), null); + } - // Parent access + // Parent access - /** - * Retrieve the datacenter where this tier is. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveadatacenter - */ - public Datacenter getDatacenter() - { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - datacenter = wrap(context, Datacenter.class, dto); - return datacenter; - } + /** + * Retrieve the datacenter where this tier is. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveadatacenter + */ + public Datacenter getDatacenter() { + Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); + DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); + datacenter = wrap(context, Datacenter.class, dto); + return datacenter; + } - // Delegate methods + // Delegate methods - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public boolean getEnabled() - { - return target.getEnabled(); - } + public boolean getEnabled() { + return target.getEnabled(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public void setDescription(final String description) - { - target.setDescription(description); - } + public void setDescription(final String description) { + target.setDescription(description); + } - public void setEnabled(final boolean enabled) - { - target.setEnabled(enabled); - } + public void setEnabled(final boolean enabled) { + target.setEnabled(enabled); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - @Override - public String toString() - { - return "Tier [id=" + getId() + ", description=" + getDescription() + ", enabled=" - + getEnabled() + ", name=" + getName() + "]"; - } + @Override + public String toString() { + return "Tier [id=" + getId() + ", description=" + getDescription() + ", enabled=" + getEnabled() + ", name=" + + getName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java index 11998cb5b0..d8d56358ee 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/DatacenterOptions.java @@ -26,39 +26,32 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class DatacenterOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class DatacenterOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - DatacenterOptions options = new DatacenterOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + DatacenterOptions options = new DatacenterOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private String ip; + public static class Builder { + private String ip; - public Builder ip(final String ip) - { - this.ip = ip; - return this; - } + public Builder ip(final String ip) { + this.ip = ip; + return this; + } - public DatacenterOptions build() - { - DatacenterOptions options = new DatacenterOptions(); - if (ip != null) - { - options.queryParameters.put("ip", ip); - } - return options; - } - } + public DatacenterOptions build() { + DatacenterOptions options = new DatacenterOptions(); + if (ip != null) { + options.queryParameters.put("ip", ip); + } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java index 4bcc60293f..4d691e1060 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/IpmiOptions.java @@ -26,43 +26,36 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author scastro */ -public class IpmiOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class IpmiOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - IpmiOptions options = new IpmiOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + IpmiOptions options = new IpmiOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private Integer port; + public static class Builder { + private Integer port; - /** - * Set the optional hypervisor port. - */ - public Builder port(final int port) - { - this.port = port; - return this; - } + /** + * Set the optional hypervisor port. + */ + public Builder port(final int port) { + this.port = port; + return this; + } - public IpmiOptions build() - { - IpmiOptions options = new IpmiOptions(); - if (port != null) - { - options.queryParameters.put("port", port.toString()); - } + public IpmiOptions build() { + IpmiOptions options = new IpmiOptions(); + if (port != null) { + options.queryParameters.put("port", port.toString()); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java index f29db2dc0f..bd37a73ba8 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/MachineOptions.java @@ -26,59 +26,50 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class MachineOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class MachineOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - MachineOptions options = new MachineOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + MachineOptions options = new MachineOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private Integer port; + public static class Builder { + private Integer port; - private Boolean sync; + private Boolean sync; - /** - * Set the optional hypervisor port. - */ - public Builder port(final int port) - { - this.port = port; - return this; - } + /** + * Set the optional hypervisor port. + */ + public Builder port(final int port) { + this.port = port; + return this; + } - /** - * Set the optional sync param. - */ - public Builder sync(final boolean sync) - { - this.sync = sync; - return this; - } + /** + * Set the optional sync param. + */ + public Builder sync(final boolean sync) { + this.sync = sync; + return this; + } - public MachineOptions build() - { - MachineOptions options = new MachineOptions(); - if (port != null) - { - options.queryParameters.put("port", port.toString()); - } + public MachineOptions build() { + MachineOptions options = new MachineOptions(); + if (port != null) { + options.queryParameters.put("port", port.toString()); + } - if (sync != null) - { - options.queryParameters.put("sync", sync.toString()); - } + if (sync != null) { + options.queryParameters.put("sync", sync.toString()); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java index af546ef991..77b73fe3b5 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/infrastructure/options/StoragePoolOptions.java @@ -29,43 +29,36 @@ import org.jclouds.http.options.BaseHttpRequestOptions; */ @EnterpriseEdition -public class StoragePoolOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class StoragePoolOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - StoragePoolOptions options = new StoragePoolOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + StoragePoolOptions options = new StoragePoolOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private Boolean sync; + public static class Builder { + private Boolean sync; - /** - * Set the optional sync param. - */ - public Builder sync(final boolean sync) - { - this.sync = sync; - return this; - } + /** + * Set the optional sync param. + */ + public Builder sync(final boolean sync) { + this.sync = sync; + return this; + } - public StoragePoolOptions build() - { - StoragePoolOptions options = new StoragePoolOptions(); - if (sync != null) - { - options.queryParameters.put("sync", sync.toString()); - } + public StoragePoolOptions build() { + StoragePoolOptions options = new StoragePoolOptions(); + if (sync != null) { + options.queryParameters.put("sync", sync.toString()); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java index c3da0e3f98..bda42fbbb9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/AbstractPublicIp.java @@ -31,38 +31,30 @@ import com.abiquo.server.core.infrastructure.network.AbstractInfrastructureIpDto * @author Ignasi Barrera * @author Francesc Montserrat */ -public abstract class AbstractPublicIp> - extends Ip -{ - /** - * Constructor to be used only by the builder. - */ - protected AbstractPublicIp(final RestContext context, - final T target) - { - super(context, target); - } +public abstract class AbstractPublicIp> extends Ip { + /** + * Constructor to be used only by the builder. + */ + protected AbstractPublicIp(final RestContext context, final T target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public boolean isAvailable() - { - return target.isAvailable(); - } + public boolean isAvailable() { + return target.isAvailable(); + } - public boolean isQuarantine() - { - return target.isQuarantine(); - } + public boolean isQuarantine() { + return target.isQuarantine(); + } - public void setAvailable(final boolean available) - { - target.setAvailable(available); - } + public void setAvailable(final boolean available) { + target.setAvailable(available); + } - public void setQuarantine(final boolean quarantine) - { - target.setQuarantine(quarantine); - } + public void setQuarantine(final boolean quarantine) { + target.setQuarantine(quarantine); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java index b881bf3a4f..1c546f4cab 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalIp.java @@ -42,48 +42,40 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class ExternalIp extends AbstractPublicIp -{ - /** - * Constructor to be used only by the builder. - */ - protected ExternalIp(final RestContext context, - final ExternalIpDto target) - { - super(context, target); - } +public class ExternalIp extends AbstractPublicIp { + /** + * Constructor to be used only by the builder. + */ + protected ExternalIp(final RestContext context, final ExternalIpDto target) { + super(context, target); + } - // Domain operations + // Domain operations - @Override - public ExternalNetwork getNetwork() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.EXTERNAL_NETWORK), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.EXTERNAL_NETWORK); + @Override + public ExternalNetwork getNetwork() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.EXTERNAL_NETWORK), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.EXTERNAL_NETWORK); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworkDto.class)); - return wrap(context, ExternalNetwork.class, parser.apply(response)); - } + return wrap(context, ExternalNetwork.class, parser.apply(response)); + } - @Override - public NetworkType getNetworkType() - { - return NetworkType.EXTERNAL; - } + @Override + public NetworkType getNetworkType() { + return NetworkType.EXTERNAL; + } - @Override - public String toString() - { - return "ExternalIp [networkType=" + getNetworkType() + ", available=" + isAvailable() - + ", quarantine=" + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" - + getMac() + ", name=" + getName() + ", networkName=" + getNetworkName() + "]"; - } + @Override + public String toString() { + return "ExternalIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine=" + + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName() + + ", networkName=" + getNetworkName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java index 8dfa92de70..a005666289 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/ExternalNetwork.java @@ -50,210 +50,180 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource */ @EnterpriseEdition -public class ExternalNetwork extends Network -{ - /** The datacenter where the network belongs. */ - private Datacenter datacenter; +public class ExternalNetwork extends Network { + /** The datacenter where the network belongs. */ + private Datacenter datacenter; - /** The enterprise where the network belongs. */ - private Enterprise enterprise; + /** The enterprise where the network belongs. */ + private Enterprise enterprise; - /** - * Constructor to be used only by the builder. - */ - protected ExternalNetwork(final RestContext context, - final VLANNetworkDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected ExternalNetwork(final RestContext context, final VLANNetworkDto target) { + super(context, target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -DeleteanExternalNetwork - */ - @Override - public void delete() - { - context.getApi().getInfrastructureApi().deleteNetwork(target); - target = null; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -DeleteanExternalNetwork + */ + @Override + public void delete() { + context.getApi().getInfrastructureApi().deleteNetwork(target); + target = null; + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -CreateanewExternalNetwork - */ - @Override - public void save() - { - this.addEnterpriseLink(); - target = - context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -CreateanewExternalNetwork + */ + @Override + public void save() { + this.addEnterpriseLink(); + target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -UpdateanExternalNetwork - */ - @Override - public void update() - { - target = context.getApi().getInfrastructureApi().updateNetwork(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -UpdateanExternalNetwork + */ + @Override + public void update() { + target = context.getApi().getInfrastructureApi().updateNetwork(target); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource#PublicIPsResource- - * ReturnthelistofIPsforaPublicNetwork - */ - @Override - public List listIps(final IpOptions options) - { - ExternalIpsDto ips = - context.getApi().getInfrastructureApi().listExternalIps(target, options); - return wrap(context, ExternalIp.class, ips.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource# + * PublicIPsResource- ReturnthelistofIPsforaPublicNetwork + */ + @Override + public List listIps(final IpOptions options) { + ExternalIpsDto ips = context.getApi().getInfrastructureApi().listExternalIps(target, options); + return wrap(context, ExternalIp.class, ips.getCollection()); + } - @Override - public ExternalIp getIp(final Integer id) - { - ExternalIpDto ip = context.getApi().getInfrastructureApi().getExternalIp(target, id); - return wrap(context, ExternalIp.class, ip); - } + @Override + public ExternalIp getIp(final Integer id) { + ExternalIpDto ip = context.getApi().getInfrastructureApi().getExternalIp(target, id); + return wrap(context, ExternalIp.class, ip); + } - // Parent access + // Parent access - public Enterprise getEnterprise() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.ENTERPRISE); + public Enterprise getEnterprise() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), ValidationErrors.MISSING_REQUIRED_LINK + + " " + ParentLinkName.ENTERPRISE); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(EnterpriseDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(EnterpriseDto.class)); - enterprise = wrap(context, Enterprise.class, parser.apply(response)); - return enterprise; - } + enterprise = wrap(context, Enterprise.class, parser.apply(response)); + return enterprise; + } - public Datacenter getDatacenter() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.DATACENTER), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.DATACENTER); + public Datacenter getDatacenter() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK + + " " + ParentLinkName.DATACENTER); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(DatacenterDto.class)); - datacenter = wrap(context, Datacenter.class, parser.apply(response)); - return datacenter; - } + datacenter = wrap(context, Datacenter.class, parser.apply(response)); + return datacenter; + } - private void addEnterpriseLink() - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Enterprise.class); + private void addEnterpriseLink() { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - RESTLink link = enterprise.unwrap().getEditLink(); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + RESTLink link = enterprise.unwrap().getEditLink(); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - target.addLink(new RESTLink("enterprise", link.getHref())); - } + target.addLink(new RESTLink("enterprise", link.getHref())); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - return new Builder(context, datacenter, enterprise); - } + public static Builder builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + return new Builder(context, datacenter, enterprise); + } - public static class Builder extends NetworkBuilder - { - private Datacenter datacenter; + public static class Builder extends NetworkBuilder { + private Datacenter datacenter; - private Enterprise enterprise; + private Enterprise enterprise; - public Builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - super(context); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.datacenter = datacenter; - this.enterprise = enterprise; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + super(context); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.datacenter = datacenter; + this.enterprise = enterprise; + this.context = context; + } - public Builder datacenter(final Datacenter datacenter) - { - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + this.datacenter = datacenter; + return this; + } - public Builder enterprise(final Enterprise enterprise) - { - this.enterprise = enterprise; - return this; - } + public Builder enterprise(final Enterprise enterprise) { + this.enterprise = enterprise; + return this; + } - public ExternalNetwork build() - { - VLANNetworkDto dto = new VLANNetworkDto(); - dto.setName(name); - dto.setTag(tag); - dto.setGateway(gateway); - dto.setAddress(address); - dto.setMask(mask); - dto.setPrimaryDNS(primaryDNS); - dto.setSecondaryDNS(secondaryDNS); - dto.setSufixDNS(sufixDNS); - dto.setDefaultNetwork(defaultNetwork == null ? Boolean.FALSE : defaultNetwork); - dto.setUnmanaged(Boolean.FALSE); - dto.setType(NetworkType.EXTERNAL); + public ExternalNetwork build() { + VLANNetworkDto dto = new VLANNetworkDto(); + dto.setName(name); + dto.setTag(tag); + dto.setGateway(gateway); + dto.setAddress(address); + dto.setMask(mask); + dto.setPrimaryDNS(primaryDNS); + dto.setSecondaryDNS(secondaryDNS); + dto.setSufixDNS(sufixDNS); + dto.setDefaultNetwork(defaultNetwork == null ? Boolean.FALSE : defaultNetwork); + dto.setUnmanaged(Boolean.FALSE); + dto.setType(NetworkType.EXTERNAL); - ExternalNetwork network = new ExternalNetwork(context, dto); - network.datacenter = datacenter; - network.enterprise = enterprise; + ExternalNetwork network = new ExternalNetwork(context, dto); + network.datacenter = datacenter; + network.enterprise = enterprise; - return network; - } + return network; + } - public static Builder fromExternalNetwork(final ExternalNetwork in) - { - return ExternalNetwork.builder(in.context, in.datacenter, in.enterprise) - .name(in.getName()).tag(in.getTag()).gateway(in.getGateway()) - .address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) - .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()) - .defaultNetwork(in.getDefaultNetwork()); - } - } + public static Builder fromExternalNetwork(final ExternalNetwork in) { + return ExternalNetwork.builder(in.context, in.datacenter, in.enterprise).name(in.getName()).tag(in.getTag()) + .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) + .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()).defaultNetwork(in.getDefaultNetwork()); + } + } - @Override - public String toString() - { - return "External " + super.toString(); - } + @Override + public String toString() { + return "External " + super.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java index ef39edfd5f..c4d683eb35 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Ip.java @@ -33,53 +33,45 @@ import com.abiquo.server.core.infrastructure.network.AbstractIpDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public abstract class Ip> extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Ip(final RestContext context, final T target) - { - super(context, target); - } +public abstract class Ip> extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Ip(final RestContext context, final T target) { + super(context, target); + } - // Domain operations + // Domain operations - public abstract N getNetwork(); + public abstract N getNetwork(); - public abstract NetworkType getNetworkType(); + public abstract NetworkType getNetworkType(); - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getIp() - { - return target.getIp(); - } + public String getIp() { + return target.getIp(); + } - public String getMac() - { - return target.getMac(); - } + public String getMac() { + return target.getMac(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getNetworkName() - { - return target.getNetworkName(); - } + public String getNetworkName() { + return target.getNetworkName(); + } - @Override - public String toString() - { - return "Ip [id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" - + getName() + ", networkName=" + getNetworkName() + "]"; - } + @Override + public String toString() { + return "Ip [id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName() + ", networkName=" + + getNetworkName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java index 8e700b647b..b4d373e806 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Network.java @@ -44,336 +44,286 @@ import com.google.common.collect.Lists; * @author Ignasi Barrera * @author Francesc Montserrat */ -public abstract class Network> extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected Network(final RestContext context, - final VLANNetworkDto target) - { - super(context, target); - } +public abstract class Network> extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected Network(final RestContext context, final VLANNetworkDto target) { + super(context, target); + } - // Domain operations + // Domain operations - public abstract void save(); + public abstract void save(); - public abstract void update(); + public abstract void update(); - public abstract void delete(); + public abstract void delete(); - public abstract List listIps(IpOptions options); + public abstract List listIps(IpOptions options); - public abstract T getIp(Integer id); + public abstract T getIp(Integer id); - public List listIps() - { - // Disable pagination by default - return listIps(IpOptions.builder().disablePagination().build()); - } + public List listIps() { + // Disable pagination by default + return listIps(IpOptions.builder().disablePagination().build()); + } - public List listIps(final Predicate filter) - { - return Lists.newLinkedList(filter(listIps(), filter)); - } + public List listIps(final Predicate filter) { + return Lists.newLinkedList(filter(listIps(), filter)); + } - public T findIp(final Predicate filter) - { - return Iterables.getFirst(filter(listIps(), filter), null); - } + public T findIp(final Predicate filter) { + return Iterables.getFirst(filter(listIps(), filter), null); + } - public List listUnusedIps() - { - return listIps(IpPredicates. notUsed()); - } + public List listUnusedIps() { + return listIps(IpPredicates. notUsed()); + } - public T findUnusedIp(final Predicate filter) - { - return Iterables.getFirst(filter(listUnusedIps(), filter), null); - } + public T findUnusedIp(final Predicate filter) { + return Iterables.getFirst(filter(listUnusedIps(), filter), null); + } - // Builder + // Builder - public static class NetworkBuilder> - { - protected RestContext context; + public static class NetworkBuilder> { + protected RestContext context; - protected String name; + protected String name; - protected Integer tag; + protected Integer tag; - protected String gateway; + protected String gateway; - protected String address; + protected String address; - protected Integer mask; + protected Integer mask; - protected String primaryDNS; + protected String primaryDNS; - protected String secondaryDNS; + protected String secondaryDNS; - protected String sufixDNS; + protected String sufixDNS; - protected Boolean defaultNetwork; + protected Boolean defaultNetwork; - public NetworkBuilder(final RestContext context) - { - super(); - this.context = context; - } + public NetworkBuilder(final RestContext context) { + super(); + this.context = context; + } - @SuppressWarnings("unchecked") - public T name(final String name) - { - this.name = name; - return (T) this; - } + @SuppressWarnings("unchecked") + public T name(final String name) { + this.name = name; + return (T) this; + } - @SuppressWarnings("unchecked") - public T tag(final Integer tag) - { - this.tag = tag; - return (T) this; - } + @SuppressWarnings("unchecked") + public T tag(final Integer tag) { + this.tag = tag; + return (T) this; + } - @SuppressWarnings("unchecked") - public T gateway(final String gateway) - { - this.gateway = gateway; - return (T) this; - } + @SuppressWarnings("unchecked") + public T gateway(final String gateway) { + this.gateway = gateway; + return (T) this; + } - @SuppressWarnings("unchecked") - public T address(final String address) - { - this.address = address; - return (T) this; - } + @SuppressWarnings("unchecked") + public T address(final String address) { + this.address = address; + return (T) this; + } - @SuppressWarnings("unchecked") - public T mask(final int mask) - { - this.mask = mask; - return (T) this; - } + @SuppressWarnings("unchecked") + public T mask(final int mask) { + this.mask = mask; + return (T) this; + } - @SuppressWarnings("unchecked") - public T primaryDNS(final String primaryDNS) - { - this.primaryDNS = primaryDNS; - return (T) this; - } + @SuppressWarnings("unchecked") + public T primaryDNS(final String primaryDNS) { + this.primaryDNS = primaryDNS; + return (T) this; + } - @SuppressWarnings("unchecked") - public T secondaryDNS(final String secondaryDNS) - { - this.secondaryDNS = secondaryDNS; - return (T) this; - } + @SuppressWarnings("unchecked") + public T secondaryDNS(final String secondaryDNS) { + this.secondaryDNS = secondaryDNS; + return (T) this; + } - @SuppressWarnings("unchecked") - public T sufixDNS(final String sufixDNS) - { - this.sufixDNS = sufixDNS; - return (T) this; - } + @SuppressWarnings("unchecked") + public T sufixDNS(final String sufixDNS) { + this.sufixDNS = sufixDNS; + return (T) this; + } - @SuppressWarnings("unchecked") - public T defaultNetwork(final Boolean defaultNetwork) - { - this.defaultNetwork = defaultNetwork; - return (T) this; - } - } + @SuppressWarnings("unchecked") + public T defaultNetwork(final Boolean defaultNetwork) { + this.defaultNetwork = defaultNetwork; + return (T) this; + } + } - public PrivateNetwork toPrivateNetwork() - { - checkArgument(target.getType().equals(NetworkType.INTERNAL), + public PrivateNetwork toPrivateNetwork() { + checkArgument(target.getType().equals(NetworkType.INTERNAL), ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - return wrap(context, PrivateNetwork.class, target); + return wrap(context, PrivateNetwork.class, target); - } + } - public ExternalNetwork toExternalNetwork() - { - checkArgument(target.getType().equals(NetworkType.EXTERNAL), + public ExternalNetwork toExternalNetwork() { + checkArgument(target.getType().equals(NetworkType.EXTERNAL), ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - return wrap(context, ExternalNetwork.class, target); + return wrap(context, ExternalNetwork.class, target); - } + } - public PublicNetwork toPublicNetwork() - { - checkArgument(target.getType().equals(NetworkType.PUBLIC), + public PublicNetwork toPublicNetwork() { + checkArgument(target.getType().equals(NetworkType.PUBLIC), ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - return wrap(context, PublicNetwork.class, target); + return wrap(context, PublicNetwork.class, target); - } + } - public UnmanagedNetwork toUnmanagedNetwork() - { - checkArgument(target.getType().equals(NetworkType.UNMANAGED), + public UnmanagedNetwork toUnmanagedNetwork() { + checkArgument(target.getType().equals(NetworkType.UNMANAGED), ValidationErrors.INVALID_NETWORK_TYPE + target.getType()); - return wrap(context, UnmanagedNetwork.class, target); + return wrap(context, UnmanagedNetwork.class, target); - } + } - // Delegate methods + // Delegate methods - public String getAddress() - { - return target.getAddress(); - } + public String getAddress() { + return target.getAddress(); + } - public Boolean getDefaultNetwork() - { - return target.getDefaultNetwork(); - } + public Boolean getDefaultNetwork() { + return target.getDefaultNetwork(); + } - public String getGateway() - { - return target.getGateway(); - } + public String getGateway() { + return target.getGateway(); + } - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public Integer getMask() - { - return target.getMask(); - } + public Integer getMask() { + return target.getMask(); + } - public String getName() - { - return target.getName(); - } + public String getName() { + return target.getName(); + } - public String getPrimaryDNS() - { - return target.getPrimaryDNS(); - } + public String getPrimaryDNS() { + return target.getPrimaryDNS(); + } - public String getSecondaryDNS() - { - return target.getSecondaryDNS(); - } + public String getSecondaryDNS() { + return target.getSecondaryDNS(); + } - public String getSufixDNS() - { - return target.getSufixDNS(); - } + public String getSufixDNS() { + return target.getSufixDNS(); + } - public Integer getTag() - { - return target.getTag(); - } + public Integer getTag() { + return target.getTag(); + } - public NetworkType getType() - { - return target.getType(); - } + public NetworkType getType() { + return target.getType(); + } - public void setAddress(final String address) - { - target.setAddress(address); - } + public void setAddress(final String address) { + target.setAddress(address); + } - public void setDefaultNetwork(final Boolean defaultNetwork) - { - target.setDefaultNetwork(defaultNetwork); - } + public void setDefaultNetwork(final Boolean defaultNetwork) { + target.setDefaultNetwork(defaultNetwork); + } - public void setGateway(final String gateway) - { - target.setGateway(gateway); - } + public void setGateway(final String gateway) { + target.setGateway(gateway); + } - public void setMask(final Integer mask) - { - target.setMask(mask); - } + public void setMask(final Integer mask) { + target.setMask(mask); + } - public void setName(final String name) - { - target.setName(name); - } + public void setName(final String name) { + target.setName(name); + } - public void setPrimaryDNS(final String primaryDNS) - { - target.setPrimaryDNS(primaryDNS); - } + public void setPrimaryDNS(final String primaryDNS) { + target.setPrimaryDNS(primaryDNS); + } - public void setSecondaryDNS(final String secondaryDNS) - { - target.setSecondaryDNS(secondaryDNS); - } + public void setSecondaryDNS(final String secondaryDNS) { + target.setSecondaryDNS(secondaryDNS); + } - public void setSufixDNS(final String sufixDNS) - { - target.setSufixDNS(sufixDNS); - } + public void setSufixDNS(final String sufixDNS) { + target.setSufixDNS(sufixDNS); + } - public void setTag(final Integer tag) - { - target.setTag(tag); - } + public void setTag(final Integer tag) { + target.setTag(tag); + } - @Override - public String toString() - { - return "Network [id=" + getId() + ", address=" + getAddress() + ", defaultNetwork=" - + getDefaultNetwork() + ", gateway=" + getGateway() + ", mask=" + getMask() + ", name=" - + getName() + ", primaryDNS=" + getPrimaryDNS() + ", secondaryDNS=" + getSecondaryDNS() - + ", suffixDNS=" + getSufixDNS() + ", tag=" + getTag() + ", type=" + getType() + "]"; - } + @Override + public String toString() { + return "Network [id=" + getId() + ", address=" + getAddress() + ", defaultNetwork=" + getDefaultNetwork() + + ", gateway=" + getGateway() + ", mask=" + getMask() + ", name=" + getName() + ", primaryDNS=" + + getPrimaryDNS() + ", secondaryDNS=" + getSecondaryDNS() + ", suffixDNS=" + getSufixDNS() + ", tag=" + + getTag() + ", type=" + getType() + "]"; + } - public static Network< ? > wrapNetwork( - final RestContext context, final VLANNetworkDto dto) - { - if (dto == null) - { - return null; - } + public static Network wrapNetwork(final RestContext context, final VLANNetworkDto dto) { + if (dto == null) { + return null; + } - Network< ? > network = null; + Network network = null; - switch (dto.getType()) - { - case EXTERNAL: - network = wrap(context, ExternalNetwork.class, dto); - break; - case EXTERNAL_UNMANAGED: - // TODO: How do we manage External && unmanaged networks ? - throw new UnsupportedOperationException("EXTERNAL_UNMANAGED networks not supported yet"); - case INTERNAL: - network = wrap(context, PrivateNetwork.class, dto); - break; - case PUBLIC: - network = wrap(context, PublicNetwork.class, dto); - break; - case UNMANAGED: - network = wrap(context, UnmanagedNetwork.class, dto); - break; - } + switch (dto.getType()) { + case EXTERNAL: + network = wrap(context, ExternalNetwork.class, dto); + break; + case EXTERNAL_UNMANAGED: + // TODO: How do we manage External && unmanaged networks ? + throw new UnsupportedOperationException("EXTERNAL_UNMANAGED networks not supported yet"); + case INTERNAL: + network = wrap(context, PrivateNetwork.class, dto); + break; + case PUBLIC: + network = wrap(context, PublicNetwork.class, dto); + break; + case UNMANAGED: + network = wrap(context, UnmanagedNetwork.class, dto); + break; + } - return network; - } + return network; + } - public static List> wrapNetworks( - final RestContext context, final List dtos) - { - List> networks = Lists.newLinkedList(); - for (VLANNetworkDto dto : dtos) - { - networks.add(wrapNetwork(context, dto)); - } - return networks; - } + public static List> wrapNetworks(final RestContext context, + final List dtos) { + List> networks = Lists.newLinkedList(); + for (VLANNetworkDto dto : dtos) { + networks.add(wrapNetwork(context, dto)); + } + return networks; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java index 78d7c3f295..91bfba17da 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.network; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -32,35 +31,32 @@ import com.abiquo.server.core.infrastructure.network.NicDto; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/VirtualMachineNetworkConfiguration + * @see API: http://community.abiquo.com/display/ABI20/ + * VirtualMachineNetworkConfiguration */ -public class Nic extends DomainWrapper -{ - /** - * Constructor to be used only by the builder (if any). - */ - protected Nic(final RestContext context, final NicDto target) - { - super(context, target); - } +public class Nic extends DomainWrapper { + /** + * Constructor to be used only by the builder (if any). + */ + protected Nic(final RestContext context, final NicDto target) { + super(context, target); + } - // Parent access + // Parent access - // Delegate methods + // Delegate methods - public Integer getId() - { - return target.getId(); - } + public Integer getId() { + return target.getId(); + } - public String getIp() - { - return target.getIp(); - } + public String getIp() { + return target.getIp(); + } - public String getMac() - { - return target.getMac(); - } + public String getMac() { + return target.getMac(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java index 1790551de4..afbd320f32 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java @@ -42,48 +42,39 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class PrivateIp extends Ip -{ - /** - * Constructor to be used only by the builder. - */ - protected PrivateIp(final RestContext context, - final PrivateIpDto target) - { - super(context, target); - } +public class PrivateIp extends Ip { + /** + * Constructor to be used only by the builder. + */ + protected PrivateIp(final RestContext context, final PrivateIpDto target) { + super(context, target); + } - // Domain operations + // Domain operations - @Override - public PrivateNetwork getNetwork() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.PRIVATE_NETWORK), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.PRIVATE_NETWORK); + @Override + public PrivateNetwork getNetwork() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.PRIVATE_NETWORK), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.PRIVATE_NETWORK); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworkDto.class)); - return wrap(context, PrivateNetwork.class, parser.apply(response)); - } + return wrap(context, PrivateNetwork.class, parser.apply(response)); + } - @Override - public NetworkType getNetworkType() - { - return NetworkType.INTERNAL; - } + @Override + public NetworkType getNetworkType() { + return NetworkType.INTERNAL; + } - @Override - public String toString() - { - return "PrivateIp [networkType=" + getNetworkType() + ", id=" + getId() + ", ip=" + getIp() - + ", mac=" + getMac() + ", name=" + getName() + ", networkName=" + getNetworkName() - + "]"; - } + @Override + public String toString() { + return "PrivateIp [networkType=" + getNetworkType() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + + ", name=" + getName() + ", networkName=" + getNetworkName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java index 4d4abedf63..55d900b93f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java @@ -37,157 +37,133 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource */ -public class PrivateNetwork extends Network -{ - /** The virtual datacenter where the network belongs. */ - private VirtualDatacenter virtualDatacenter; +public class PrivateNetwork extends Network { + /** The virtual datacenter where the network belongs. */ + private VirtualDatacenter virtualDatacenter; - /** - * Constructor to be used only by the builder. - */ - protected PrivateNetwork(final RestContext context, - final VLANNetworkDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected PrivateNetwork(final RestContext context, final VLANNetworkDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource - * -DeleteaPrivateNetwork - */ - @Override - public void delete() - { - context.getApi().getCloudApi().deletePrivateNetwork(target); - target = null; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource# + * PrivateNetworkResource -DeleteaPrivateNetwork + */ + @Override + public void delete() { + context.getApi().getCloudApi().deletePrivateNetwork(target); + target = null; + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource - * -CreateaPrivateNetwork - */ - @Override - public void save() - { - target = - context.getApi().getCloudApi() - .createPrivateNetwork(virtualDatacenter.unwrap(), target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource# + * PrivateNetworkResource -CreateaPrivateNetwork + */ + @Override + public void save() { + target = context.getApi().getCloudApi().createPrivateNetwork(virtualDatacenter.unwrap(), target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource - * -UpdateaPrivateNetwork - */ - @Override - public void update() - { - target = context.getApi().getCloudApi().updatePrivateNetwork(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource# + * PrivateNetworkResource -UpdateaPrivateNetwork + */ + @Override + public void update() { + target = context.getApi().getCloudApi().updatePrivateNetwork(target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource - * -RetrievethelistofIPSofthePrivateNetwork - */ - @Override - public List listIps(final IpOptions options) - { - PrivateIpsDto ips = - context.getApi().getCloudApi().listPrivateNetworkIps(target, options); - return wrap(context, PrivateIp.class, ips.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Private+Network+Resource# + * PrivateNetworkResource -RetrievethelistofIPSofthePrivateNetwork + */ + @Override + public List listIps(final IpOptions options) { + PrivateIpsDto ips = context.getApi().getCloudApi().listPrivateNetworkIps(target, options); + return wrap(context, PrivateIp.class, ips.getCollection()); + } - // Override to apply the filter in the server side - @Override - public List listUnusedIps() - { - IpOptions options = IpOptions.builder().disablePagination().free(true).build(); - PrivateIpsDto ips = - context.getApi().getCloudApi().listPrivateNetworkIps(target, options); - return wrap(context, PrivateIp.class, ips.getCollection()); - } + // Override to apply the filter in the server side + @Override + public List listUnusedIps() { + IpOptions options = IpOptions.builder().disablePagination().free(true).build(); + PrivateIpsDto ips = context.getApi().getCloudApi().listPrivateNetworkIps(target, options); + return wrap(context, PrivateIp.class, ips.getCollection()); + } - @Override - public PrivateIp getIp(final Integer id) - { - PrivateIpDto ip = context.getApi().getCloudApi().getPrivateNetworkIp(target, id); - return wrap(context, PrivateIp.class, ip); - } + @Override + public PrivateIp getIp(final Integer id) { + PrivateIpDto ip = context.getApi().getCloudApi().getPrivateNetworkIp(target, id); + return wrap(context, PrivateIp.class, ip); + } - // Builder + // Builder - public static Builder builder(final RestContext context) - { - return new Builder(context); - } + public static Builder builder(final RestContext context) { + return new Builder(context); + } - public static class Builder extends NetworkBuilder - { - private VirtualDatacenter virtualDatacenter; + public static class Builder extends NetworkBuilder { + private VirtualDatacenter virtualDatacenter; - public Builder(final RestContext context) - { - super(context); - this.context = context; - } + public Builder(final RestContext context) { + super(context); + this.context = context; + } - public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) - { - this.virtualDatacenter = virtualDatacenter; - return this; - } + public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) { + this.virtualDatacenter = virtualDatacenter; + return this; + } - public PrivateNetwork build() - { - VLANNetworkDto dto = new VLANNetworkDto(); - dto.setName(name); - dto.setTag(tag); - dto.setGateway(gateway); - dto.setAddress(address); - dto.setMask(mask); - dto.setPrimaryDNS(primaryDNS); - dto.setSecondaryDNS(secondaryDNS); - dto.setSufixDNS(sufixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(false); - dto.setType(NetworkType.INTERNAL); + public PrivateNetwork build() { + VLANNetworkDto dto = new VLANNetworkDto(); + dto.setName(name); + dto.setTag(tag); + dto.setGateway(gateway); + dto.setAddress(address); + dto.setMask(mask); + dto.setPrimaryDNS(primaryDNS); + dto.setSecondaryDNS(secondaryDNS); + dto.setSufixDNS(sufixDNS); + dto.setDefaultNetwork(defaultNetwork); + dto.setUnmanaged(false); + dto.setType(NetworkType.INTERNAL); - PrivateNetwork network = new PrivateNetwork(context, dto); - network.virtualDatacenter = virtualDatacenter; + PrivateNetwork network = new PrivateNetwork(context, dto); + network.virtualDatacenter = virtualDatacenter; - return network; - } + return network; + } - public static Builder fromPrivateNetwork(final PrivateNetwork in) - { - return PrivateNetwork.builder(in.context).name(in.getName()).tag(in.getTag()) - .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()) - .primaryDNS(in.getPrimaryDNS()).secondaryDNS(in.getSecondaryDNS()) - .sufixDNS(in.getSufixDNS()).defaultNetwork(in.getDefaultNetwork()) - .virtualDatacenter(in.virtualDatacenter); - } - } + public static Builder fromPrivateNetwork(final PrivateNetwork in) { + return PrivateNetwork.builder(in.context).name(in.getName()).tag(in.getTag()).gateway(in.getGateway()) + .address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) + .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()).defaultNetwork(in.getDefaultNetwork()) + .virtualDatacenter(in.virtualDatacenter); + } + } - @Override - public String toString() - { - return "Private " + super.toString(); - } + @Override + public String toString() { + return "Private " + super.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java index e2f0ebd0f3..c02418624d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java @@ -42,46 +42,38 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class PublicIp extends AbstractPublicIp -{ - /** - * Constructor to be used only by the builder. - */ - protected PublicIp(final RestContext context, - final PublicIpDto target) - { - super(context, target); - } +public class PublicIp extends AbstractPublicIp { + /** + * Constructor to be used only by the builder. + */ + protected PublicIp(final RestContext context, final PublicIpDto target) { + super(context, target); + } - @Override - public PublicNetwork getNetwork() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.PUBLIC_NETWORK), - ValidationErrors.MISSING_REQUIRED_LINK + ParentLinkName.PUBLIC_NETWORK); + @Override + public PublicNetwork getNetwork() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.PUBLIC_NETWORK), + ValidationErrors.MISSING_REQUIRED_LINK + ParentLinkName.PUBLIC_NETWORK); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworkDto.class)); - return wrap(context, PublicNetwork.class, parser.apply(response)); - } + return wrap(context, PublicNetwork.class, parser.apply(response)); + } - @Override - public NetworkType getNetworkType() - { - return NetworkType.PUBLIC; - } + @Override + public NetworkType getNetworkType() { + return NetworkType.PUBLIC; + } - @Override - public String toString() - { - return "PublicIp [networkType=" + getNetworkType() + ", available=" + isAvailable() - + ", quarantine=" + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" - + getMac() + ", name=" + getName() + ", networkName=" + getNetworkName() + "]"; - } + @Override + public String toString() { + return "PublicIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine=" + + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName() + + ", networkName=" + getNetworkName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java index 554166d80f..15a9d48d6d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java @@ -49,167 +49,141 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource */ @EnterpriseEdition -public class PublicNetwork extends Network -{ - /** The datacenter where the network belongs. */ - private Datacenter datacenter; +public class PublicNetwork extends Network { + /** The datacenter where the network belongs. */ + private Datacenter datacenter; - /** - * Constructor to be used only by the builder. - */ - protected PublicNetwork(final RestContext context, - final VLANNetworkDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected PublicNetwork(final RestContext context, final VLANNetworkDto target) { + super(context, target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -DeleteaPublicNetwork - */ - @Override - public void delete() - { - context.getApi().getInfrastructureApi().deleteNetwork(target); - target = null; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -DeleteaPublicNetwork + */ + @Override + public void delete() { + context.getApi().getInfrastructureApi().deleteNetwork(target); + target = null; + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -CreateanewPublicNetwork - */ - @Override - public void save() - { - target = - context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -CreateanewPublicNetwork + */ + @Override + public void save() { + target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -UpdateaPublicNetwork - */ - @Override - public void update() - { - target = context.getApi().getInfrastructureApi().updateNetwork(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -UpdateaPublicNetwork + */ + @Override + public void update() { + target = context.getApi().getInfrastructureApi().updateNetwork(target); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource#PublicIPsResource- - * ReturnthelistofIPsforaPublicNetwork - */ - @Override - public List listIps(final IpOptions options) - { - PublicIpsDto ips = - context.getApi().getInfrastructureApi().listPublicIps(target, options); - return wrap(context, PublicIp.class, ips.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource# + * PublicIPsResource- ReturnthelistofIPsforaPublicNetwork + */ + @Override + public List listIps(final IpOptions options) { + PublicIpsDto ips = context.getApi().getInfrastructureApi().listPublicIps(target, options); + return wrap(context, PublicIp.class, ips.getCollection()); + } - @Override - public PublicIp getIp(final Integer id) - { - PublicIpDto ip = context.getApi().getInfrastructureApi().getPublicIp(target, id); - return wrap(context, PublicIp.class, ip); - } + @Override + public PublicIp getIp(final Integer id) { + PublicIpDto ip = context.getApi().getInfrastructureApi().getPublicIp(target, id); + return wrap(context, PublicIp.class, ip); + } - // Parent access + // Parent access - public Datacenter getDatacenter() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.DATACENTER), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.DATACENTER); + public Datacenter getDatacenter() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK + + " " + ParentLinkName.DATACENTER); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(DatacenterDto.class)); - datacenter = wrap(context, Datacenter.class, parser.apply(response)); - return datacenter; - } + datacenter = wrap(context, Datacenter.class, parser.apply(response)); + return datacenter; + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Datacenter datacenter) - { - return new Builder(context, datacenter); - } + public static Builder builder(final RestContext context, final Datacenter datacenter) { + return new Builder(context, datacenter); + } - public static class Builder extends NetworkBuilder - { - private Datacenter datacenter; + public static class Builder extends NetworkBuilder { + private Datacenter datacenter; - public Builder(final RestContext context, - final Datacenter datacenter) - { - super(context); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.datacenter = datacenter; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter) { + super(context); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.datacenter = datacenter; + this.context = context; + } - public Builder datacenter(final Datacenter datacenter) - { - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + this.datacenter = datacenter; + return this; + } - public PublicNetwork build() - { - VLANNetworkDto dto = new VLANNetworkDto(); - dto.setName(name); - dto.setTag(tag); - dto.setGateway(gateway); - dto.setAddress(address); - dto.setMask(mask); - dto.setPrimaryDNS(primaryDNS); - dto.setSecondaryDNS(secondaryDNS); - dto.setSufixDNS(sufixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(false); - dto.setType(NetworkType.PUBLIC); + public PublicNetwork build() { + VLANNetworkDto dto = new VLANNetworkDto(); + dto.setName(name); + dto.setTag(tag); + dto.setGateway(gateway); + dto.setAddress(address); + dto.setMask(mask); + dto.setPrimaryDNS(primaryDNS); + dto.setSecondaryDNS(secondaryDNS); + dto.setSufixDNS(sufixDNS); + dto.setDefaultNetwork(defaultNetwork); + dto.setUnmanaged(false); + dto.setType(NetworkType.PUBLIC); - PublicNetwork network = new PublicNetwork(context, dto); - network.datacenter = datacenter; + PublicNetwork network = new PublicNetwork(context, dto); + network.datacenter = datacenter; - return network; - } + return network; + } - public static Builder fromPublicNetwork(final PublicNetwork in) - { - return PublicNetwork.builder(in.context, in.datacenter).name(in.getName()) - .tag(in.getTag()).gateway(in.getGateway()).address(in.getAddress()) - .mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) - .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()) - .defaultNetwork(in.getDefaultNetwork()); - } - } + public static Builder fromPublicNetwork(final PublicNetwork in) { + return PublicNetwork.builder(in.context, in.datacenter).name(in.getName()).tag(in.getTag()) + .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) + .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()).defaultNetwork(in.getDefaultNetwork()); + } + } - @Override - public String toString() - { - return "Public " + super.toString(); - } + @Override + public String toString() { + return "Public " + super.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java index c6fb0cd363..9c4d0c66ad 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java @@ -42,48 +42,40 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class UnmanagedIp extends AbstractPublicIp -{ - /** - * Constructor to be used only by the builder. - */ - protected UnmanagedIp(final RestContext context, - final UnmanagedIpDto target) - { - super(context, target); - } +public class UnmanagedIp extends AbstractPublicIp { + /** + * Constructor to be used only by the builder. + */ + protected UnmanagedIp(final RestContext context, final UnmanagedIpDto target) { + super(context, target); + } - // Domain operations + // Domain operations - @Override - public UnmanagedNetwork getNetwork() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.UNMANAGED_NETWORK), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.UNMANAGED_NETWORK); + @Override + public UnmanagedNetwork getNetwork() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.UNMANAGED_NETWORK), + ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.UNMANAGED_NETWORK); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(VLANNetworkDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(VLANNetworkDto.class)); - return wrap(context, UnmanagedNetwork.class, parser.apply(response)); - } + return wrap(context, UnmanagedNetwork.class, parser.apply(response)); + } - @Override - public NetworkType getNetworkType() - { - return NetworkType.UNMANAGED; - } + @Override + public NetworkType getNetworkType() { + return NetworkType.UNMANAGED; + } - @Override - public String toString() - { - return "UnmanagedIp [networkType=" + getNetworkType() + ", available=" + isAvailable() - + ", quarantine=" + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" - + getMac() + ", name=" + getName() + ", networkName=" + getNetworkName() + "]"; - } + @Override + public String toString() { + return "UnmanagedIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine=" + + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName() + + ", networkName=" + getNetworkName() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java index 81c0ddd877..9b8e73ecbf 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java @@ -50,211 +50,181 @@ import com.google.inject.TypeLiteral; * * @author Ignasi Barrera * @author Francesc Montserrat - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource */ @EnterpriseEdition -public class UnmanagedNetwork extends Network -{ - /** The datacenter where the network belongs. */ - private Datacenter datacenter; +public class UnmanagedNetwork extends Network { + /** The datacenter where the network belongs. */ + private Datacenter datacenter; - /** The enterprise where the network belongs. */ - private Enterprise enterprise; + /** The enterprise where the network belongs. */ + private Enterprise enterprise; - /** - * Constructor to be used only by the builder. - */ - protected UnmanagedNetwork(final RestContext context, - final VLANNetworkDto target) - { - super(context, target); - } + /** + * Constructor to be used only by the builder. + */ + protected UnmanagedNetwork(final RestContext context, final VLANNetworkDto target) { + super(context, target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -DeleteanUnmanagedNetwork - */ - @Override - public void delete() - { - context.getApi().getInfrastructureApi().deleteNetwork(target); - target = null; - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -DeleteanUnmanagedNetwork + */ + @Override + public void delete() { + context.getApi().getInfrastructureApi().deleteNetwork(target); + target = null; + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -CreateanewUnmanagedNetwork - */ - @Override - public void save() - { - this.addEnterpriseLink(); - target = - context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -CreateanewUnmanagedNetwork + */ + @Override + public void save() { + this.addEnterpriseLink(); + target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target); + } - /** - * @see API: - * http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource - * -UpdateanUnmanagedNetwork - */ - @Override - public void update() - { - target = context.getApi().getInfrastructureApi().updateNetwork(target); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+Network+Resource# + * PublicNetworkResource -UpdateanUnmanagedNetwork + */ + @Override + public void update() { + target = context.getApi().getInfrastructureApi().updateNetwork(target); + } - /** - * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource#PublicIPsResource- - * ReturnthelistofIPsforaPublicNetwork - */ - @Override - public List listIps(final IpOptions options) - { - UnmanagedIpsDto ips = - context.getApi().getInfrastructureApi().listUnmanagedIps(target, options); - return wrap(context, UnmanagedIp.class, ips.getCollection()); - } + /** + * @see API: http://community.abiquo.com/display/ABI20/Public+IPs+Resource# + * PublicIPsResource- ReturnthelistofIPsforaPublicNetwork + */ + @Override + public List listIps(final IpOptions options) { + UnmanagedIpsDto ips = context.getApi().getInfrastructureApi().listUnmanagedIps(target, options); + return wrap(context, UnmanagedIp.class, ips.getCollection()); + } - @Override - public UnmanagedIp getIp(final Integer id) - { - UnmanagedIpDto ip = context.getApi().getInfrastructureApi().getUnmanagedIp(target, id); - return wrap(context, UnmanagedIp.class, ip); - } + @Override + public UnmanagedIp getIp(final Integer id) { + UnmanagedIpDto ip = context.getApi().getInfrastructureApi().getUnmanagedIp(target, id); + return wrap(context, UnmanagedIp.class, ip); + } - // Parent access + // Parent access - public Enterprise getEnterprise() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.ENTERPRISE); + public Enterprise getEnterprise() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), ValidationErrors.MISSING_REQUIRED_LINK + + " " + ParentLinkName.ENTERPRISE); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(EnterpriseDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(EnterpriseDto.class)); - enterprise = wrap(context, Enterprise.class, parser.apply(response)); - return enterprise; - } + enterprise = wrap(context, Enterprise.class, parser.apply(response)); + return enterprise; + } - public Datacenter getDatacenter() - { - RESTLink link = - checkNotNull(target.searchLink(ParentLinkName.DATACENTER), - ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.DATACENTER); + public Datacenter getDatacenter() { + RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK + + " " + ParentLinkName.DATACENTER); - ExtendedUtils utils = (ExtendedUtils) context.getUtils(); - HttpResponse response = utils.getAbiquoHttpClient().get(link); + ExtendedUtils utils = (ExtendedUtils) context.getUtils(); + HttpResponse response = utils.getAbiquoHttpClient().get(link); - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(utils.getXml(), - TypeLiteral.get(DatacenterDto.class)); + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(utils.getXml(), + TypeLiteral.get(DatacenterDto.class)); - datacenter = wrap(context, Datacenter.class, parser.apply(response)); - return datacenter; - } + datacenter = wrap(context, Datacenter.class, parser.apply(response)); + return datacenter; + } - private void addEnterpriseLink() - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Enterprise.class); + private void addEnterpriseLink() { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - RESTLink link = enterprise.unwrap().searchLink("edit"); + RESTLink link = enterprise.unwrap().searchLink("edit"); - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); + checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - target.addLink(new RESTLink("enterprise", link.getHref())); - } + target.addLink(new RESTLink("enterprise", link.getHref())); + } - // Builder + // Builder - public static Builder builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - return new Builder(context, datacenter, enterprise); - } + public static Builder builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + return new Builder(context, datacenter, enterprise); + } - public static class Builder extends NetworkBuilder - { - private Datacenter datacenter; + public static class Builder extends NetworkBuilder { + private Datacenter datacenter; - private Enterprise enterprise; + private Enterprise enterprise; - public Builder(final RestContext context, - final Datacenter datacenter, final Enterprise enterprise) - { - super(context); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); - checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.datacenter = datacenter; - this.enterprise = enterprise; - this.context = context; - } + public Builder(final RestContext context, final Datacenter datacenter, + final Enterprise enterprise) { + super(context); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class); + checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Enterprise.class); + this.datacenter = datacenter; + this.enterprise = enterprise; + this.context = context; + } - public Builder datacenter(final Datacenter datacenter) - { - this.datacenter = datacenter; - return this; - } + public Builder datacenter(final Datacenter datacenter) { + this.datacenter = datacenter; + return this; + } - public Builder enterprise(final Enterprise enterprise) - { - this.enterprise = enterprise; - return this; - } + public Builder enterprise(final Enterprise enterprise) { + this.enterprise = enterprise; + return this; + } - public UnmanagedNetwork build() - { - VLANNetworkDto dto = new VLANNetworkDto(); - dto.setName(name); - dto.setTag(tag); - dto.setGateway(gateway); - dto.setAddress(address); - dto.setMask(mask); - dto.setPrimaryDNS(primaryDNS); - dto.setSecondaryDNS(secondaryDNS); - dto.setSufixDNS(sufixDNS); - dto.setDefaultNetwork(defaultNetwork); - dto.setUnmanaged(true); - dto.setType(NetworkType.UNMANAGED); + public UnmanagedNetwork build() { + VLANNetworkDto dto = new VLANNetworkDto(); + dto.setName(name); + dto.setTag(tag); + dto.setGateway(gateway); + dto.setAddress(address); + dto.setMask(mask); + dto.setPrimaryDNS(primaryDNS); + dto.setSecondaryDNS(secondaryDNS); + dto.setSufixDNS(sufixDNS); + dto.setDefaultNetwork(defaultNetwork); + dto.setUnmanaged(true); + dto.setType(NetworkType.UNMANAGED); - UnmanagedNetwork network = new UnmanagedNetwork(context, dto); - network.datacenter = datacenter; - network.enterprise = enterprise; + UnmanagedNetwork network = new UnmanagedNetwork(context, dto); + network.datacenter = datacenter; + network.enterprise = enterprise; - return network; - } + return network; + } - public static Builder fromUnmanagedNetwork(final UnmanagedNetwork in) - { - return UnmanagedNetwork.builder(in.context, in.datacenter, in.enterprise) - .name(in.getName()).tag(in.getTag()).gateway(in.getGateway()) - .address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) - .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()) - .defaultNetwork(in.getDefaultNetwork()); - } - } + public static Builder fromUnmanagedNetwork(final UnmanagedNetwork in) { + return UnmanagedNetwork.builder(in.context, in.datacenter, in.enterprise).name(in.getName()).tag(in.getTag()) + .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS()) + .secondaryDNS(in.getSecondaryDNS()).sufixDNS(in.getSufixDNS()).defaultNetwork(in.getDefaultNetwork()); + } + } - @Override - public String toString() - { - return "Unmanaged " + super.toString(); - } + @Override + public String toString() { + return "Unmanaged " + super.toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java index d44191bed9..dfcbdc5bac 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java @@ -27,41 +27,34 @@ import org.jclouds.http.options.BaseHttpRequestOptions; * * @author Francesc Montserrat */ -public class IpOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class IpOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - IpOptions options = new IpOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + IpOptions options = new IpOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder extends BaseFilterOptionsBuilder - { - private Boolean free; + public static class Builder extends BaseFilterOptionsBuilder { + private Boolean free; - public Builder free(final boolean free) - { - this.free = free; - return this; - } + public Builder free(final boolean free) { + this.free = free; + return this; + } - public IpOptions build() - { - IpOptions options = new IpOptions(); + public IpOptions build() { + IpOptions options = new IpOptions(); - if (free != null) - { - options.queryParameters.put("free", String.valueOf(free)); - } + if (free != null) { + options.queryParameters.put("free", String.valueOf(free)); + } - return addFilterOptions(options); - } - } + return addFilterOptions(options); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java index f97d182c96..304d6b9356 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java @@ -28,54 +28,45 @@ import com.abiquo.model.enumerator.NetworkType; * * @author Francesc Montserrat */ -public class NetworkOptions extends BaseHttpRequestOptions -{ - public static Builder builder() - { - return new Builder(); - } +public class NetworkOptions extends BaseHttpRequestOptions { + public static Builder builder() { + return new Builder(); + } - @Override - protected Object clone() throws CloneNotSupportedException - { - NetworkOptions options = new NetworkOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } + @Override + protected Object clone() throws CloneNotSupportedException { + NetworkOptions options = new NetworkOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static class Builder - { - private NetworkType type; + public static class Builder { + private NetworkType type; - private Boolean all; + private Boolean all; - public Builder type(final NetworkType type) - { - this.type = type; - return this; - } + public Builder type(final NetworkType type) { + this.type = type; + return this; + } - public Builder all(final boolean all) - { - this.all = all; - return this; - } + public Builder all(final boolean all) { + this.all = all; + return this; + } - public NetworkOptions build() - { - NetworkOptions options = new NetworkOptions(); + public NetworkOptions build() { + NetworkOptions options = new NetworkOptions(); - if (type != null) - { - options.queryParameters.put("type", String.valueOf(type)); - } + if (type != null) { + options.queryParameters.put("type", String.valueOf(type)); + } - if (all != null) - { - options.queryParameters.put("all", String.valueOf(all)); - } + if (all != null) { + options.queryParameters.put("all", String.valueOf(all)); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/FilterOptions.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/FilterOptions.java index 34b62699ba..8364f65885 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/FilterOptions.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/FilterOptions.java @@ -29,115 +29,96 @@ import com.google.common.collect.Multimap; * * @author Francesc Montserrat */ -public class FilterOptions extends BaseHttpRequestOptions -{ - @Override - protected Object clone() throws CloneNotSupportedException - { - FilterOptions options = new FilterOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } +public class FilterOptions extends BaseHttpRequestOptions { + @Override + protected Object clone() throws CloneNotSupportedException { + FilterOptions options = new FilterOptions(); + options.queryParameters.putAll(queryParameters); + return options; + } - public static FilterOptionsBuilder builder() - { - return new FilterOptionsBuilder(); - } + public static FilterOptionsBuilder builder() { + return new FilterOptionsBuilder(); + } - public static class FilterOptionsBuilder extends BaseFilterOptionsBuilder - { - public FilterOptions build() - { - FilterOptions options = new FilterOptions(); - return super.addFilterOptions(options); - } - } + public static class FilterOptionsBuilder extends BaseFilterOptionsBuilder { + public FilterOptions build() { + FilterOptions options = new FilterOptions(); + return super.addFilterOptions(options); + } + } - @SuppressWarnings("unchecked") - public static class BaseFilterOptionsBuilder> - { - protected Integer startWith; + @SuppressWarnings("unchecked") + public static class BaseFilterOptionsBuilder> { + protected Integer startWith; - protected Integer limit; + protected Integer limit; - protected OrderBy by; + protected OrderBy by; - protected String has; + protected String has; - protected Boolean asc; + protected Boolean asc; - public T startWith(final int startWith) - { - this.startWith = startWith; - return (T) this; - } + public T startWith(final int startWith) { + this.startWith = startWith; + return (T) this; + } - public T has(final String has) - { - this.has = has; - return (T) this; - } + public T has(final String has) { + this.has = has; + return (T) this; + } - public T limit(final int limit) - { - this.limit = limit; - return (T) this; - } + public T limit(final int limit) { + this.limit = limit; + return (T) this; + } - public T orderBy(final OrderBy by) - { - this.by = by; - return (T) this; - } + public T orderBy(final OrderBy by) { + this.by = by; + return (T) this; + } - public T ascendant(final boolean asc) - { - this.asc = asc; - return (T) this; - } + public T ascendant(final boolean asc) { + this.asc = asc; + return (T) this; + } - public T descendant(final boolean desc) - { - this.asc = !desc; - return (T) this; - } + public T descendant(final boolean desc) { + this.asc = !desc; + return (T) this; + } - public T disablePagination() - { - this.limit = 0; - return (T) this; - } + public T disablePagination() { + this.limit = 0; + return (T) this; + } - protected O addFilterOptions(final O options) - { - Multimap queryParameters = options.buildQueryParameters(); + protected O addFilterOptions(final O options) { + Multimap queryParameters = options.buildQueryParameters(); - if (startWith != null) - { - queryParameters.put("startwith", startWith.toString()); - } + if (startWith != null) { + queryParameters.put("startwith", startWith.toString()); + } - if (limit != null) - { - queryParameters.put("limit", limit.toString()); - } + if (limit != null) { + queryParameters.put("limit", limit.toString()); + } - if (has != null) - { - queryParameters.put("has", has); - } + if (has != null) { + queryParameters.put("has", has); + } - if (by != null) - { - queryParameters.put("by", by.getValue()); - } + if (by != null) { + queryParameters.put("by", by.getValue()); + } - if (asc != null) - { - queryParameters.put("asc", asc.toString()); - } + if (asc != null) { + queryParameters.put("asc", asc.toString()); + } - return options; - } - } + return options; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/reference/OrderBy.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/reference/OrderBy.java index 75fede5905..65db94df61 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/reference/OrderBy.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/options/search/reference/OrderBy.java @@ -25,20 +25,17 @@ package org.jclouds.abiquo.domain.options.search.reference; * @author Francesc Montserrat * @author Ignasi Barrera */ -public enum OrderBy -{ - NAME("name"), ID("id"), VIRTUALDATACENTER("virtualdatacenter"), VIRTUALMACHINE("virtualmachine"), VIRTUALAPPLIANCE( - "virtualappliance"), TIER("tier"), TOTALSIZE("totalsize"), STATE("state"); +public enum OrderBy { + NAME("name"), ID("id"), VIRTUALDATACENTER("virtualdatacenter"), VIRTUALMACHINE("virtualmachine"), VIRTUALAPPLIANCE( + "virtualappliance"), TIER("tier"), TOTALSIZE("totalsize"), STATE("state"); - public String value; + public String value; - public String getValue() - { - return value; - } + public String getValue() { + return value; + } - private OrderBy(final String value) - { - this.value = value; - } + private OrderBy(final String value) { + this.value = value; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java index 19d47fef4e..f1283b801e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java @@ -19,7 +19,6 @@ package org.jclouds.abiquo.domain.task; - import org.jclouds.abiquo.AbiquoAsyncApi; import org.jclouds.abiquo.AbiquoApi; import org.jclouds.abiquo.domain.DomainWrapper; @@ -34,54 +33,44 @@ import com.abiquo.server.core.task.JobDto; * * @author Francesc Montserrat */ -public class AsyncJob extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected AsyncJob(final RestContext context, final JobDto target) - { - super(context, target); - } +public class AsyncJob extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected AsyncJob(final RestContext context, final JobDto target) { + super(context, target); + } - // Delegate methods + // Delegate methods - public String getDescription() - { - return target.getDescription(); - } + public String getDescription() { + return target.getDescription(); + } - public String getId() - { - return target.getId(); - } + public String getId() { + return target.getId(); + } - public JobState getRollbackState() - { - return target.getRollbackState(); - } + public JobState getRollbackState() { + return target.getRollbackState(); + } - public JobState getState() - { - return target.getState(); - } + public JobState getState() { + return target.getState(); + } - public long getTimestamp() - { - return target.getTimestamp(); - } + public long getTimestamp() { + return target.getTimestamp(); + } - public JobType getType() - { - return target.getType(); - } + public JobType getType() { + return target.getType(); + } - @Override - public String toString() - { - return "AsyncJob [id=" + getId() + ", description=" + getDescription() + ", rollbackState=" - + getRollbackState() + ", state=" + getState() + ", timestamp=" + getTimestamp() - + ", type=" + getType() + "]"; - } + @Override + public String toString() { + return "AsyncJob [id=" + getId() + ", description=" + getDescription() + ", rollbackState=" + getRollbackState() + + ", state=" + getState() + ", timestamp=" + getTimestamp() + ", type=" + getType() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java index 7e1f02fd48..7cf5d999a1 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java @@ -39,77 +39,63 @@ import com.abiquo.server.core.task.enums.TaskType; * * @author Francesc Montserrat */ -public class AsyncTask extends DomainWrapper -{ - /** - * Constructor to be used only by the builder. - */ - protected AsyncTask(final RestContext context, - final TaskDto target) - { - super(context, target); - } +public class AsyncTask extends DomainWrapper { + /** + * Constructor to be used only by the builder. + */ + protected AsyncTask(final RestContext context, final TaskDto target) { + super(context, target); + } - // Domain operations + // Domain operations - /** - * Refresh the state of the task. - */ - public void refresh() - { - RESTLink self = - checkNotNull(target.searchLink("self"), ValidationErrors.MISSING_REQUIRED_LINK + "self"); + /** + * Refresh the state of the task. + */ + public void refresh() { + RESTLink self = checkNotNull(target.searchLink("self"), ValidationErrors.MISSING_REQUIRED_LINK + "self"); - target = context.getApi().getTaskApi().getTask(self); - } + target = context.getApi().getTaskApi().getTask(self); + } - // Children access + // Children access - /** - * Get the individual jobs that compose the current task. - */ - public List getJobs() - { - return wrap(context, AsyncJob.class, target.getJobs().getCollection()); - } + /** + * Get the individual jobs that compose the current task. + */ + public List getJobs() { + return wrap(context, AsyncJob.class, target.getJobs().getCollection()); + } - // Delegate methods + // Delegate methods - public String getOwnerId() - { - return target.getOwnerId(); - } + public String getOwnerId() { + return target.getOwnerId(); + } - public TaskState getState() - { - return target.getState(); - } + public TaskState getState() { + return target.getState(); + } - public String getTaskId() - { - return target.getTaskId(); - } + public String getTaskId() { + return target.getTaskId(); + } - public long getTimestamp() - { - return target.getTimestamp(); - } + public long getTimestamp() { + return target.getTimestamp(); + } - public TaskType getType() - { - return target.getType(); - } + public TaskType getType() { + return target.getType(); + } - public String getUserId() - { - return target.getUserId(); - } + public String getUserId() { + return target.getUserId(); + } - @Override - public String toString() - { - return "AsyncTask [taskId=" + getTaskId() + ", ownerId=" + getOwnerId() + ", timestamp=" - + getTimestamp() + ", userId=" + getUserId() + ", state=" + getState() + ", type=" - + getType() + "]"; - } + @Override + public String toString() { + return "AsyncTask [taskId=" + getTaskId() + ", ownerId=" + getOwnerId() + ", timestamp=" + getTimestamp() + + ", userId=" + getUserId() + ", state=" + getState() + ", type=" + getType() + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java index 485a4130ca..d8626de5c3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java @@ -34,28 +34,27 @@ import com.google.common.collect.Lists; * * @author Ignasi Barrera */ -public class LinkUtils -{ - /** - * Get the link that points to the current resource. - * - * @param dto The target dto. - * @return The link to the current resource. - */ - public static RESTLink getSelfLink(final SingleResourceTransportDto dto) - { - RESTLink link = dto.searchLink("edit"); - return link == null ? dto.searchLink("self") : link; - } +public class LinkUtils { + /** + * Get the link that points to the current resource. + * + * @param dto + * The target dto. + * @return The link to the current resource. + */ + public static RESTLink getSelfLink(final SingleResourceTransportDto dto) { + RESTLink link = dto.searchLink("edit"); + return link == null ? dto.searchLink("self") : link; + } - /** - * Filter the given link list and return only the links that point to a NIC. - * - * @param links The list with the links to filter. - * @return A lsit with all links taht point to a NIC. - */ - public static List filterNicLinks(final List links) - { - return Lists.newLinkedList(filter(links, LinkPredicates.isNic())); - } + /** + * Filter the given link list and return only the links that point to a NIC. + * + * @param links + * The list with the links to filter. + * @return A lsit with all links taht point to a NIC. + */ + public static List filterNicLinks(final List links) { + return Lists.newLinkedList(filter(links, LinkPredicates.isNic())); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java index 74621ac69e..d5a022f6a7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/AbstractEventHandler.java @@ -29,29 +29,29 @@ import org.jclouds.logging.Logger; * * @author Ignasi Barrera */ -public abstract class AbstractEventHandler -{ - @Resource - protected Logger logger = Logger.NULL; +public abstract class AbstractEventHandler { + @Resource + protected Logger logger = Logger.NULL; - /** - * Checks if the current handler must handle the dispatched event. - * - * @param event The event being dispatched. - * @return Boolean indicating if the event must be handled by the current handler. - */ - protected abstract boolean handles(MonitorEvent event); + /** + * Checks if the current handler must handle the dispatched event. + * + * @param event + * The event being dispatched. + * @return Boolean indicating if the event must be handled by the current + * handler. + */ + protected abstract boolean handles(MonitorEvent event); - // Public getters and setters to allow non-guice code to set the appropriate logger + // Public getters and setters to allow non-guice code to set the appropriate + // logger - public Logger getLogger() - { - return logger; - } + public Logger getLogger() { + return logger; + } - public void setLogger(final Logger logger) - { - this.logger = logger; - } + public void setLogger(final Logger logger) { + this.logger = logger; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java index 7973fe31dc..45c14994ea 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/handlers/BlockingEventHandler.java @@ -34,136 +34,116 @@ import com.google.common.collect.Lists; import com.google.common.eventbus.Subscribe; /** - * An event handler that blocks the thread until all monitored objects have been finished being - * watched. + * An event handler that blocks the thread until all monitored objects have been + * finished being watched. *

- * Due to Guava Issue - * 786 {@link #handle(MonitorEvent)} is marked finalto avoid having duplicate - * events. + * Due to Guava + * Issue 786 {@link #handle(MonitorEvent)} is marked finalto + * avoid having duplicate events. * * @author Ignasi Barrera - * @param The monitored object. + * @param + * The monitored object. */ -public class BlockingEventHandler extends AbstractEventHandler -{ - /** The signal used to lock the thread. */ - @VisibleForTesting - CountDownLatch completeSignal; +public class BlockingEventHandler extends AbstractEventHandler { + /** The signal used to lock the thread. */ + @VisibleForTesting + CountDownLatch completeSignal; - /** - * The objects being locked. - *

- * This class handles events in a thread safe way. Otherwise this collections should be - * synchronised. - */ - protected List lockedObjects; + /** + * The objects being locked. + *

+ * This class handles events in a thread safe way. Otherwise this collections + * should be synchronised. + */ + protected List lockedObjects; - public BlockingEventHandler(final T... lockedObjects) - { - this(Logger.NULL, lockedObjects); - } + public BlockingEventHandler(final T... lockedObjects) { + this(Logger.NULL, lockedObjects); + } - public BlockingEventHandler(final Logger logger, final T... lockedObjects) - { - super(); - checkArgument(checkNotNull(lockedObjects, "lockedObjects").length > 0, - "must provide at least one object"); - this.logger = checkNotNull(logger, "logger"); - this.lockedObjects = Lists.newArrayList(lockedObjects); - this.logger.debug("created BlockingEventHandler locking %s objects", lockedObjects.length); - } + public BlockingEventHandler(final Logger logger, final T... lockedObjects) { + super(); + checkArgument(checkNotNull(lockedObjects, "lockedObjects").length > 0, "must provide at least one object"); + this.logger = checkNotNull(logger, "logger"); + this.lockedObjects = Lists.newArrayList(lockedObjects); + this.logger.debug("created BlockingEventHandler locking %s objects", lockedObjects.length); + } - @Override - protected boolean handles(final MonitorEvent event) - { - logger.debug("checking if %s event on %s must be handled by %s", event.getType(), - event.getTarget(), this); - boolean handles = lockedObjects.contains(event.getTarget()); - logger.debug("%s event on %s must %sbe handled", event.getType(), event.getTarget(), - handles ? "" : "not "); - return handles; - } + @Override + protected boolean handles(final MonitorEvent event) { + logger.debug("checking if %s event on %s must be handled by %s", event.getType(), event.getTarget(), this); + boolean handles = lockedObjects.contains(event.getTarget()); + logger.debug("%s event on %s must %sbe handled", event.getType(), event.getTarget(), handles ? "" : "not "); + return handles; + } - /** - * Handles the dispatched event in a thread safe way. - *

- * Due to Guava Issue - * 786 {@link #handle(MonitorEvent)} is marked finalto avoid having duplicate - * events. - * - * @see {@link #doBeforeRelease(MonitorEvent)} - */ - @Subscribe - public final void handle(final MonitorEvent event) - { - if (handles(event)) - { - logger.debug("handling %s", event); + /** + * Handles the dispatched event in a thread safe way. + *

+ * Due to Guava + * Issue 786 {@link #handle(MonitorEvent)} is marked finalto + * avoid having duplicate events. + * + * @see {@link #doBeforeRelease(MonitorEvent)} + */ + @Subscribe + public final void handle(final MonitorEvent event) { + if (handles(event)) { + logger.debug("handling %s", event); - try - { - doBeforeRelease(event); - } - finally - { - // Always release the lock, even if the handler code fails - release(event.getTarget()); - } - } - } + try { + doBeforeRelease(event); + } finally { + // Always release the lock, even if the handler code fails + release(event.getTarget()); + } + } + } - /** - * Blocks the thread until all locked objects have been released. - */ - public void lock() - { - // When invoking the lock, it is possible that all events have - // already been consumed. If there are no objects to monitor, - // just ignore the lock. - if (!lockedObjects.isEmpty()) - { - try - { - completeSignal = new CountDownLatch(lockedObjects.size()); - logger.debug("creating lock for %s object(s)", lockedObjects.size()); - completeSignal.await(); - } - catch (InterruptedException ex) - { - Throwables.propagate(ex); - } - } - else - { - logger.debug("there is nothing to watch. Ignoring lock."); - } - } + /** + * Blocks the thread until all locked objects have been released. + */ + public void lock() { + // When invoking the lock, it is possible that all events have + // already been consumed. If there are no objects to monitor, + // just ignore the lock. + if (!lockedObjects.isEmpty()) { + try { + completeSignal = new CountDownLatch(lockedObjects.size()); + logger.debug("creating lock for %s object(s)", lockedObjects.size()); + completeSignal.await(); + } catch (InterruptedException ex) { + Throwables.propagate(ex); + } + } else { + logger.debug("there is nothing to watch. Ignoring lock."); + } + } - /** - * Releases the lock on the given object. - */ - protected void release(final T target) - { - logger.debug("releasing %s", target); - lockedObjects.remove(target); + /** + * Releases the lock on the given object. + */ + protected void release(final T target) { + logger.debug("releasing %s", target); + lockedObjects.remove(target); - // The completeSignal might be null if the events have been consumed - // before acquiring the lock - if (completeSignal != null) - { - completeSignal.countDown(); - logger.debug("releasing lock for %s. %s remaining objects", target, - completeSignal.getCount()); - } - } + // The completeSignal might be null if the events have been consumed + // before acquiring the lock + if (completeSignal != null) { + completeSignal.countDown(); + logger.debug("releasing lock for %s. %s remaining objects", target, completeSignal.getCount()); + } + } - /** - * Convenience method to bypass the Guava Issue 786 that - * forces the subscriber method to be final. - */ - protected void doBeforeRelease(final MonitorEvent event) - { - // Let subclasses may override it to customize behavior - } + /** + * Convenience method to bypass the Guava + * Issue 786 that forces the subscriber method to be final. + */ + protected void doBeforeRelease(final MonitorEvent event) { + // Let subclasses may override it to customize behavior + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java index 3bfbb59d0b..cac8e36d45 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/CompletedEvent.java @@ -24,11 +24,9 @@ package org.jclouds.abiquo.events.monitor; * * @author Ignasi Barrera */ -public class CompletedEvent extends MonitorEvent -{ - public CompletedEvent(final T target) - { - super(MonitorEvent.Type.COMPLETED, target); - } +public class CompletedEvent extends MonitorEvent { + public CompletedEvent(final T target) { + super(MonitorEvent.Type.COMPLETED, target); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java index e2be9763de..7d185c2260 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/FailedEvent.java @@ -24,11 +24,9 @@ package org.jclouds.abiquo.events.monitor; * * @author Ignasi Barrera */ -public class FailedEvent extends MonitorEvent -{ - public FailedEvent(final T target) - { - super(MonitorEvent.Type.FAILED, target); - } +public class FailedEvent extends MonitorEvent { + public FailedEvent(final T target) { + super(MonitorEvent.Type.FAILED, target); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java index e03dd791f2..7a263dd247 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/MonitorEvent.java @@ -26,53 +26,45 @@ import static com.google.common.base.Preconditions.checkNotNull; * * @author Ignasi Barrera */ -public class MonitorEvent -{ - /** - * The type of the event. - */ - public static enum Type - { - COMPLETED, FAILED, TIMEOUT; - } +public class MonitorEvent { + /** + * The type of the event. + */ + public static enum Type { + COMPLETED, FAILED, TIMEOUT; + } - /** The type of the event. */ - private Type type; + /** The type of the event. */ + private Type type; - /** The target object being monitored. */ - private T target; + /** The target object being monitored. */ + private T target; - public MonitorEvent(final Type type, final T target) - { - super(); - this.type = checkNotNull(type, "type"); - this.target = checkNotNull(target, "target"); - } + public MonitorEvent(final Type type, final T target) { + super(); + this.type = checkNotNull(type, "type"); + this.target = checkNotNull(target, "target"); + } - public Type getType() - { - return type; - } + public Type getType() { + return type; + } - public void setType(final Type type) - { - this.type = type; - } + public void setType(final Type type) { + this.type = type; + } - public T getTarget() - { - return target; - } + public T getTarget() { + return target; + } - public void setTarget(final T target) - { - this.target = target; - } + public void setTarget(final T target) { + this.target = target; + } - @Override - public String toString() - { - return "MonitorEvent [type=" + type + ", target=" + target + "]"; - } + @Override + public String toString() { + return "MonitorEvent [type=" + type + ", target=" + target + "]"; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java index 6effde8184..b98c38f5cd 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/events/monitor/TimeoutEvent.java @@ -24,11 +24,9 @@ package org.jclouds.abiquo.events.monitor; * * @author Ignasi Barrera */ -public class TimeoutEvent extends MonitorEvent -{ - public TimeoutEvent(final T target) - { - super(MonitorEvent.Type.TIMEOUT, target); - } +public class TimeoutEvent extends MonitorEvent { + public TimeoutEvent(final T target) { + super(MonitorEvent.Type.TIMEOUT, target); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java index e01e6c6db9..228854225a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java @@ -39,77 +39,82 @@ import com.abiquo.server.core.enterprise.UserDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface AdminApi -{ - /* ********************** User ********************** */ +public interface AdminApi { + /* ********************** User ********************** */ - /** - * Get the information of the current user. - * - * @return The information of the current user. - */ - UserDto getCurrentUser(); + /** + * Get the information of the current user. + * + * @return The information of the current user. + */ + UserDto getCurrentUser(); - /* ********************** Role ********************** */ + /* ********************** Role ********************** */ - /** - * List global roles. - * - * @return The list of global Roles. - */ - RolesDto listRoles(); + /** + * List global roles. + * + * @return The list of global Roles. + */ + RolesDto listRoles(); - /** - * List enterprise roles. - * - * @return The list of Roles for the given enterprise. - */ - RolesDto listRoles(EnterpriseDto enterprise); + /** + * List enterprise roles. + * + * @return The list of Roles for the given enterprise. + */ + RolesDto listRoles(EnterpriseDto enterprise); - /** - * Retrieves the role of the given user. - * - * @param user The user. - * @return The role of the user. - */ - RoleDto getRole(UserDto user); + /** + * Retrieves the role of the given user. + * + * @param user + * The user. + * @return The role of the user. + */ + RoleDto getRole(UserDto user); - /** - * Get the given role. - * - * @param roleId The id of the role. - * @return The role or null if it does not exist. - */ - RoleDto getRole(Integer roleId); + /** + * Get the given role. + * + * @param roleId + * The id of the role. + * @return The role or null if it does not exist. + */ + RoleDto getRole(Integer roleId); - /** - * Deletes an existing role. - * - * @param role The role to delete. - */ - void deleteRole(final RoleDto role); + /** + * Deletes an existing role. + * + * @param role + * The role to delete. + */ + void deleteRole(final RoleDto role); - /** - * Updates an existing role. - * - * @param role The new attributes for the role. - * @return The updated role. - */ - RoleDto updateRole(RoleDto role); + /** + * Updates an existing role. + * + * @param role + * The new attributes for the role. + * @return The updated role. + */ + RoleDto updateRole(RoleDto role); - /** - * Create a new role. - * - * @param role The role to be created. - * @return The created role. - */ - RoleDto createRole(RoleDto role); + /** + * Create a new role. + * + * @param role + * The role to be created. + * @return The created role. + */ + RoleDto createRole(RoleDto role); - /** - * Get privileges of the given role. - * - * @param role The role. - * @return The list of privileges. - */ - PrivilegesDto listPrivileges(RoleDto role); + /** + * Get privileges of the given role. + * + * @param role + * The role. + * @return The list of privileges. + */ + PrivilegesDto listPrivileges(RoleDto role); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminAsyncApi.java index 3209c72b24..d795614304 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/AdminAsyncApi.java @@ -60,94 +60,90 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) -public interface AdminAsyncApi -{ - /*********************** Login ***********************/ +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) +public interface AdminAsyncApi { + /*********************** Login ***********************/ - /** - * @see AdminApi#getCurrentUser() - */ - @GET - @Path("/login") - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getCurrentUser(); + /** + * @see AdminApi#getCurrentUser() + */ + @GET + @Path("/login") + @Consumes(UserDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getCurrentUser(); - /*********************** Role ***********************/ + /*********************** Role ***********************/ - /** - * @see AdminApi#listRoles() - */ - @GET - @Path("/admin/roles") - @Consumes(RolesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRoles(); + /** + * @see AdminApi#listRoles() + */ + @GET + @Path("/admin/roles") + @Consumes(RolesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listRoles(); - /** - * @see AdminApi#listRoles(Enterprise enterprise) - */ - @GET - @Path("/admin/roles") - @Consumes(RolesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRoles( - @QueryParam("identerprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise); + /** + * @see AdminApi#listRoles(Enterprise enterprise) + */ + @GET + @Path("/admin/roles") + @Consumes(RolesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listRoles( + @QueryParam("identerprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise); - /** - * @see AdminApi#getRole(UserDto) - */ - @GET - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRole( - @EndpointLink("role") @BinderParam(BindToPath.class) UserDto user); + /** + * @see AdminApi#getRole(UserDto) + */ + @GET + @Consumes(RoleDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRole(@EndpointLink("role") @BinderParam(BindToPath.class) UserDto user); - /** - * @see AdminApi#getRole(Integer) - */ - @GET - @Path("/admin/roles/{role}") - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRole(@PathParam("role") Integer roleId); + /** + * @see AdminApi#getRole(Integer) + */ + @GET + @Path("/admin/roles/{role}") + @Consumes(RoleDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRole(@PathParam("role") Integer roleId); - /** - * @see AdminApi#deleteRole(RoleDto) - */ - @DELETE - ListenableFuture deleteRole( - @EndpointLink("edit") @BinderParam(BindToPath.class) RoleDto role); + /** + * @see AdminApi#deleteRole(RoleDto) + */ + @DELETE + ListenableFuture deleteRole(@EndpointLink("edit") @BinderParam(BindToPath.class) RoleDto role); - /** - * @see AdminApi#updateRole(RoleDto) - */ - @PUT - @Produces(RoleDto.BASE_MEDIA_TYPE) - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateRole( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RoleDto role); + /** + * @see AdminApi#updateRole(RoleDto) + */ + @PUT + @Produces(RoleDto.BASE_MEDIA_TYPE) + @Consumes(RoleDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateRole(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RoleDto role); - /** - * @see AdminApi#createRole(RoleDto) - */ - @POST - @Path("/admin/roles") - @Produces(RoleDto.BASE_MEDIA_TYPE) - @Consumes(RoleDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createRole(@BinderParam(BindToXMLPayload.class) RoleDto role); + /** + * @see AdminApi#createRole(RoleDto) + */ + @POST + @Path("/admin/roles") + @Produces(RoleDto.BASE_MEDIA_TYPE) + @Consumes(RoleDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createRole(@BinderParam(BindToXMLPayload.class) RoleDto role); - /** - * @see AdminApi#listPrivileges(RoleDto) - */ - @GET - @Consumes(PrivilegesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivileges( - @EndpointLink("privileges") @BinderParam(BindToPath.class) RoleDto role); + /** + * @see AdminApi#listPrivileges(RoleDto) + */ + @GET + @Consumes(PrivilegesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPrivileges( + @EndpointLink("privileges") @BinderParam(BindToPath.class) RoleDto role); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java index 2d01dcb640..2ddb1cd6a6 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudApi.java @@ -69,620 +69,719 @@ import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface CloudApi -{ - /*********************** Virtual Datacenter ***********************/ - - /** - * List all virtual datacenters. - * - * @param options Optional query params. - * @return The list of Datacenters. - */ - VirtualDatacentersDto listVirtualDatacenters(VirtualDatacenterOptions options); - - /** - * Get the given virtual datacenter. - * - * @param virtualDatacenterId The id of the virtual datacenter. - * @return The virtual datacenter or null if it does not exist. - */ - VirtualDatacenterDto getVirtualDatacenter(Integer virtualDatacenterId); - - /** - * Create a new virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter to be created. - * @param datacenter Datacenter where the virtualdatacenter will be deployed. - * @param enterprise Enterprise of the virtual datacenter. - * @return The created virtual datacenter. - */ - VirtualDatacenterDto createVirtualDatacenter(VirtualDatacenterDto virtualDatacenter, - DatacenterDto datacenter, EnterpriseDto enterprise); - - /** - * Updates an existing virtual datacenter. - * - * @param virtualDatacenter The new attributes for the virtual datacenter. - * @return The updated virtual datacenter. - */ - VirtualDatacenterDto updateVirtualDatacenter(VirtualDatacenterDto virtualDatacenter); - - /** - * Deletes an existing virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter to delete. - */ - void deleteVirtualDatacenter(VirtualDatacenterDto virtualDatacenter); - - /** - * List all available templates for the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The list of available templates. - */ - VirtualMachineTemplatesDto listAvailableTemplates(VirtualDatacenterDto virtualDatacenter); - - /** - * List all available templates for the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param options Filtering options. - * @return The list of available templates. - */ - VirtualMachineTemplatesDto listAvailableTemplates(VirtualDatacenterDto virtualDatacenter, - VirtualMachineTemplateOptions options); - - /** - * List all available ips to purchase in the datacenter by the virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param options Filtering options. - * @return The list of available ips. - */ - PublicIpsDto listAvailablePublicIps(VirtualDatacenterDto virtualDatacenter, IpOptions options); - - /** - * List all purchased public ip addresses in the virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param options Filtering options. - * @return The list of purchased ips. - */ - PublicIpsDto listPurchasedPublicIps(VirtualDatacenterDto virtualDatacenter, IpOptions options); - - /** - * Purchase a public IP. - * - * @param ip The public ip address to purchase. - * @return The purchased public ip. - */ - PublicIpDto purchasePublicIp(PublicIpDto publicIp); - - /** - * Release a public IP. - * - * @param ip The public ip address to purchase. - * @return The release public ip. - */ - PublicIpDto releasePublicIp(PublicIpDto publicIp); - - /** - * List the storage tiers available for the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The storage tiers available to the given virtual datacenter. - */ - @EnterpriseEdition - TiersDto listStorageTiers(VirtualDatacenterDto virtualDatacenter); - - /** - * Get the storage tier from the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param The id of the storage tier. - * @return The storage tiers available to the given virtual datacenter. - */ - @EnterpriseEdition - TierDto getStorageTier(VirtualDatacenterDto virtualDatacenter, Integer tierId); - - /*********************** Private Network ***********************/ - - /** - * Get the default network of the virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The default network of the virtual datacenter. - */ - VLANNetworkDto getDefaultNetwork(VirtualDatacenterDto virtualDatacenter); - - /** - * Set the default network of the virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param network The default network. - */ - void setDefaultNetwork(VirtualDatacenterDto virtualDatacenter, VLANNetworkDto network); - - /** - * List all private networks for a virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The list of private networks for the virtual datacenter. - */ - VLANNetworksDto listPrivateNetworks(VirtualDatacenterDto virtualDatacenter); - - /** - * Get the given private network from the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param virtualApplianceId The id of the private network. - * @return The private network or null if it does not exist. - */ - VLANNetworkDto getPrivateNetwork(VirtualDatacenterDto virtualDatacenter, - Integer privateNetworkId); - - /** - * Create a new private network in a virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param privateNetwork The private network to be created. - * @return The created private network. - */ - VLANNetworkDto createPrivateNetwork(final VirtualDatacenterDto virtualDatacenter, - final VLANNetworkDto privateNetwork); - - /** - * Updates an existing private network from the given virtual datacenter. - * - * @param privateNetwork The new attributes for the private network. - * @return The updated private network. - */ - VLANNetworkDto updatePrivateNetwork(VLANNetworkDto privateNetwork); - - /** - * Deletes an existing private network. - * - * @param privateNetwork The private network to delete. - */ - void deletePrivateNetwork(VLANNetworkDto privateNetwork); - - /*********************** Private Network IPs ***********************/ - - /** - * List all ips for a private network. - * - * @param network The private network. - * @return The list of ips for the private network. - */ - PrivateIpsDto listPrivateNetworkIps(VLANNetworkDto network); - - /** - * List all ips for a private network with options. - * - * @param network The private network. - * @param options Filtering options. - * @return The list of ips for the private network. - */ - PrivateIpsDto listPrivateNetworkIps(VLANNetworkDto network, IpOptions options); - - /** - * Get the requested ip from the given private network. - * - * @param network The private network. - * @param ipId The id of the ip to get. - * @return The requested ip. - */ - PrivateIpDto getPrivateNetworkIp(VLANNetworkDto network, Integer ipId); - - /*********************** Virtual Appliance ***********************/ - - /** - * List all virtual appliance for a virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The list of virtual appliances for the virtual datacenter. - */ - VirtualAppliancesDto listVirtualAppliances(VirtualDatacenterDto virtualDatacenter); - - /** - * Get the given virtual appliance from the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param virtualApplianceId The id of the virtual appliance. - * @return The virtual appliance or null if it does not exist. - */ - VirtualApplianceDto getVirtualAppliance(VirtualDatacenterDto virtualDatacenter, - Integer virtualApplianceId); - - /** - * Create a new virtual appliance in a virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param virtualAppliance The virtual appliance to be created. - * @return The created virtual appliance. - */ - VirtualApplianceDto createVirtualAppliance(VirtualDatacenterDto virtualDatacenter, - VirtualApplianceDto virtualAppliance); - - /** - * Updates an existing virtual appliance from the given virtual datacenter. - * - * @param virtualAppliance The new attributes for the virtual appliance. - * @return The updated virtual appliance. - */ - VirtualApplianceDto updateVirtualAppliance(VirtualApplianceDto virtualAppliance); - - /** - * Deletes an existing virtual appliance. - * - * @param virtualAppliance The virtual appliance to delete. - */ - void deleteVirtualAppliance(VirtualApplianceDto virtualAppliance); - - /** - * Deletes an existing virtual appliance. - * - * @param virtualAppliance The virtual appliance to delete. - * @param options The options to customize the delete operation (e.g. Force delete). - */ - void deleteVirtualAppliance(VirtualApplianceDto virtualAppliance, - VirtualApplianceOptions options); - - /** - * Deploy a virtual appliance. - * - * @param virtualAppliance The virtual appliance to deploy - * @param options the extra options for the deploy process. - * @return Response message to the deploy request. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto deployVirtualAppliance(VirtualApplianceDto virtualAppliance, - VirtualMachineTaskDto options); - - /** - * Undeploy a virtual appliance. - * - * @param virtualAppliance The virtual appliance to undeploy - * @param options the extra options for the undeploy process. - * @return Response message to the undeploy request. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto undeployVirtualAppliance(VirtualApplianceDto virtualAppliance, - VirtualMachineTaskDto options); - - /** - * Get the state of the given virtual appliance. - * - * @param virtualAppliance The given virtual appliance. - * @return The state of the given virtual appliance. - */ - VirtualApplianceStateDto getVirtualApplianceState(VirtualApplianceDto virtualAppliance); - - /** - * Gets the price of the given virtual appliance. - * - * @param virtualAppliance The virtual appliance to get the price of. - * @return A String representation of the price of the virtual appliance. - */ - String getVirtualAppliancePrice(VirtualApplianceDto virtualAppliance); - - /*********************** Virtual Machine ***********************/ - - /** - * List all virtual machines for a virtual appliance. - * - * @param virtualAppliance The virtual appliance. - * @return The list of virtual machines for the virtual appliance. - */ - VirtualMachinesWithNodeExtendedDto listVirtualMachines(VirtualApplianceDto virtualAppliance); - - /** - * List all virtual machines for a virtual appliance. - * - * @param virtualAppliance The virtual appliance. - * @param options The options to filter the list of virtual machines. - * @return The list of virtual machines for the virtual appliance. - */ - VirtualMachinesWithNodeExtendedDto listVirtualMachines(VirtualApplianceDto virtualAppliance, - VirtualMachineOptions options); - - /** - * Get the given virtual machine from the given virtual machine. - * - * @param virtualAppliance The virtual appliance. - * @param virtualMachineId The id of the virtual machine. - * @return The virtual machine or null if it does not exist. - */ - VirtualMachineWithNodeExtendedDto getVirtualMachine(VirtualApplianceDto virtualAppliance, - Integer virtualMachineId); - - /** - * Create a new virtual machine in a virtual appliance. - * - * @param virtualAppliance The virtual appliance. - * @param virtualMachine The virtual machine to be created. - * @return The created virtual machine. - */ - VirtualMachineWithNodeExtendedDto createVirtualMachine(VirtualApplianceDto virtualAppliance, - VirtualMachineWithNodeExtendedDto virtualMachine); - - /** - * Deletes an existing virtual machine. - * - * @param virtualMachine The virtual machine to delete. - */ - void deleteVirtualMachine(VirtualMachineDto virtualMachine); - - /** - * Updates an existing virtual machine from the given virtual appliance. - * - * @param virtualMachine The new attributes for the virtual machine. - * @return The task reference or null if the operation completed synchronously. - */ - AcceptedRequestDto updateVirtualMachine(VirtualMachineWithNodeExtendedDto virtualMachine); - - /** - * Updates an existing virtual machine from the given virtual appliance. - * - * @param virtualMachine The new attributes for the virtual machine. - * @param options The update options. - * @return The task reference or null if the operation completed synchronously. - */ - AcceptedRequestDto updateVirtualMachine( - VirtualMachineWithNodeExtendedDto virtualMachine, VirtualMachineOptions options); - - /** - * Changes the state an existing virtual machine. - * - * @param virtualMachine The given virtual machine. - * @param state The new state. - * @return The task reference. - */ - AcceptedRequestDto changeVirtualMachineState(VirtualMachineDto virtualMachine, - VirtualMachineStateDto state); - - /** - * Get the state of the given virtual machine. - * - * @param virtualMachine The given virtual machine. - * @return The state of the given virtual machine. - */ - VirtualMachineStateDto getVirtualMachineState(VirtualMachineDto virtualMachine); - - /** - * Deploy a virtual machine with task options. - * - * @param virtualMachine The virtual machine to deploy. - * @param options extra deploy options. - * @return Response message to the deploy request. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto deployVirtualMachine(VirtualMachineDto virtualMachine, - VirtualMachineTaskDto options); - - /** - * Uneploy a virtual machine with task options. - * - * @param virtualMachine The virtual machine to undeploy. - * @param options extra deploy unoptions. - * @return Response message to the undeploy request. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto undeployVirtualMachine(VirtualMachineDto virtualMachine, - VirtualMachineTaskDto options); - - /** - * List all available network configurations for a virtual machine. - * - * @param virtualMachine The virtual machine. - * @return The list of network configurations. - */ - VMNetworkConfigurationsDto listNetworkConfigurations(VirtualMachineDto virtualMachine); - - /** - * Sets the gateway network to be used by this virtual machine. - * - * @param virtualMachine The virtual machine. - * @param network The gateway network to use. - */ - void setGatewayNetwork(final VirtualMachineDto virtualMachine, final VLANNetworkDto network); - - /** - * Reboot a virtual machine. - * - * @param virtualMachine The virtual machine to reboot. - * @return Response message to the reset request. - */ - AcceptedRequestDto rebootVirtualMachine(VirtualMachineDto virtualMachine); - - /******************* Virtual Machine Template ***********************/ - - /** - * Get the template of a virtual machine. - * - * @param virtualMachine The given virtual machine. - * @return The template of the given virtual machine. - */ - VirtualMachineTemplateDto getVirtualMachineTemplate(VirtualMachineDto virtualMachine); - - /** - * Get the volumes attached to the given virtual machine. - * - * @param virtualMachine The virtual machine. - * @return The volumes attached to the given virtual machine. - */ - VolumesManagementDto listAttachedVolumes(VirtualMachineDto virtualMachine); - - /** - * Detach all volumes from the given virtual machine. - *

- * If the virtual machine is deployed, the operation will be executed asynchronously. - * - * @param virtualMachine The virtual machine. - * @return The task reference or null if the operation completed synchronously. - */ - AcceptedRequestDto detachAllVolumes(VirtualMachineDto virtualMachine); - - /** - * Replaces the current volumes attached to the virtual machine with the given ones. - *

- * If the virtual machine is deployed, the operation will be executed asynchronously. - * - * @param virtualMachine The virtual machine. - * @param options virtual machine parameters - * @param volumes The new volumes for the virtual machine. - * @return The task reference or null if the operation completed synchronously. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto replaceVolumes(VirtualMachineDto virtualMachine, - VirtualMachineOptions options, VolumeManagementDto... volumes); - - /** - * List all hard disks attached to the given virtual machine. - * - * @param virtualMachine The virtual machine. - * @return The hard disks attached to the virtual machine. - */ - DisksManagementDto listAttachedHardDisks(VirtualMachineDto virtualMachine); - - /** - * Detach all hard disks from the given virtual machine. - *

- * If the virtual machine is deployed, the operation will be executed asynchronously. - * - * @param virtualMachine The virtual machine. - * @return The task reference or null if the operation completed synchronously. - */ - AcceptedRequestDto detachAllHardDisks(VirtualMachineDto virtualMachine); - - /** - * Replaces the current hard disks attached to the virtual machine with the given ones. - *

- * If the virtual machine is deployed, the operation will be executed asynchronously. - * - * @param virtualMachine The virtual machine. - * @param hardDisks The new hard disks for the virtual machine. - * @return The task reference or null if the operation completed synchronously. - */ - AcceptedRequestDto replaceHardDisks(VirtualMachineDto virtualMachine, - DiskManagementDto... hardDisks); - - /*********************** Hard disks ***********************/ - - /** - * List all hard disks in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The hard disks in the virtual datacenter. - */ - DisksManagementDto listHardDisks(VirtualDatacenterDto virtualDatacenter); - - /** - * Get the hard disk with the given id in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param diskId The id of the hard disk to get. - * @return The requested hard disk or null if it does not exist. - */ - DiskManagementDto getHardDisk(VirtualDatacenterDto virtualDatacenter, Integer diskId); - - /** - * Creates a new hard disk in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter where the hard disk will be created. - * @param hardDisk The hard disk to create. - * @return The created hard disk. - */ - DiskManagementDto createHardDisk(VirtualDatacenterDto virtualDatacenter, - DiskManagementDto hardDisk); - - /** - * Deletes the given hard disk. - * - * @param hardDisk The hard disk to delete. - */ - void deleteHardDisk(DiskManagementDto hardDisk); - - /*********************** Volumes ***********************/ - - /** - * List all volumes in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @return The volumes in the virtual datacenter. - */ - @EnterpriseEdition - VolumesManagementDto listVolumes(VirtualDatacenterDto virtualDatacenter); - - /** - * List all volumes in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param options Optional parameters to filter the volume list. - * @return The volumes in the virtual datacenter. - */ - @EnterpriseEdition - VolumesManagementDto listVolumes(VirtualDatacenterDto virtualDatacenter, VolumeOptions options); - - /** - * Get a volume from the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter. - * @param volumeId The id of the volume to get. - * @return The volume or null if it does not exist. - */ - @EnterpriseEdition - VolumeManagementDto getVolume(VirtualDatacenterDto virtualDatacenter, Integer volumeId); - - /** - * Creates a volume in the given virtual datacenter. - * - * @param virtualDatacenter The virtual datacenter where the volume will be created. - * @param volume The volume to create. This volume dto must contain a link to the tier where the - * volume should be created. - * @return The created volume. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - VolumeManagementDto createVolume(VirtualDatacenterDto virtualDatacenter, - VolumeManagementDto volume); - - /** - * Modifies the given volume. - *

- * If the virtual machine is deployed and the size of the volume is changed, then an - * asynchronous task will be generated to refresh the resources of the virtual machine in the - * hypervisor. - * - * @param volume The volume to modify. - * @return The task reference or null if no task was generated. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto updateVolume(VolumeManagementDto volume); - - /** - * Delete the given volume. - * - * @param volume The volume to delete. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void deleteVolume(VolumeManagementDto volume); - - /** - * Moves the given volume to a new virtual datacenter. - *

- * The Abiquo API will return a 301 (Moved Permanently), so redirects must be enabled to make - * this method succeed. - * - * @param volume The volume to move. - * @param newVirtualDatacenter The destination virtual datacenter. - * @return The reference to the volume in the new virtual datacenter. - */ - @EnterpriseEdition - VolumeManagementDto moveVolume(VolumeManagementDto volume, - VirtualDatacenterDto newVirtualDatacenter); +public interface CloudApi { + /*********************** Virtual Datacenter ***********************/ + + /** + * List all virtual datacenters. + * + * @param options + * Optional query params. + * @return The list of Datacenters. + */ + VirtualDatacentersDto listVirtualDatacenters(VirtualDatacenterOptions options); + + /** + * Get the given virtual datacenter. + * + * @param virtualDatacenterId + * The id of the virtual datacenter. + * @return The virtual datacenter or null if it does not exist. + */ + VirtualDatacenterDto getVirtualDatacenter(Integer virtualDatacenterId); + + /** + * Create a new virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter to be created. + * @param datacenter + * Datacenter where the virtualdatacenter will be deployed. + * @param enterprise + * Enterprise of the virtual datacenter. + * @return The created virtual datacenter. + */ + VirtualDatacenterDto createVirtualDatacenter(VirtualDatacenterDto virtualDatacenter, DatacenterDto datacenter, + EnterpriseDto enterprise); + + /** + * Updates an existing virtual datacenter. + * + * @param virtualDatacenter + * The new attributes for the virtual datacenter. + * @return The updated virtual datacenter. + */ + VirtualDatacenterDto updateVirtualDatacenter(VirtualDatacenterDto virtualDatacenter); + + /** + * Deletes an existing virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter to delete. + */ + void deleteVirtualDatacenter(VirtualDatacenterDto virtualDatacenter); + + /** + * List all available templates for the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The list of available templates. + */ + VirtualMachineTemplatesDto listAvailableTemplates(VirtualDatacenterDto virtualDatacenter); + + /** + * List all available templates for the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param options + * Filtering options. + * @return The list of available templates. + */ + VirtualMachineTemplatesDto listAvailableTemplates(VirtualDatacenterDto virtualDatacenter, + VirtualMachineTemplateOptions options); + + /** + * List all available ips to purchase in the datacenter by the virtual + * datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param options + * Filtering options. + * @return The list of available ips. + */ + PublicIpsDto listAvailablePublicIps(VirtualDatacenterDto virtualDatacenter, IpOptions options); + + /** + * List all purchased public ip addresses in the virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param options + * Filtering options. + * @return The list of purchased ips. + */ + PublicIpsDto listPurchasedPublicIps(VirtualDatacenterDto virtualDatacenter, IpOptions options); + + /** + * Purchase a public IP. + * + * @param ip + * The public ip address to purchase. + * @return The purchased public ip. + */ + PublicIpDto purchasePublicIp(PublicIpDto publicIp); + + /** + * Release a public IP. + * + * @param ip + * The public ip address to purchase. + * @return The release public ip. + */ + PublicIpDto releasePublicIp(PublicIpDto publicIp); + + /** + * List the storage tiers available for the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The storage tiers available to the given virtual datacenter. + */ + @EnterpriseEdition + TiersDto listStorageTiers(VirtualDatacenterDto virtualDatacenter); + + /** + * Get the storage tier from the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param The + * id of the storage tier. + * @return The storage tiers available to the given virtual datacenter. + */ + @EnterpriseEdition + TierDto getStorageTier(VirtualDatacenterDto virtualDatacenter, Integer tierId); + + /*********************** Private Network ***********************/ + + /** + * Get the default network of the virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The default network of the virtual datacenter. + */ + VLANNetworkDto getDefaultNetwork(VirtualDatacenterDto virtualDatacenter); + + /** + * Set the default network of the virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param network + * The default network. + */ + void setDefaultNetwork(VirtualDatacenterDto virtualDatacenter, VLANNetworkDto network); + + /** + * List all private networks for a virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The list of private networks for the virtual datacenter. + */ + VLANNetworksDto listPrivateNetworks(VirtualDatacenterDto virtualDatacenter); + + /** + * Get the given private network from the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param virtualApplianceId + * The id of the private network. + * @return The private network or null if it does not exist. + */ + VLANNetworkDto getPrivateNetwork(VirtualDatacenterDto virtualDatacenter, Integer privateNetworkId); + + /** + * Create a new private network in a virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param privateNetwork + * The private network to be created. + * @return The created private network. + */ + VLANNetworkDto createPrivateNetwork(final VirtualDatacenterDto virtualDatacenter, final VLANNetworkDto privateNetwork); + + /** + * Updates an existing private network from the given virtual datacenter. + * + * @param privateNetwork + * The new attributes for the private network. + * @return The updated private network. + */ + VLANNetworkDto updatePrivateNetwork(VLANNetworkDto privateNetwork); + + /** + * Deletes an existing private network. + * + * @param privateNetwork + * The private network to delete. + */ + void deletePrivateNetwork(VLANNetworkDto privateNetwork); + + /*********************** Private Network IPs ***********************/ + + /** + * List all ips for a private network. + * + * @param network + * The private network. + * @return The list of ips for the private network. + */ + PrivateIpsDto listPrivateNetworkIps(VLANNetworkDto network); + + /** + * List all ips for a private network with options. + * + * @param network + * The private network. + * @param options + * Filtering options. + * @return The list of ips for the private network. + */ + PrivateIpsDto listPrivateNetworkIps(VLANNetworkDto network, IpOptions options); + + /** + * Get the requested ip from the given private network. + * + * @param network + * The private network. + * @param ipId + * The id of the ip to get. + * @return The requested ip. + */ + PrivateIpDto getPrivateNetworkIp(VLANNetworkDto network, Integer ipId); + + /*********************** Virtual Appliance ***********************/ + + /** + * List all virtual appliance for a virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The list of virtual appliances for the virtual datacenter. + */ + VirtualAppliancesDto listVirtualAppliances(VirtualDatacenterDto virtualDatacenter); + + /** + * Get the given virtual appliance from the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param virtualApplianceId + * The id of the virtual appliance. + * @return The virtual appliance or null if it does not exist. + */ + VirtualApplianceDto getVirtualAppliance(VirtualDatacenterDto virtualDatacenter, Integer virtualApplianceId); + + /** + * Create a new virtual appliance in a virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param virtualAppliance + * The virtual appliance to be created. + * @return The created virtual appliance. + */ + VirtualApplianceDto createVirtualAppliance(VirtualDatacenterDto virtualDatacenter, + VirtualApplianceDto virtualAppliance); + + /** + * Updates an existing virtual appliance from the given virtual datacenter. + * + * @param virtualAppliance + * The new attributes for the virtual appliance. + * @return The updated virtual appliance. + */ + VirtualApplianceDto updateVirtualAppliance(VirtualApplianceDto virtualAppliance); + + /** + * Deletes an existing virtual appliance. + * + * @param virtualAppliance + * The virtual appliance to delete. + */ + void deleteVirtualAppliance(VirtualApplianceDto virtualAppliance); + + /** + * Deletes an existing virtual appliance. + * + * @param virtualAppliance + * The virtual appliance to delete. + * @param options + * The options to customize the delete operation (e.g. Force + * delete). + */ + void deleteVirtualAppliance(VirtualApplianceDto virtualAppliance, VirtualApplianceOptions options); + + /** + * Deploy a virtual appliance. + * + * @param virtualAppliance + * The virtual appliance to deploy + * @param options + * the extra options for the deploy process. + * @return Response message to the deploy request. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto deployVirtualAppliance(VirtualApplianceDto virtualAppliance, VirtualMachineTaskDto options); + + /** + * Undeploy a virtual appliance. + * + * @param virtualAppliance + * The virtual appliance to undeploy + * @param options + * the extra options for the undeploy process. + * @return Response message to the undeploy request. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto undeployVirtualAppliance(VirtualApplianceDto virtualAppliance, + VirtualMachineTaskDto options); + + /** + * Get the state of the given virtual appliance. + * + * @param virtualAppliance + * The given virtual appliance. + * @return The state of the given virtual appliance. + */ + VirtualApplianceStateDto getVirtualApplianceState(VirtualApplianceDto virtualAppliance); + + /** + * Gets the price of the given virtual appliance. + * + * @param virtualAppliance + * The virtual appliance to get the price of. + * @return A String representation of the price of the virtual + * appliance. + */ + String getVirtualAppliancePrice(VirtualApplianceDto virtualAppliance); + + /*********************** Virtual Machine ***********************/ + + /** + * List all virtual machines for a virtual appliance. + * + * @param virtualAppliance + * The virtual appliance. + * @return The list of virtual machines for the virtual appliance. + */ + VirtualMachinesWithNodeExtendedDto listVirtualMachines(VirtualApplianceDto virtualAppliance); + + /** + * List all virtual machines for a virtual appliance. + * + * @param virtualAppliance + * The virtual appliance. + * @param options + * The options to filter the list of virtual machines. + * @return The list of virtual machines for the virtual appliance. + */ + VirtualMachinesWithNodeExtendedDto listVirtualMachines(VirtualApplianceDto virtualAppliance, + VirtualMachineOptions options); + + /** + * Get the given virtual machine from the given virtual machine. + * + * @param virtualAppliance + * The virtual appliance. + * @param virtualMachineId + * The id of the virtual machine. + * @return The virtual machine or null if it does not exist. + */ + VirtualMachineWithNodeExtendedDto getVirtualMachine(VirtualApplianceDto virtualAppliance, Integer virtualMachineId); + + /** + * Create a new virtual machine in a virtual appliance. + * + * @param virtualAppliance + * The virtual appliance. + * @param virtualMachine + * The virtual machine to be created. + * @return The created virtual machine. + */ + VirtualMachineWithNodeExtendedDto createVirtualMachine(VirtualApplianceDto virtualAppliance, + VirtualMachineWithNodeExtendedDto virtualMachine); + + /** + * Deletes an existing virtual machine. + * + * @param virtualMachine + * The virtual machine to delete. + */ + void deleteVirtualMachine(VirtualMachineDto virtualMachine); + + /** + * Updates an existing virtual machine from the given virtual appliance. + * + * @param virtualMachine + * The new attributes for the virtual machine. + * @return The task reference or null if the operation completed + * synchronously. + */ + AcceptedRequestDto updateVirtualMachine(VirtualMachineWithNodeExtendedDto virtualMachine); + + /** + * Updates an existing virtual machine from the given virtual appliance. + * + * @param virtualMachine + * The new attributes for the virtual machine. + * @param options + * The update options. + * @return The task reference or null if the operation completed + * synchronously. + */ + AcceptedRequestDto updateVirtualMachine(VirtualMachineWithNodeExtendedDto virtualMachine, + VirtualMachineOptions options); + + /** + * Changes the state an existing virtual machine. + * + * @param virtualMachine + * The given virtual machine. + * @param state + * The new state. + * @return The task reference. + */ + AcceptedRequestDto changeVirtualMachineState(VirtualMachineDto virtualMachine, VirtualMachineStateDto state); + + /** + * Get the state of the given virtual machine. + * + * @param virtualMachine + * The given virtual machine. + * @return The state of the given virtual machine. + */ + VirtualMachineStateDto getVirtualMachineState(VirtualMachineDto virtualMachine); + + /** + * Deploy a virtual machine with task options. + * + * @param virtualMachine + * The virtual machine to deploy. + * @param options + * extra deploy options. + * @return Response message to the deploy request. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto deployVirtualMachine(VirtualMachineDto virtualMachine, VirtualMachineTaskDto options); + + /** + * Uneploy a virtual machine with task options. + * + * @param virtualMachine + * The virtual machine to undeploy. + * @param options + * extra deploy unoptions. + * @return Response message to the undeploy request. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto undeployVirtualMachine(VirtualMachineDto virtualMachine, VirtualMachineTaskDto options); + + /** + * List all available network configurations for a virtual machine. + * + * @param virtualMachine + * The virtual machine. + * @return The list of network configurations. + */ + VMNetworkConfigurationsDto listNetworkConfigurations(VirtualMachineDto virtualMachine); + + /** + * Sets the gateway network to be used by this virtual machine. + * + * @param virtualMachine + * The virtual machine. + * @param network + * The gateway network to use. + */ + void setGatewayNetwork(final VirtualMachineDto virtualMachine, final VLANNetworkDto network); + + /** + * Reboot a virtual machine. + * + * @param virtualMachine + * The virtual machine to reboot. + * @return Response message to the reset request. + */ + AcceptedRequestDto rebootVirtualMachine(VirtualMachineDto virtualMachine); + + /******************* Virtual Machine Template ***********************/ + + /** + * Get the template of a virtual machine. + * + * @param virtualMachine + * The given virtual machine. + * @return The template of the given virtual machine. + */ + VirtualMachineTemplateDto getVirtualMachineTemplate(VirtualMachineDto virtualMachine); + + /** + * Get the volumes attached to the given virtual machine. + * + * @param virtualMachine + * The virtual machine. + * @return The volumes attached to the given virtual machine. + */ + VolumesManagementDto listAttachedVolumes(VirtualMachineDto virtualMachine); + + /** + * Detach all volumes from the given virtual machine. + *

+ * If the virtual machine is deployed, the operation will be executed + * asynchronously. + * + * @param virtualMachine + * The virtual machine. + * @return The task reference or null if the operation completed + * synchronously. + */ + AcceptedRequestDto detachAllVolumes(VirtualMachineDto virtualMachine); + + /** + * Replaces the current volumes attached to the virtual machine with the + * given ones. + *

+ * If the virtual machine is deployed, the operation will be executed + * asynchronously. + * + * @param virtualMachine + * The virtual machine. + * @param options + * virtual machine parameters + * @param volumes + * The new volumes for the virtual machine. + * @return The task reference or null if the operation completed + * synchronously. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto replaceVolumes(VirtualMachineDto virtualMachine, VirtualMachineOptions options, + VolumeManagementDto... volumes); + + /** + * List all hard disks attached to the given virtual machine. + * + * @param virtualMachine + * The virtual machine. + * @return The hard disks attached to the virtual machine. + */ + DisksManagementDto listAttachedHardDisks(VirtualMachineDto virtualMachine); + + /** + * Detach all hard disks from the given virtual machine. + *

+ * If the virtual machine is deployed, the operation will be executed + * asynchronously. + * + * @param virtualMachine + * The virtual machine. + * @return The task reference or null if the operation completed + * synchronously. + */ + AcceptedRequestDto detachAllHardDisks(VirtualMachineDto virtualMachine); + + /** + * Replaces the current hard disks attached to the virtual machine with the + * given ones. + *

+ * If the virtual machine is deployed, the operation will be executed + * asynchronously. + * + * @param virtualMachine + * The virtual machine. + * @param hardDisks + * The new hard disks for the virtual machine. + * @return The task reference or null if the operation completed + * synchronously. + */ + AcceptedRequestDto replaceHardDisks(VirtualMachineDto virtualMachine, DiskManagementDto... hardDisks); + + /*********************** Hard disks ***********************/ + + /** + * List all hard disks in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The hard disks in the virtual datacenter. + */ + DisksManagementDto listHardDisks(VirtualDatacenterDto virtualDatacenter); + + /** + * Get the hard disk with the given id in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param diskId + * The id of the hard disk to get. + * @return The requested hard disk or null if it does not exist. + */ + DiskManagementDto getHardDisk(VirtualDatacenterDto virtualDatacenter, Integer diskId); + + /** + * Creates a new hard disk in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter where the hard disk will be created. + * @param hardDisk + * The hard disk to create. + * @return The created hard disk. + */ + DiskManagementDto createHardDisk(VirtualDatacenterDto virtualDatacenter, DiskManagementDto hardDisk); + + /** + * Deletes the given hard disk. + * + * @param hardDisk + * The hard disk to delete. + */ + void deleteHardDisk(DiskManagementDto hardDisk); + + /*********************** Volumes ***********************/ + + /** + * List all volumes in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @return The volumes in the virtual datacenter. + */ + @EnterpriseEdition + VolumesManagementDto listVolumes(VirtualDatacenterDto virtualDatacenter); + + /** + * List all volumes in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param options + * Optional parameters to filter the volume list. + * @return The volumes in the virtual datacenter. + */ + @EnterpriseEdition + VolumesManagementDto listVolumes(VirtualDatacenterDto virtualDatacenter, VolumeOptions options); + + /** + * Get a volume from the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter. + * @param volumeId + * The id of the volume to get. + * @return The volume or null if it does not exist. + */ + @EnterpriseEdition + VolumeManagementDto getVolume(VirtualDatacenterDto virtualDatacenter, Integer volumeId); + + /** + * Creates a volume in the given virtual datacenter. + * + * @param virtualDatacenter + * The virtual datacenter where the volume will be created. + * @param volume + * The volume to create. This volume dto must contain a link to the + * tier where the volume should be created. + * @return The created volume. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + VolumeManagementDto createVolume(VirtualDatacenterDto virtualDatacenter, VolumeManagementDto volume); + + /** + * Modifies the given volume. + *

+ * If the virtual machine is deployed and the size of the volume is changed, + * then an asynchronous task will be generated to refresh the resources of + * the virtual machine in the hypervisor. + * + * @param volume + * The volume to modify. + * @return The task reference or null if no task was generated. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto updateVolume(VolumeManagementDto volume); + + /** + * Delete the given volume. + * + * @param volume + * The volume to delete. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void deleteVolume(VolumeManagementDto volume); + + /** + * Moves the given volume to a new virtual datacenter. + *

+ * The Abiquo API will return a 301 (Moved Permanently), so redirects must be + * enabled to make this method succeed. + * + * @param volume + * The volume to move. + * @param newVirtualDatacenter + * The destination virtual datacenter. + * @return The reference to the volume in the new virtual datacenter. + */ + @EnterpriseEdition + VolumeManagementDto moveVolume(VolumeManagementDto volume, VirtualDatacenterDto newVirtualDatacenter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudAsyncApi.java index 3c3772c9fa..d79839bb2b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/CloudAsyncApi.java @@ -108,668 +108,676 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/cloud") -public interface CloudAsyncApi -{ - /*********************** Virtual Datacenter ***********************/ - - /** - * @see CloudApi#listVirtualDatacenters(VirtualDatacenterOptions) - */ - @GET - @Path("/virtualdatacenters") - @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualDatacenters(VirtualDatacenterOptions options); - - /** - * @see CloudApi#getVirtualDatacenter(Integer) - */ - @GET - @Path("/virtualdatacenters/{virtualdatacenter}") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualDatacenter( - @PathParam("virtualdatacenter") Integer virtualDatacenterId); - - /** - * @see CloudApi#createVirtualDatacenter(VirtualDatacenterDto, Datacenter, Enterprise) - */ - @POST - @Path("/virtualdatacenters") - @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @Produces(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createVirtualDatacenter( - @BinderParam(BindToXMLPayload.class) final VirtualDatacenterDto virtualDatacenter, - @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter, - @QueryParam("enterprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise); - - /** - * @see CloudApi#updateVirtualDatacenter(VirtualDatacenterDto) - */ - @PUT - @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @Produces(VirtualDatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateVirtualDatacenter( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#deleteVirtualDatacenter(VirtualDatacenterDto) - */ - @DELETE - ListenableFuture deleteVirtualDatacenter( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto) - */ - @GET - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailableTemplates( - @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto, VirtualMachineTemplateOptions) - */ - @GET - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailableTemplates( - @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - VirtualMachineTemplateOptions options); - - /** - * @see CloudApi#listStorageTiers(VirtualDatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(TiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStorageTiers( - @EndpointLink("tiers") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getStorageTier(VirtualDatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getStorageTier( - @EndpointLink("tiers") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(AppendToPath.class) Integer tierId); - - /*********************** Public IP ***********************/ - - /** - * @see CloudApi#listAvailablePublicIps(VirtualDatacenterDto, IpOptions) - */ - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAvailablePublicIps( - @EndpointLink("topurchase") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - IpOptions options); - - /** - * @see CloudApi#listPurchasedPublicIps(VirtualDatacenterDto, IpOptions) - */ - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPurchasedPublicIps( - @EndpointLink("purchased") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - IpOptions options); - - /** - * @see CloudApi#purchasePublicIp(PublicIpDto) - */ - @PUT - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture purchasePublicIp( - @EndpointLink("purchase") @BinderParam(BindToPath.class) PublicIpDto publicIp); - - /** - * @see CloudApi#releasePublicIp(PublicIpDto) - */ - @PUT - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture releasePublicIp( - @EndpointLink("release") @BinderParam(BindToPath.class) PublicIpDto publicIp); - - /*********************** Private Network ***********************/ - - /** - * @see CloudApi#listPrivateNetworks(VirtualDatacenter) - */ - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworks( - @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getPrivateNetwork(VirtualDatacenterDto, Integer) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getPrivateNetwork( - @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(AppendToPath.class) Integer privateNetworkId); - - /** - * @see CloudApi#createPrivateNetwork(VirtualDatacenterDto, VLANNetworkDto) - */ - @POST - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createPrivateNetwork( - @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(BindToXMLPayload.class) VLANNetworkDto privateNetwork); - - /** - * @see CloudApi#updatePrivateNetwork(VLANNetworkDto) - */ - @PUT - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updatePrivateNetwork( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VLANNetworkDto privateNetwork); - - /** - * @see CloudApi#deletePrivateNetwork(VLANNetworkDto) - */ - @DELETE - ListenableFuture deletePrivateNetwork( - @EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto privateNetwork); - - /** - * @see CloudApi#getDefaultNetwork(VirtualDatacenterDto) - */ - @GET - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getDefaultNetwork( - @EndpointLink("defaultnetwork") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#setDefaultNetwork(VirtualDatacenterDto, VLANNetworkDto) - */ - @PUT - @Produces(LinksDto.BASE_MEDIA_TYPE) - ListenableFuture setDefaultNetwork( - @EndpointLink("defaultvlan") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(BindNetworkRefToPayload.class) VLANNetworkDto network); - - /*********************** Private Network IPs ***********************/ - - /** - * @see CloudApi#listPrivateNetworkIps(VLANNetworkDto) - */ - @GET - @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworkIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see CloudApi#listPrivateNetworkIps(VLANNetworkDto, IpOptions) - */ - @GET - @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivateNetworkIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - IpOptions options); - - /** - * @see CloudApi#getPrivateNetworkIp(VLANNetworkDto, Integer) - */ - @GET - @Consumes(PrivateIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getPrivateNetworkIp( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /*********************** Virtual Appliance ***********************/ - - /** - * @see CloudApi#listVirtualAppliances(VirtualDatacenterDto) - */ - @GET - @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualAppliances( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getVirtualAppliance(VirtualDatacenterDto, Integer) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualAppliance( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(AppendToPath.class) Integer virtualApplianceId); - - /** - * @see CloudApi#getVirtualApplianceState(VirtualApplianceDto) - */ - @GET - @Consumes(VirtualApplianceStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualApplianceState( - @EndpointLink("state") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#createVirtualAppliance(VirtualDatacenterDto, VirtualApplianceDto) - */ - @POST - @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) - @Produces(VirtualApplianceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createVirtualAppliance( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(BindToXMLPayload.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#updateVirtualAppliance(VirtualApplianceDto) - */ - @PUT - @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) - @Produces(VirtualApplianceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateVirtualAppliance( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#deleteVirtualAppliance(VirtualApplianceDto) - */ - @DELETE - ListenableFuture deleteVirtualAppliance( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#deleteVirtualAppliance(VirtualApplianceDto, VirtualApplianceOptions) - */ - @DELETE - ListenableFuture deleteVirtualAppliance( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - VirtualApplianceOptions options); - - /** - * @see CloudApi#deployVirtualAppliance(VirtualApplianceDto, VirtualMachineTaskDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> deployVirtualAppliance( - @EndpointLink("deploy") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); - - /** - * @see CloudApi#undeployVirtualAppliance(VirtualApplianceDto, VirtualMachineTaskDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> undeployVirtualAppliance( - @EndpointLink("undeploy") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); - - /** - * @see CloudApi#getVirtualAppliancePrice(VirtualApplianceDto) - */ - @GET - @Consumes(MediaType.TEXT_PLAIN) - @ResponseParser(ReturnStringIf2xx.class) - ListenableFuture getVirtualAppliancePrice( - @EndpointLink("price") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /*********************** Virtual Machine ***********************/ - - /** - * @see CloudApi#listVirtualMachines(VirtualApplianceDto) - */ - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); - - /** - * @see CloudApi#listVirtualMachines(VirtualApplianceDto, VirtualMachineOptions) - */ - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - VirtualMachineOptions options); - - /** - * @see CloudApi#getVirtualMachine(VirtualApplianceDto, Integer) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - @BinderParam(AppendToPath.class) Integer virtualMachineId); - - /** - * @see CloudApi#createVirtualMachine(VirtualApplianceDto, VirtualMachineWithNodeExtendedDto) - */ - @POST - @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createVirtualMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, - @BinderParam(BindToXMLPayload.class) VirtualMachineWithNodeExtendedDto virtualMachine); - - /** - * @see CloudApi#deleteVirtualMachine(VirtualMachineDto) - */ - @DELETE - ListenableFuture deleteVirtualMachine( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#updateVirtualMachine(VirtualMachineWithNodeExtendedDto) - */ - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - ListenableFuture> updateVirtualMachine( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineWithNodeExtendedDto virtualMachine); - - /** - * @see CloudApi#updateVirtualMachine(VirtualMachineDto, VirtualMachineOptions) - */ - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - ListenableFuture> updateVirtualMachine( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineWithNodeExtendedDto virtualMachine, - VirtualMachineOptions options); - - /** - * @see CloudApi#changeVirtualMachineState(VirtualMachineDto, VirtualMachineStateDto) - */ - @PUT - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> changeVirtualMachineState( - @EndpointLink("state") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindToXMLPayload.class) VirtualMachineStateDto state); - - /** - * @see CloudApi#getVirtualMachineState(VirtualMachineDto) - */ - @GET - @Consumes(VirtualMachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachineState( - @EndpointLink("state") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#listNetworkConfigurations(VirtualMachineDto) - */ - @GET - @Consumes(VMNetworkConfigurationsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworkConfigurations( - @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#setGatewayNetwork(VirtualMachineDto, VMNetworkConfigurationDto) - */ - @PUT - @Produces(LinksDto.BASE_MEDIA_TYPE) - ListenableFuture setGatewayNetwork( - @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindNetworkConfigurationRefToPayload.class) VLANNetworkDto network); - - /** - * @see CloudApi#rebootVirtualMachine(VirtualMachineDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> rebootVirtualMachine( - @EndpointLink("reset") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /*********************** Virtual Machine Template ***********************/ - - /** - * @see CloudApi#getVirtualMachineTemplate(VirtualMachineTemplateDto) - */ - @GET - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachineTemplate( - @EndpointLink("virtualmachinetemplate") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#listAttachedVolumes(VirtualMachineDto) - */ - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAttachedVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#detachAllVolumes(VirtualMachineDto) - */ - @DELETE - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - ListenableFuture> detachAllVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#replaceVolumes(VirtualMachineDto, VirtualMachineOptions, - * VolumeManagementDto...) - */ - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(LinksDto.BASE_MEDIA_TYPE) - ListenableFuture> replaceVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - VirtualMachineOptions options, - @BinderParam(BindVolumeRefsToPayload.class) VolumeManagementDto... volumes); - - /** - * @see CloudApi#listAttachedHardDisks(VirtualMachineDto) - */ - @GET - @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAttachedHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#detachAllHardDisks(VirtualMachineDto) - */ - @DELETE - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - ListenableFuture> detachAllHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); - - /** - * @see CloudApi#replaceHardDisks(VirtualMachineDto, DiskManagementDto...) - */ - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(LinksDto.BASE_MEDIA_TYPE) - ListenableFuture> replaceHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindHardDiskRefsToPayload.class) DiskManagementDto... hardDisks); - - /** - * @see CloudApi#deployVirtualMachine(VirtualMachineDto, VirtualMachineTaskDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> deployVirtualMachine( - @EndpointLink("deploy") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); - - /** - * @see CloudApi#undeployVirtualMachine(VirtualMachineDto, VirtualMachineTaskDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture> undeployVirtualMachine( - @EndpointLink("undeploy") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, - @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); - - /*********************** Hard disks ***********************/ - - /** - * @see CloudApi#listHardDisks(VirtualDatacenterDto) - */ - @GET - @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listHardDisks( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#getHardDisk(VirtualDatacenterDto, Integer) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(DiskManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getHardDisk( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(AppendToPath.class) Integer diskId); - - /** - * @see CloudApi#createHardDisk(VirtualDatacenterDto, DiskManagementDto) - */ - @POST - @Consumes(DiskManagementDto.BASE_MEDIA_TYPE) - @Produces(DiskManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createHardDisk( - @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(BindToXMLPayload.class) DiskManagementDto hardDisk); - - /** - * @see CloudApi#deleteHardDisk(DiskManagementDto) - */ - @DELETE - ListenableFuture deleteHardDisk( - @EndpointLink("edit") @BinderParam(BindToPath.class) DiskManagementDto hardDisk); - - /*********************** Volumes ***********************/ - - /** - * @see CloudApi#listVolumes(VirtualDatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); - - /** - * @see CloudApi#listVolumes(VirtualDatacenterDto, VolumeOptions) - */ - @EnterpriseEdition - @GET - @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVolumes( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - VolumeOptions options); - - /** - * @see CloudApi#getVolume(VirtualDatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VolumeManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVolume( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(AppendToPath.class) Integer volumeId); - - /** - * @see CloudApi#createVolume(VirtualDatacenterDto, VolumeManagementDto) - */ - @EnterpriseEdition - @POST - @Consumes(VolumeManagementDto.BASE_MEDIA_TYPE) - @Produces(VolumeManagementDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createVolume( - @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, - @BinderParam(BindToXMLPayload.class) VolumeManagementDto volume); - - /** - * @see CloudApi#updateVolume(VolumeManagementDto) - */ - @EnterpriseEdition - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VolumeManagementDto.BASE_MEDIA_TYPE) - ListenableFuture> updateVolume( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VolumeManagementDto volume); - - /** - * @see CloudApi#updateVolume(VolumeManagementDto) - */ - @EnterpriseEdition - @DELETE - ListenableFuture deleteVolume( - @EndpointLink("edit") @BinderParam(BindToPath.class) VolumeManagementDto volume); - - /** - * @see CloudApi#moveVolume(VolumeManagementDto, VirtualDatacenterDto) - */ - @EnterpriseEdition - @POST - @ExceptionParser(ReturnMovedVolume.class) - @Consumes(MovedVolumeDto.BASE_MEDIA_TYPE) - @Produces(LinksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture moveVolume( - @BinderParam(BindMoveVolumeToPath.class) VolumeManagementDto volume, - @BinderParam(BindVirtualDatacenterRefToPayload.class) VirtualDatacenterDto newVirtualDatacenter); +public interface CloudAsyncApi { + /*********************** Virtual Datacenter ***********************/ + + /** + * @see CloudApi#listVirtualDatacenters(VirtualDatacenterOptions) + */ + @GET + @Path("/virtualdatacenters") + @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualDatacenters(VirtualDatacenterOptions options); + + /** + * @see CloudApi#getVirtualDatacenter(Integer) + */ + @GET + @Path("/virtualdatacenters/{virtualdatacenter}") + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualDatacenter( + @PathParam("virtualdatacenter") Integer virtualDatacenterId); + + /** + * @see CloudApi#createVirtualDatacenter(VirtualDatacenterDto, Datacenter, + * Enterprise) + */ + @POST + @Path("/virtualdatacenters") + @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) + @Produces(VirtualDatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createVirtualDatacenter( + @BinderParam(BindToXMLPayload.class) final VirtualDatacenterDto virtualDatacenter, + @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter, + @QueryParam("enterprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise); + + /** + * @see CloudApi#updateVirtualDatacenter(VirtualDatacenterDto) + */ + @PUT + @Consumes(VirtualDatacenterDto.BASE_MEDIA_TYPE) + @Produces(VirtualDatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateVirtualDatacenter( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#deleteVirtualDatacenter(VirtualDatacenterDto) + */ + @DELETE + ListenableFuture deleteVirtualDatacenter( + @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto) + */ + @GET + @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAvailableTemplates( + @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#listAvailableTemplates(VirtualDatacenterDto, + * VirtualMachineTemplateOptions) + */ + @GET + @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAvailableTemplates( + @EndpointLink("templates") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + VirtualMachineTemplateOptions options); + + /** + * @see CloudApi#listStorageTiers(VirtualDatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(TiersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listStorageTiers( + @EndpointLink("tiers") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#getStorageTier(VirtualDatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(TierDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getStorageTier( + @EndpointLink("tiers") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(AppendToPath.class) Integer tierId); + + /*********************** Public IP ***********************/ + + /** + * @see CloudApi#listAvailablePublicIps(VirtualDatacenterDto, IpOptions) + */ + @GET + @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAvailablePublicIps( + @EndpointLink("topurchase") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + IpOptions options); + + /** + * @see CloudApi#listPurchasedPublicIps(VirtualDatacenterDto, IpOptions) + */ + @GET + @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPurchasedPublicIps( + @EndpointLink("purchased") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + IpOptions options); + + /** + * @see CloudApi#purchasePublicIp(PublicIpDto) + */ + @PUT + @Consumes(PublicIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture purchasePublicIp( + @EndpointLink("purchase") @BinderParam(BindToPath.class) PublicIpDto publicIp); + + /** + * @see CloudApi#releasePublicIp(PublicIpDto) + */ + @PUT + @Consumes(PublicIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture releasePublicIp( + @EndpointLink("release") @BinderParam(BindToPath.class) PublicIpDto publicIp); + + /*********************** Private Network ***********************/ + + /** + * @see CloudApi#listPrivateNetworks(VirtualDatacenter) + */ + @GET + @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPrivateNetworks( + @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#getPrivateNetwork(VirtualDatacenterDto, Integer) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getPrivateNetwork( + @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(AppendToPath.class) Integer privateNetworkId); + + /** + * @see CloudApi#createPrivateNetwork(VirtualDatacenterDto, VLANNetworkDto) + */ + @POST + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createPrivateNetwork( + @EndpointLink("privatenetworks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(BindToXMLPayload.class) VLANNetworkDto privateNetwork); + + /** + * @see CloudApi#updatePrivateNetwork(VLANNetworkDto) + */ + @PUT + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updatePrivateNetwork( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VLANNetworkDto privateNetwork); + + /** + * @see CloudApi#deletePrivateNetwork(VLANNetworkDto) + */ + @DELETE + ListenableFuture deletePrivateNetwork( + @EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto privateNetwork); + + /** + * @see CloudApi#getDefaultNetwork(VirtualDatacenterDto) + */ + @GET + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getDefaultNetwork( + @EndpointLink("defaultnetwork") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#setDefaultNetwork(VirtualDatacenterDto, VLANNetworkDto) + */ + @PUT + @Produces(LinksDto.BASE_MEDIA_TYPE) + ListenableFuture setDefaultNetwork( + @EndpointLink("defaultvlan") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(BindNetworkRefToPayload.class) VLANNetworkDto network); + + /*********************** Private Network IPs ***********************/ + + /** + * @see CloudApi#listPrivateNetworkIps(VLANNetworkDto) + */ + @GET + @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPrivateNetworkIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); + + /** + * @see CloudApi#listPrivateNetworkIps(VLANNetworkDto, IpOptions) + */ + @GET + @Consumes(PrivateIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPrivateNetworkIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); + + /** + * @see CloudApi#getPrivateNetworkIp(VLANNetworkDto, Integer) + */ + @GET + @Consumes(PrivateIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getPrivateNetworkIp( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, + @BinderParam(AppendToPath.class) Integer ipId); + + /*********************** Virtual Appliance ***********************/ + + /** + * @see CloudApi#listVirtualAppliances(VirtualDatacenterDto) + */ + @GET + @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualAppliances( + @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#getVirtualAppliance(VirtualDatacenterDto, Integer) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualAppliance( + @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(AppendToPath.class) Integer virtualApplianceId); + + /** + * @see CloudApi#getVirtualApplianceState(VirtualApplianceDto) + */ + @GET + @Consumes(VirtualApplianceStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualApplianceState( + @EndpointLink("state") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); + + /** + * @see CloudApi#createVirtualAppliance(VirtualDatacenterDto, + * VirtualApplianceDto) + */ + @POST + @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) + @Produces(VirtualApplianceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createVirtualAppliance( + @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(BindToXMLPayload.class) VirtualApplianceDto virtualAppliance); + + /** + * @see CloudApi#updateVirtualAppliance(VirtualApplianceDto) + */ + @PUT + @Consumes(VirtualApplianceDto.BASE_MEDIA_TYPE) + @Produces(VirtualApplianceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateVirtualAppliance( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualApplianceDto virtualAppliance); + + /** + * @see CloudApi#deleteVirtualAppliance(VirtualApplianceDto) + */ + @DELETE + ListenableFuture deleteVirtualAppliance( + @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); + + /** + * @see CloudApi#deleteVirtualAppliance(VirtualApplianceDto, + * VirtualApplianceOptions) + */ + @DELETE + ListenableFuture deleteVirtualAppliance( + @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + VirtualApplianceOptions options); + + /** + * @see CloudApi#deployVirtualAppliance(VirtualApplianceDto, + * VirtualMachineTaskDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> deployVirtualAppliance( + @EndpointLink("deploy") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); + + /** + * @see CloudApi#undeployVirtualAppliance(VirtualApplianceDto, + * VirtualMachineTaskDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> undeployVirtualAppliance( + @EndpointLink("undeploy") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); + + /** + * @see CloudApi#getVirtualAppliancePrice(VirtualApplianceDto) + */ + @GET + @Consumes(MediaType.TEXT_PLAIN) + @ResponseParser(ReturnStringIf2xx.class) + ListenableFuture getVirtualAppliancePrice( + @EndpointLink("price") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); + + /*********************** Virtual Machine ***********************/ + + /** + * @see CloudApi#listVirtualMachines(VirtualApplianceDto) + */ + @GET + @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachines( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance); + + /** + * @see CloudApi#listVirtualMachines(VirtualApplianceDto, + * VirtualMachineOptions) + */ + @GET + @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachines( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + VirtualMachineOptions options); + + /** + * @see CloudApi#getVirtualMachine(VirtualApplianceDto, Integer) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualMachine( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + @BinderParam(AppendToPath.class) Integer virtualMachineId); + + /** + * @see CloudApi#createVirtualMachine(VirtualApplianceDto, + * VirtualMachineWithNodeExtendedDto) + */ + @POST + @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createVirtualMachine( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) VirtualApplianceDto virtualAppliance, + @BinderParam(BindToXMLPayload.class) VirtualMachineWithNodeExtendedDto virtualMachine); + + /** + * @see CloudApi#deleteVirtualMachine(VirtualMachineDto) + */ + @DELETE + ListenableFuture deleteVirtualMachine( + @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#updateVirtualMachine(VirtualMachineWithNodeExtendedDto) + */ + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + ListenableFuture> updateVirtualMachine( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineWithNodeExtendedDto virtualMachine); + + /** + * @see CloudApi#updateVirtualMachine(VirtualMachineDto, + * VirtualMachineOptions) + */ + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + ListenableFuture> updateVirtualMachine( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineWithNodeExtendedDto virtualMachine, + VirtualMachineOptions options); + + /** + * @see CloudApi#changeVirtualMachineState(VirtualMachineDto, + * VirtualMachineStateDto) + */ + @PUT + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> changeVirtualMachineState( + @EndpointLink("state") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + @BinderParam(BindToXMLPayload.class) VirtualMachineStateDto state); + + /** + * @see CloudApi#getVirtualMachineState(VirtualMachineDto) + */ + @GET + @Consumes(VirtualMachineStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualMachineState( + @EndpointLink("state") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#listNetworkConfigurations(VirtualMachineDto) + */ + @GET + @Consumes(VMNetworkConfigurationsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listNetworkConfigurations( + @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#setGatewayNetwork(VirtualMachineDto, + * VMNetworkConfigurationDto) + */ + @PUT + @Produces(LinksDto.BASE_MEDIA_TYPE) + ListenableFuture setGatewayNetwork( + @EndpointLink("configurations") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + @BinderParam(BindNetworkConfigurationRefToPayload.class) VLANNetworkDto network); + + /** + * @see CloudApi#rebootVirtualMachine(VirtualMachineDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> rebootVirtualMachine( + @EndpointLink("reset") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /*********************** Virtual Machine Template ***********************/ + + /** + * @see CloudApi#getVirtualMachineTemplate(VirtualMachineTemplateDto) + */ + @GET + @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualMachineTemplate( + @EndpointLink("virtualmachinetemplate") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#listAttachedVolumes(VirtualMachineDto) + */ + @GET + @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAttachedVolumes( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#detachAllVolumes(VirtualMachineDto) + */ + @DELETE + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + ListenableFuture> detachAllVolumes( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#replaceVolumes(VirtualMachineDto, VirtualMachineOptions, + * VolumeManagementDto...) + */ + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(LinksDto.BASE_MEDIA_TYPE) + ListenableFuture> replaceVolumes( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + VirtualMachineOptions options, @BinderParam(BindVolumeRefsToPayload.class) VolumeManagementDto... volumes); + + /** + * @see CloudApi#listAttachedHardDisks(VirtualMachineDto) + */ + @GET + @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAttachedHardDisks( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#detachAllHardDisks(VirtualMachineDto) + */ + @DELETE + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + ListenableFuture> detachAllHardDisks( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine); + + /** + * @see CloudApi#replaceHardDisks(VirtualMachineDto, DiskManagementDto...) + */ + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(LinksDto.BASE_MEDIA_TYPE) + ListenableFuture> replaceHardDisks( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + @BinderParam(BindHardDiskRefsToPayload.class) DiskManagementDto... hardDisks); + + /** + * @see CloudApi#deployVirtualMachine(VirtualMachineDto, + * VirtualMachineTaskDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> deployVirtualMachine( + @EndpointLink("deploy") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); + + /** + * @see CloudApi#undeployVirtualMachine(VirtualMachineDto, + * VirtualMachineTaskDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineTaskDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture> undeployVirtualMachine( + @EndpointLink("undeploy") @BinderParam(BindToPath.class) VirtualMachineDto virtualMachine, + @BinderParam(BindToXMLPayload.class) VirtualMachineTaskDto task); + + /*********************** Hard disks ***********************/ + + /** + * @see CloudApi#listHardDisks(VirtualDatacenterDto) + */ + @GET + @Consumes(DisksManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listHardDisks( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#getHardDisk(VirtualDatacenterDto, Integer) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(DiskManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getHardDisk( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(AppendToPath.class) Integer diskId); + + /** + * @see CloudApi#createHardDisk(VirtualDatacenterDto, DiskManagementDto) + */ + @POST + @Consumes(DiskManagementDto.BASE_MEDIA_TYPE) + @Produces(DiskManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createHardDisk( + @EndpointLink("disks") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(BindToXMLPayload.class) DiskManagementDto hardDisk); + + /** + * @see CloudApi#deleteHardDisk(DiskManagementDto) + */ + @DELETE + ListenableFuture deleteHardDisk(@EndpointLink("edit") @BinderParam(BindToPath.class) DiskManagementDto hardDisk); + + /*********************** Volumes ***********************/ + + /** + * @see CloudApi#listVolumes(VirtualDatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVolumes( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter); + + /** + * @see CloudApi#listVolumes(VirtualDatacenterDto, VolumeOptions) + */ + @EnterpriseEdition + @GET + @Consumes(VolumesManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVolumes( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + VolumeOptions options); + + /** + * @see CloudApi#getVolume(VirtualDatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VolumeManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVolume( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(AppendToPath.class) Integer volumeId); + + /** + * @see CloudApi#createVolume(VirtualDatacenterDto, VolumeManagementDto) + */ + @EnterpriseEdition + @POST + @Consumes(VolumeManagementDto.BASE_MEDIA_TYPE) + @Produces(VolumeManagementDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createVolume( + @EndpointLink("volumes") @BinderParam(BindToPath.class) VirtualDatacenterDto virtualDatacenter, + @BinderParam(BindToXMLPayload.class) VolumeManagementDto volume); + + /** + * @see CloudApi#updateVolume(VolumeManagementDto) + */ + @EnterpriseEdition + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VolumeManagementDto.BASE_MEDIA_TYPE) + ListenableFuture> updateVolume( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VolumeManagementDto volume); + + /** + * @see CloudApi#updateVolume(VolumeManagementDto) + */ + @EnterpriseEdition + @DELETE + ListenableFuture deleteVolume(@EndpointLink("edit") @BinderParam(BindToPath.class) VolumeManagementDto volume); + + /** + * @see CloudApi#moveVolume(VolumeManagementDto, VirtualDatacenterDto) + */ + @EnterpriseEdition + @POST + @ExceptionParser(ReturnMovedVolume.class) + @Consumes(MovedVolumeDto.BASE_MEDIA_TYPE) + @Produces(LinksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture moveVolume( + @BinderParam(BindMoveVolumeToPath.class) VolumeManagementDto volume, + @BinderParam(BindVirtualDatacenterRefToPayload.class) VirtualDatacenterDto newVirtualDatacenter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigApi.java index 3e819ae42a..fee541be01 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigApi.java @@ -45,123 +45,132 @@ import com.abiquo.server.core.enterprise.PrivilegesDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface ConfigApi -{ - /*********************** License ***********************/ +public interface ConfigApi { + /*********************** License ***********************/ - /** - * List all licenses. - * - * @return The list of licenses. - */ - @EnterpriseEdition - LicensesDto listLicenses(); + /** + * List all licenses. + * + * @return The list of licenses. + */ + @EnterpriseEdition + LicensesDto listLicenses(); - /** - * List all active/inactive licenses. - * - * @param options Optional query params. - * @return The list of licenses. - */ - @EnterpriseEdition - LicensesDto listLicenses(LicenseOptions options); + /** + * List all active/inactive licenses. + * + * @param options + * Optional query params. + * @return The list of licenses. + */ + @EnterpriseEdition + LicensesDto listLicenses(LicenseOptions options); - /** - * Add a new license. - * - * @param license The license to add. - * @return The added license. - */ - @EnterpriseEdition - LicenseDto addLicense(LicenseDto license); + /** + * Add a new license. + * + * @param license + * The license to add. + * @return The added license. + */ + @EnterpriseEdition + LicenseDto addLicense(LicenseDto license); - /** - * Removes an existing license. - * - * @param license The license to delete. - */ - @EnterpriseEdition - void removeLicense(LicenseDto license); + /** + * Removes an existing license. + * + * @param license + * The license to delete. + */ + @EnterpriseEdition + void removeLicense(LicenseDto license); - /*********************** Privilege ***********************/ + /*********************** Privilege ***********************/ - /** - * List all privileges in the system. - * - * @return The list of privileges. - */ - PrivilegesDto listPrivileges(); + /** + * List all privileges in the system. + * + * @return The list of privileges. + */ + PrivilegesDto listPrivileges(); - /** - * Get the given privilege. - * - * @param privilegeId The id of the privilege. - * @return The privilege or null if it does not exist. - */ - PrivilegeDto getPrivilege(Integer privilegeId); + /** + * Get the given privilege. + * + * @param privilegeId + * The id of the privilege. + * @return The privilege or null if it does not exist. + */ + PrivilegeDto getPrivilege(Integer privilegeId); - /*********************** System Properties ***********************/ + /*********************** System Properties ***********************/ - /** - * List all system properties. - * - * @return The list of properties. - */ - SystemPropertiesDto listSystemProperties(); + /** + * List all system properties. + * + * @return The list of properties. + */ + SystemPropertiesDto listSystemProperties(); - /** - * List properties with options. - * - * @param options Optional query params. - * @return The list of system properties. - */ - SystemPropertiesDto listSystemProperties(PropertyOptions options); + /** + * List properties with options. + * + * @param options + * Optional query params. + * @return The list of system properties. + */ + SystemPropertiesDto listSystemProperties(PropertyOptions options); - /** - * Updates a system property. - * - * @param property The new attributes for the system property. - * @return The updated system property. - */ - SystemPropertyDto updateSystemProperty(SystemPropertyDto property); + /** + * Updates a system property. + * + * @param property + * The new attributes for the system property. + * @return The updated system property. + */ + SystemPropertyDto updateSystemProperty(SystemPropertyDto property); - /*********************** Category ***********************/ + /*********************** Category ***********************/ - /** - * List all categories. - * - * @return The list of categories. - */ - CategoriesDto listCategories(); + /** + * List all categories. + * + * @return The list of categories. + */ + CategoriesDto listCategories(); - /** - * Get the given category. - * - * @param categoryId The id of the category. - * @return The category or null if it does not exist. - */ - CategoryDto getCategory(Integer categoryId); + /** + * Get the given category. + * + * @param categoryId + * The id of the category. + * @return The category or null if it does not exist. + */ + CategoryDto getCategory(Integer categoryId); - /** - * Create a new category. - * - * @param icon The category to be created. - * @return The created category. - */ - CategoryDto createCategory(CategoryDto category); + /** + * Create a new category. + * + * @param icon + * The category to be created. + * @return The created category. + */ + CategoryDto createCategory(CategoryDto category); - /** - * Updates an existing category. - * - * @param category The new attributes for the category. - * @return The updated category. - */ - CategoryDto updateCategory(CategoryDto category); + /** + * Updates an existing category. + * + * @param category + * The new attributes for the category. + * @return The updated category. + */ + CategoryDto updateCategory(CategoryDto category); - /** - * Deletes an existing category. - * - * @param icon The category to delete. - */ - void deleteCategory(CategoryDto category); + /** + * Deletes an existing category. + * + * @param icon + * The category to delete. + */ + void deleteCategory(CategoryDto category); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigAsyncApi.java index d84ad5de9f..eeacd4a3a9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/ConfigAsyncApi.java @@ -63,149 +63,145 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/config") -public interface ConfigAsyncApi -{ - /*********************** License ***********************/ +public interface ConfigAsyncApi { + /*********************** License ***********************/ - /** - * @see ConfigApi#listLicenses() - */ + /** + * @see ConfigApi#listLicenses() + */ - @EnterpriseEdition - @GET - @Path("/licenses") - @Consumes(LicensesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLicenses(); + @EnterpriseEdition + @GET + @Path("/licenses") + @Consumes(LicensesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listLicenses(); - /** - * @see ConfigApi#listLicenses(LicenseOptions) - */ - @EnterpriseEdition - @GET - @Path("/licenses") - @Consumes(LicensesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLicenses(LicenseOptions options); + /** + * @see ConfigApi#listLicenses(LicenseOptions) + */ + @EnterpriseEdition + @GET + @Path("/licenses") + @Consumes(LicensesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listLicenses(LicenseOptions options); - /** - * @see ConfigApi#addLicense(LicenseDto) - */ - @EnterpriseEdition - @POST - @Produces(LicenseDto.BASE_MEDIA_TYPE) - @Consumes(LicenseDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Path("/licenses") - ListenableFuture addLicense(@BinderParam(BindToXMLPayload.class) LicenseDto license); + /** + * @see ConfigApi#addLicense(LicenseDto) + */ + @EnterpriseEdition + @POST + @Produces(LicenseDto.BASE_MEDIA_TYPE) + @Consumes(LicenseDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @Path("/licenses") + ListenableFuture addLicense(@BinderParam(BindToXMLPayload.class) LicenseDto license); - /** - * @see ConfigApi#removeLicense(LicenseDto) - */ - @DELETE - @EnterpriseEdition - ListenableFuture removeLicense( - @EndpointLink("edit") @BinderParam(BindToPath.class) LicenseDto license); + /** + * @see ConfigApi#removeLicense(LicenseDto) + */ + @DELETE + @EnterpriseEdition + ListenableFuture removeLicense(@EndpointLink("edit") @BinderParam(BindToPath.class) LicenseDto license); - /*********************** Privilege ***********************/ + /*********************** Privilege ***********************/ - /** - * @see ConfigApi#listPrivileges() - */ - @GET - @Path("/privileges") - @Consumes(PrivilegesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPrivileges(); + /** + * @see ConfigApi#listPrivileges() + */ + @GET + @Path("/privileges") + @Consumes(PrivilegesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPrivileges(); - /** - * @see ConfigApi#getPrivilege(Integer) - */ - @GET - @Path("/privileges/{privilege}") - @Consumes(PrivilegeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPrivilege(@PathParam("privilege") Integer privilegeId); + /** + * @see ConfigApi#getPrivilege(Integer) + */ + @GET + @Path("/privileges/{privilege}") + @Consumes(PrivilegeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPrivilege(@PathParam("privilege") Integer privilegeId); - /*********************** System Properties ***********************/ + /*********************** System Properties ***********************/ - /** - * @see ConfigApi#listSystemProperties() - */ - @GET - @Path("/properties") - @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSystemProperties(); + /** + * @see ConfigApi#listSystemProperties() + */ + @GET + @Path("/properties") + @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listSystemProperties(); - /** - * @see ConfigApi#listSystemProperties(PropertyOptions) - */ - @GET - @Path("/properties") - @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSystemProperties(PropertyOptions options); + /** + * @see ConfigApi#listSystemProperties(PropertyOptions) + */ + @GET + @Path("/properties") + @Consumes(SystemPropertiesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listSystemProperties(PropertyOptions options); - /** - * @see ConfigApi#updateSystemProperty(VirtualDatacenterDto) - */ - @PUT - @Produces(SystemPropertyDto.BASE_MEDIA_TYPE) - @Consumes(SystemPropertyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateSystemProperty( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) SystemPropertyDto property); + /** + * @see ConfigApi#updateSystemProperty(VirtualDatacenterDto) + */ + @PUT + @Produces(SystemPropertyDto.BASE_MEDIA_TYPE) + @Consumes(SystemPropertyDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateSystemProperty( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) SystemPropertyDto property); - /*********************** Category ***********************/ + /*********************** Category ***********************/ - /** - * @see ConfigApi#listCategories() - */ - @GET - @Path("/categories") - @Consumes(CategoriesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCategories(); + /** + * @see ConfigApi#listCategories() + */ + @GET + @Path("/categories") + @Consumes(CategoriesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listCategories(); - /** - * @see ConfigApi#getCategory(Integer) - */ - @GET - @Path("/categories/{category}") - @Consumes(CategoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCategory(@PathParam("category") Integer categoryId); + /** + * @see ConfigApi#getCategory(Integer) + */ + @GET + @Path("/categories/{category}") + @Consumes(CategoryDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCategory(@PathParam("category") Integer categoryId); - /** - * @see ConfigApi#createCategory(CategoryDto) - */ - @POST - @Path("/categories") - @Produces(CategoryDto.BASE_MEDIA_TYPE) - @Consumes(CategoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createCategory( - @BinderParam(BindToXMLPayload.class) CategoryDto category); + /** + * @see ConfigApi#createCategory(CategoryDto) + */ + @POST + @Path("/categories") + @Produces(CategoryDto.BASE_MEDIA_TYPE) + @Consumes(CategoryDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createCategory(@BinderParam(BindToXMLPayload.class) CategoryDto category); - /** - * @see ConfigApi#updateCategory(CategoryDto) - */ - @PUT - @Produces(CategoryDto.BASE_MEDIA_TYPE) - @Consumes(CategoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateCategory( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CategoryDto category); + /** + * @see ConfigApi#updateCategory(CategoryDto) + */ + @PUT + @Produces(CategoryDto.BASE_MEDIA_TYPE) + @Consumes(CategoryDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateCategory( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CategoryDto category); - /** - * @see ConfigApi#deleteCategory(CategoryDto) - */ - @DELETE - ListenableFuture deleteCategory( - @EndpointLink("edit") @BinderParam(BindToPath.class) CategoryDto category); + /** + * @see ConfigApi#deleteCategory(CategoryDto) + */ + @DELETE + ListenableFuture deleteCategory(@EndpointLink("edit") @BinderParam(BindToPath.class) CategoryDto category); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseApi.java index db01154f48..2cd716bd53 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseApi.java @@ -54,306 +54,350 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface EnterpriseApi -{ +public interface EnterpriseApi { - /*********************** Enterprise ********************** */ + /*********************** Enterprise ********************** */ - /** - * List all enterprises. - * - * @return The list of Enterprises. - */ - EnterprisesDto listEnterprises(); + /** + * List all enterprises. + * + * @return The list of Enterprises. + */ + EnterprisesDto listEnterprises(); - /** - * List enterprises with options. - * - * @param options Filtering options. - * @return The list of Enterprises. - */ - EnterprisesDto listEnterprises(EnterpriseOptions options); + /** + * List enterprises with options. + * + * @param options + * Filtering options. + * @return The list of Enterprises. + */ + EnterprisesDto listEnterprises(EnterpriseOptions options); - /** - * List filtered enterprises by datacenter. - * - * @param datacenter The given datacenter. - * @param options Filtering options. - * @return The list of Enterprises. - */ - EnterprisesDto listEnterprises(DatacenterDto datacenter, EnterpriseOptions options); + /** + * List filtered enterprises by datacenter. + * + * @param datacenter + * The given datacenter. + * @param options + * Filtering options. + * @return The list of Enterprises. + */ + EnterprisesDto listEnterprises(DatacenterDto datacenter, EnterpriseOptions options); - /** - * Create a new enterprise. - * - * @param enterprise The enterprise to be created. - * @return The created enterprise. - */ - EnterpriseDto createEnterprise(EnterpriseDto enterprise); + /** + * Create a new enterprise. + * + * @param enterprise + * The enterprise to be created. + * @return The created enterprise. + */ + EnterpriseDto createEnterprise(EnterpriseDto enterprise); - /** - * Get the given enterprise. - * - * @param enterpriseId The id of the enterprise. - * @return The enterprise or null if it does not exist. - */ - EnterpriseDto getEnterprise(Integer enterpriseId); + /** + * Get the given enterprise. + * + * @param enterpriseId + * The id of the enterprise. + * @return The enterprise or null if it does not exist. + */ + EnterpriseDto getEnterprise(Integer enterpriseId); - /** - * Updates an existing enterprise. - * - * @param enterprise The new attributes for the enterprise. - * @return The updated enterprise. - */ - EnterpriseDto updateEnterprise(EnterpriseDto enterprise); + /** + * Updates an existing enterprise. + * + * @param enterprise + * The new attributes for the enterprise. + * @return The updated enterprise. + */ + EnterpriseDto updateEnterprise(EnterpriseDto enterprise); - /** - * Deletes an existing enterprise. - * - * @param enterprise The enterprise to delete. - */ - void deleteEnterprise(EnterpriseDto enterprise); + /** + * Deletes an existing enterprise. + * + * @param enterprise + * The enterprise to delete. + */ + void deleteEnterprise(EnterpriseDto enterprise); - /** - * List the allowed datacenters to the given enterprise. - * - * @param enterpriseId The id of the enterprise. - * @return The allowed datacenters to the given enterprise. - */ - DatacentersDto listAllowedDatacenters(Integer enterpriseId); + /** + * List the allowed datacenters to the given enterprise. + * + * @param enterpriseId + * The id of the enterprise. + * @return The allowed datacenters to the given enterprise. + */ + DatacentersDto listAllowedDatacenters(Integer enterpriseId); - /** - * List all virtual datacenters of an enterprise. - * - * @param enterprise The given enterprise. - * @return The list of Datacenters. - */ - VirtualDatacentersDto listVirtualDatacenters(EnterpriseDto enterprise); + /** + * List all virtual datacenters of an enterprise. + * + * @param enterprise + * The given enterprise. + * @return The list of Datacenters. + */ + VirtualDatacentersDto listVirtualDatacenters(EnterpriseDto enterprise); - /*********************** Enterprise Properties ***********************/ + /*********************** Enterprise Properties ***********************/ - /** - * Get defined properties of the given enterprise. - * - * @param enterpriseId The enterprise id. - * @return Set of enterprise properties. - */ - @EnterpriseEdition - EnterprisePropertiesDto getEnterpriseProperties(EnterpriseDto enterprise); + /** + * Get defined properties of the given enterprise. + * + * @param enterpriseId + * The enterprise id. + * @return Set of enterprise properties. + */ + @EnterpriseEdition + EnterprisePropertiesDto getEnterpriseProperties(EnterpriseDto enterprise); - /** - * Updates the given enterprise properties set. - * - * @param properties The properties set. - * @return The updated properties. - */ - @EnterpriseEdition - EnterprisePropertiesDto updateEnterpriseProperties(EnterprisePropertiesDto properties); + /** + * Updates the given enterprise properties set. + * + * @param properties + * The properties set. + * @return The updated properties. + */ + @EnterpriseEdition + EnterprisePropertiesDto updateEnterpriseProperties(EnterprisePropertiesDto properties); - /*********************** Enterprise Limits ***********************/ + /*********************** Enterprise Limits ***********************/ - /** - * Allows the given enterprise to use the given datacenter with the given limits. - * - * @param enterprise The enterprise. - * @param datacenter The datacenter to allow to the given enterprise. - * @param limits The usage limits for the enterprise in the given datacenter. - * @return The usage limits for the enterprise in the given datacenter. - */ - DatacenterLimitsDto createLimits(final EnterpriseDto enterprise, - final DatacenterDto datacenter, final DatacenterLimitsDto limits); + /** + * Allows the given enterprise to use the given datacenter with the given + * limits. + * + * @param enterprise + * The enterprise. + * @param datacenter + * The datacenter to allow to the given enterprise. + * @param limits + * The usage limits for the enterprise in the given datacenter. + * @return The usage limits for the enterprise in the given datacenter. + */ + DatacenterLimitsDto createLimits(final EnterpriseDto enterprise, final DatacenterDto datacenter, + final DatacenterLimitsDto limits); - /** - * Retreives the limits for the given enterprise and datacenter. - * - * @param enterprise The enterprise. - * @param datacenter The datacenter. - * @return The usage limits for the enterprise in the given datacenter. - */ - DatacentersLimitsDto getLimits(EnterpriseDto enterprise, DatacenterDto datacenter); + /** + * Retreives the limits for the given enterprise and datacenter. + * + * @param enterprise + * The enterprise. + * @param datacenter + * The datacenter. + * @return The usage limits for the enterprise in the given datacenter. + */ + DatacentersLimitsDto getLimits(EnterpriseDto enterprise, DatacenterDto datacenter); - /** - * Retreives limits for the given enterprise and any datacenter. - * - * @param enterprise The enterprise. - * @return The usage limits for the enterprise on any datacenter. - */ - DatacentersLimitsDto listLimits(EnterpriseDto enterprise); + /** + * Retreives limits for the given enterprise and any datacenter. + * + * @param enterprise + * The enterprise. + * @return The usage limits for the enterprise on any datacenter. + */ + DatacentersLimitsDto listLimits(EnterpriseDto enterprise); - /** - * Updates an existing enterprise-datacenter limits. - * - * @param limits The new set of limits. - * @return The updated limits. - */ - DatacenterLimitsDto updateLimits(DatacenterLimitsDto limits); + /** + * Updates an existing enterprise-datacenter limits. + * + * @param limits + * The new set of limits. + * @return The updated limits. + */ + DatacenterLimitsDto updateLimits(DatacenterLimitsDto limits); - /** - * Deletes existing limits for a pair enterprise-datacenter. - * - * @param limits The limits to delete. - */ - void deleteLimits(DatacenterLimitsDto limits); + /** + * Deletes existing limits for a pair enterprise-datacenter. + * + * @param limits + * The limits to delete. + */ + void deleteLimits(DatacenterLimitsDto limits); - /*********************** User ********************** */ + /*********************** User ********************** */ - /** - * Retreives users of the given enterprise. - * - * @param enterprise The enterprise. - * @return The users of the enterprise. - */ - UsersDto listUsers(final EnterpriseDto enterprise); + /** + * Retreives users of the given enterprise. + * + * @param enterprise + * The enterprise. + * @return The users of the enterprise. + */ + UsersDto listUsers(final EnterpriseDto enterprise); - /** - * Create a new user in the given enterprise. - * - * @param enterprise The enterprise. - * @param user The user to be created. - * @return The created user. - */ - UserDto createUser(EnterpriseDto enterprise, UserDto user); + /** + * Create a new user in the given enterprise. + * + * @param enterprise + * The enterprise. + * @param user + * The user to be created. + * @return The created user. + */ + UserDto createUser(EnterpriseDto enterprise, UserDto user); - /** - * Get the given user from the given enterprise. - * - * @param enterprise The enterprise. - * @param userId The id of the user. - * @return The user or null if it does not exist. - */ - UserDto getUser(final EnterpriseDto enterprise, final Integer idUser); + /** + * Get the given user from the given enterprise. + * + * @param enterprise + * The enterprise. + * @param userId + * The id of the user. + * @return The user or null if it does not exist. + */ + UserDto getUser(final EnterpriseDto enterprise, final Integer idUser); - /** - * Updates an existing user. - * - * @param enterprise The new attributes for the user. - * @return The updated user. - */ - UserDto updateUser(UserDto user); + /** + * Updates an existing user. + * + * @param enterprise + * The new attributes for the user. + * @return The updated user. + */ + UserDto updateUser(UserDto user); - /** - * Deletes existing user. - * - * @param user The user to delete. - */ - void deleteUser(UserDto user); + /** + * Deletes existing user. + * + * @param user + * The user to delete. + */ + void deleteUser(UserDto user); - /** - * Retrieves list of virtual machines by user. - * - * @param user The user. - * @return The list of virtual machines of the user. - */ - VirtualMachinesWithNodeExtendedDto listVirtualMachines(final UserDto user); + /** + * Retrieves list of virtual machines by user. + * + * @param user + * The user. + * @return The list of virtual machines of the user. + */ + VirtualMachinesWithNodeExtendedDto listVirtualMachines(final UserDto user); - /*********************** Datacenter Repository ***********************/ + /*********************** Datacenter Repository ***********************/ - /** - * Get the given datacenter repository from the given enterprise. - * - * @param enterprise The enterprise. - * @param datacenterRepositoryId The id of the datacenter repository. - * @return The datacenter repository or null if it does not exist. - */ - DatacenterRepositoryDto getDatacenterRepository(final EnterpriseDto enterprise, - final Integer datacenterRepositoryId); + /** + * Get the given datacenter repository from the given enterprise. + * + * @param enterprise + * The enterprise. + * @param datacenterRepositoryId + * The id of the datacenter repository. + * @return The datacenter repository or null if it does not + * exist. + */ + DatacenterRepositoryDto getDatacenterRepository(final EnterpriseDto enterprise, final Integer datacenterRepositoryId); - /** - * Refreshes database with virtual machine templates existing in the repository filesystem. - * - * @param enterpriseId Id of the enterprise which information will be refreshed. - * @param datacenterRepositoryId Id of the datacenter repository contaning the templates. - */ - @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) - void refreshTemplateRepository(Integer enterpriseId, Integer datacenterRepositoryId); + /** + * Refreshes database with virtual machine templates existing in the + * repository filesystem. + * + * @param enterpriseId + * Id of the enterprise which information will be refreshed. + * @param datacenterRepositoryId + * Id of the datacenter repository contaning the templates. + */ + @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) + void refreshTemplateRepository(Integer enterpriseId, Integer datacenterRepositoryId); - /*********************** Network ***********************/ + /*********************** Network ***********************/ - /** - * List external networks of the enterprise - * - * @param enterprise The enterprise. - * @return The list of external networks created and assigned. - */ - @EnterpriseEdition - VLANNetworksDto listExternalNetworks(EnterpriseDto enterprise); + /** + * List external networks of the enterprise + * + * @param enterprise + * The enterprise. + * @return The list of external networks created and assigned. + */ + @EnterpriseEdition + VLANNetworksDto listExternalNetworks(EnterpriseDto enterprise); - /*********************** Cloud ***********************/ + /*********************** Cloud ***********************/ - /** - * Retrieves list of virtual appliances by the given enterprise. - * - * @param enterprise The enterprise. - * @return The list of virtual appliances of the enterprise. - */ - VirtualAppliancesDto listVirtualAppliances(EnterpriseDto enterprise); + /** + * Retrieves list of virtual appliances by the given enterprise. + * + * @param enterprise + * The enterprise. + * @return The list of virtual appliances of the enterprise. + */ + VirtualAppliancesDto listVirtualAppliances(EnterpriseDto enterprise); - /** - * List virtual machines for the enterprise - * - * @param enterprise The enterprise. - * @return The list of virtual machines by the enterprise. - */ - VirtualMachinesWithNodeExtendedDto listVirtualMachines(EnterpriseDto enterprise); + /** + * List virtual machines for the enterprise + * + * @param enterprise + * The enterprise. + * @return The list of virtual machines by the enterprise. + */ + VirtualMachinesWithNodeExtendedDto listVirtualMachines(EnterpriseDto enterprise); - /** - * List reserved machines for the enterprise - * - * @param enterprise The enterprise. - * @return The list of reserverd machines by the enterprise. - */ - MachinesDto listReservedMachines(EnterpriseDto enterprise); + /** + * List reserved machines for the enterprise + * + * @param enterprise + * The enterprise. + * @return The list of reserverd machines by the enterprise. + */ + MachinesDto listReservedMachines(EnterpriseDto enterprise); - /** - * List all template definitions in apps library. - * - * @param enterprise The enterprise. - * @return The list of template definitions by the enterprise. - */ - TemplateDefinitionListsDto listTemplateDefinitionLists(EnterpriseDto enterprise); + /** + * List all template definitions in apps library. + * + * @param enterprise + * The enterprise. + * @return The list of template definitions by the enterprise. + */ + TemplateDefinitionListsDto listTemplateDefinitionLists(EnterpriseDto enterprise); - /** - * Create a new template definition list in apps library in the given enterprise. - * - * @param enterprise The enterprise. - * @param template The template to be created. - * @return The created template. - */ - TemplateDefinitionListDto createTemplateDefinitionList(EnterpriseDto enterprise, - TemplateDefinitionListDto templateList); + /** + * Create a new template definition list in apps library in the given + * enterprise. + * + * @param enterprise + * The enterprise. + * @param template + * The template to be created. + * @return The created template. + */ + TemplateDefinitionListDto createTemplateDefinitionList(EnterpriseDto enterprise, + TemplateDefinitionListDto templateList); - /** - * Update an existing template definition list in apps library. - * - * @param template The template to be update. - * @return The updated template. - */ - TemplateDefinitionListDto updateTemplateDefinitionList(TemplateDefinitionListDto templateList); + /** + * Update an existing template definition list in apps library. + * + * @param template + * The template to be update. + * @return The updated template. + */ + TemplateDefinitionListDto updateTemplateDefinitionList(TemplateDefinitionListDto templateList); - /** - * Deletes existing user. - * - * @param user The user to delete. - */ - void deleteTemplateDefinitionList(TemplateDefinitionListDto templateList); + /** + * Deletes existing user. + * + * @param user + * The user to delete. + */ + void deleteTemplateDefinitionList(TemplateDefinitionListDto templateList); - /** - * Get the given template definition list from the given enterprise. - * - * @param enterprise The enterprise. - * @param templateListId The id of the template definition list. - * @return The list or null if it does not exist. - */ - TemplateDefinitionListDto getTemplateDefinitionList(final EnterpriseDto enterprise, - final Integer templateListId); + /** + * Get the given template definition list from the given enterprise. + * + * @param enterprise + * The enterprise. + * @param templateListId + * The id of the template definition list. + * @return The list or null if it does not exist. + */ + TemplateDefinitionListDto getTemplateDefinitionList(final EnterpriseDto enterprise, final Integer templateListId); - /** - * Get the list of status of a template definition list in a datacenter. - * - * @param templateList The template definition list. - * @param datacenter The given datacenter. - * @return The list of states. - */ - TemplatesStateDto listTemplateListStatus(TemplateDefinitionListDto templateList, - DatacenterDto datacenter); + /** + * Get the list of status of a template definition list in a datacenter. + * + * @param templateList + * The template definition list. + * @param datacenter + * The given datacenter. + * @return The list of states. + */ + TemplatesStateDto listTemplateListStatus(TemplateDefinitionListDto templateList, DatacenterDto datacenter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseAsyncApi.java index 3838fbc9af..c77af99c0a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EnterpriseAsyncApi.java @@ -75,351 +75,342 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/admin") -public interface EnterpriseAsyncApi -{ - /*********************** Enterprise ***********************/ +public interface EnterpriseAsyncApi { + /*********************** Enterprise ***********************/ - /** - * @see EnterpriseApi#listEnterprises() - */ - @GET - @Path("/enterprises") - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises(); + /** + * @see EnterpriseApi#listEnterprises() + */ + @GET + @Path("/enterprises") + @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listEnterprises(); - /** - * @see EnterpriseApi#listEnterprises(EnterpriseOptions) - */ - @GET - @Path("/enterprises") - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises(EnterpriseOptions options); + /** + * @see EnterpriseApi#listEnterprises(EnterpriseOptions) + */ + @GET + @Path("/enterprises") + @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listEnterprises(EnterpriseOptions options); - /** - * @see EnterpriseApi#listEnterprises(DatacenterDto, EnterpriseOptions) - */ - @GET - @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEnterprises( - @EndpointLink("enterprises") @BinderParam(BindToPath.class) DatacenterDto datacenter, - EnterpriseOptions options); + /** + * @see EnterpriseApi#listEnterprises(DatacenterDto, EnterpriseOptions) + */ + @GET + @Consumes(EnterprisesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listEnterprises( + @EndpointLink("enterprises") @BinderParam(BindToPath.class) DatacenterDto datacenter, EnterpriseOptions options); - /** - * @see EnterpriseApi#createEnterprise(EnterpriseDto) - */ - @POST - @Path("/enterprises") - @Produces(EnterpriseDto.BASE_MEDIA_TYPE) - @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createEnterprise( - @BinderParam(BindToXMLPayload.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#createEnterprise(EnterpriseDto) + */ + @POST + @Path("/enterprises") + @Produces(EnterpriseDto.BASE_MEDIA_TYPE) + @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createEnterprise(@BinderParam(BindToXMLPayload.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#getEnterprise(Integer) - */ - @GET - @Path("/enterprises/{enterprise}") - @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getEnterprise(@PathParam("enterprise") Integer enterpriseId); + /** + * @see EnterpriseApi#getEnterprise(Integer) + */ + @GET + @Path("/enterprises/{enterprise}") + @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getEnterprise(@PathParam("enterprise") Integer enterpriseId); - /** - * @see EnterpriseApi#updateEnterprise(EnterpriseDto) - */ - @PUT - @Produces(EnterpriseDto.BASE_MEDIA_TYPE) - @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateEnterprise( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#updateEnterprise(EnterpriseDto) + */ + @PUT + @Produces(EnterpriseDto.BASE_MEDIA_TYPE) + @Consumes(EnterpriseDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateEnterprise( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#deleteEnterprise(EnterpriseDto) - */ - @DELETE - ListenableFuture deleteEnterprise( - @EndpointLink("edit") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#deleteEnterprise(EnterpriseDto) + */ + @DELETE + ListenableFuture deleteEnterprise(@EndpointLink("edit") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#listAllowedDatacenters(Integer) - */ - @GET - @Path("/datacenters") - @Consumes(DatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listAllowedDatacenters( - @QueryParam("idEnterprise") Integer enterpriseId); + /** + * @see EnterpriseApi#listAllowedDatacenters(Integer) + */ + @GET + @Path("/datacenters") + @Consumes(DatacentersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listAllowedDatacenters(@QueryParam("idEnterprise") Integer enterpriseId); - /** - * @see EnterpriseApi#listVirtualDatacenters(EnterpriseDto) - */ - @GET - @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualDatacenters( - @EndpointLink("cloud/virtualdatacenters") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listVirtualDatacenters(EnterpriseDto) + */ + @GET + @Consumes(VirtualDatacentersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualDatacenters( + @EndpointLink("cloud/virtualdatacenters") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /*********************** Enterprise Properties ***********************/ + /*********************** Enterprise Properties ***********************/ - /** - * @see EnterpriseApi#getEnterpriseProperties(EnterpriseDto) - */ - @EnterpriseEdition - @GET - @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getEnterpriseProperties( - @EndpointLink("properties") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#getEnterpriseProperties(EnterpriseDto) + */ + @EnterpriseEdition + @GET + @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getEnterpriseProperties( + @EndpointLink("properties") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#updateEnterpriseProperties(EnterprisePropertiesDto) - */ - @EnterpriseEdition - @PUT - @Produces(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateEnterpriseProperties( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) EnterprisePropertiesDto properties); + /** + * @see EnterpriseApi#updateEnterpriseProperties(EnterprisePropertiesDto) + */ + @EnterpriseEdition + @PUT + @Produces(EnterprisePropertiesDto.BASE_MEDIA_TYPE) + @Consumes(EnterprisePropertiesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateEnterpriseProperties( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) EnterprisePropertiesDto properties); - /*********************** Enterprise Limits ***********************/ + /*********************** Enterprise Limits ***********************/ - /** - * @see EnterpriseApi#createLimits(EnterpriseDto, DatacenterDto, DatacenterLimitsDto) - */ - @POST - @Produces(DatacenterLimitsDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createLimits( - @EndpointLink("limits") @BinderParam(BindToPath.class) final EnterpriseDto enterprise, - @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) DatacenterLimitsDto limits); + /** + * @see EnterpriseApi#createLimits(EnterpriseDto, DatacenterDto, + * DatacenterLimitsDto) + */ + @POST + @Produces(DatacenterLimitsDto.BASE_MEDIA_TYPE) + @Consumes(DatacenterLimitsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createLimits( + @EndpointLink("limits") @BinderParam(BindToPath.class) final EnterpriseDto enterprise, + @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) DatacenterLimitsDto limits); - /** - * @see EnterpriseApi#getLimits(EnterpriseDto, DatacenterDto) - */ - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getLimits( - @EndpointLink("limits") @BinderParam(BindToPath.class) final EnterpriseDto enterprise, - @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter); + /** + * @see EnterpriseApi#getLimits(EnterpriseDto, DatacenterDto) + */ + @GET + @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getLimits( + @EndpointLink("limits") @BinderParam(BindToPath.class) final EnterpriseDto enterprise, + @QueryParam("datacenter") @ParamParser(ParseDatacenterId.class) final DatacenterDto datacenter); - /** - * @see EnterpriseApi#updateLimits(DatacenterLimitsDto) - */ - @PUT - @Produces(DatacenterLimitsDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateLimits( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) DatacenterLimitsDto limits); + /** + * @see EnterpriseApi#updateLimits(DatacenterLimitsDto) + */ + @PUT + @Produces(DatacenterLimitsDto.BASE_MEDIA_TYPE) + @Consumes(DatacenterLimitsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateLimits( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) DatacenterLimitsDto limits); - /** - * @see EnterpriseApi#deleteLimits(DatacenterLimitsDto) - */ - @DELETE - ListenableFuture deleteLimits( - @EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterLimitsDto limits); + /** + * @see EnterpriseApi#deleteLimits(DatacenterLimitsDto) + */ + @DELETE + ListenableFuture deleteLimits(@EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterLimitsDto limits); - /** - * @see EnterpriseApi#listLimits(EnterpriseDto) - */ - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLimits( - @EndpointLink("limits") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listLimits(EnterpriseDto) + */ + @GET + @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listLimits( + @EndpointLink("limits") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /*********************** User ***********************/ + /*********************** User ***********************/ - /** - * @see EnterpriseApi#listUsers(EnterpriseDto) - */ - @GET - @Consumes(UsersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUsers( - @EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listUsers(EnterpriseDto) + */ + @GET + @Consumes(UsersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listUsers(@EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#getUser(EnterpriseDto, Integer) - */ - @GET - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getUser( - @EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer userId); + /** + * @see EnterpriseApi#getUser(EnterpriseDto, Integer) + */ + @GET + @Consumes(UserDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getUser(@EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(AppendToPath.class) Integer userId); - /** - * @see EnterpriseApi#createUser(EnterpriseDto) - */ - @POST - @Produces(UserDto.BASE_MEDIA_TYPE) - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createUser( - @EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(BindToXMLPayload.class) UserDto user); + /** + * @see EnterpriseApi#createUser(EnterpriseDto) + */ + @POST + @Produces(UserDto.BASE_MEDIA_TYPE) + @Consumes(UserDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createUser(@EndpointLink("users") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(BindToXMLPayload.class) UserDto user); - /** - * @see EnterpriseApi#updateUser(UserDto) - */ - @PUT - @Produces(UserDto.BASE_MEDIA_TYPE) - @Consumes(UserDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateUser( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) UserDto user); + /** + * @see EnterpriseApi#updateUser(UserDto) + */ + @PUT + @Produces(UserDto.BASE_MEDIA_TYPE) + @Consumes(UserDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateUser(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) UserDto user); - /** - * @see EnterpriseApi#deleteUser(UserDto) - */ - @DELETE - ListenableFuture deleteUser( - @EndpointLink("edit") @BinderParam(BindToPath.class) UserDto user); + /** + * @see EnterpriseApi#deleteUser(UserDto) + */ + @DELETE + ListenableFuture deleteUser(@EndpointLink("edit") @BinderParam(BindToPath.class) UserDto user); - /** - * @see EnterpriseApi#listVirtualMachines(UserDto) - */ - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) final UserDto user); + /** + * @see EnterpriseApi#listVirtualMachines(UserDto) + */ + @GET + @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachines( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) final UserDto user); - /*********************** Datacenter Repository ***********************/ + /*********************** Datacenter Repository ***********************/ - /** - * @see EnterpriseApi#getDatacenterRepository(EnterpriseDto, Integer) - */ - @GET - @Consumes(DatacenterRepositoryDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getDatacenterRepository( - @EndpointLink("datacenterrepositories") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer datacenterRepositoryId); + /** + * @see EnterpriseApi#getDatacenterRepository(EnterpriseDto, Integer) + */ + @GET + @Consumes(DatacenterRepositoryDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getDatacenterRepository( + @EndpointLink("datacenterrepositories") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(AppendToPath.class) Integer datacenterRepositoryId); - /** - * @see EnterpriseApi#refreshTemplateRepository(Integer, Integer) - */ - @PUT - @Path("/enterprises/{enterprise}/datacenterrepositories/{datacenterrepository}/actions/refresh") - ListenableFuture refreshTemplateRepository(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId); + /** + * @see EnterpriseApi#refreshTemplateRepository(Integer, Integer) + */ + @PUT + @Path("/enterprises/{enterprise}/datacenterrepositories/{datacenterrepository}/actions/refresh") + ListenableFuture refreshTemplateRepository(@PathParam("enterprise") Integer enterpriseId, + @PathParam("datacenterrepository") Integer datacenterRepositoryId); - /*********************** External Network ***********************/ + /*********************** External Network ***********************/ - /** - * @see EnterpriseApi#listExternalNetworks(EnterpriseDto) - */ - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalNetworks( - @EndpointLink("externalnetworks") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listExternalNetworks(EnterpriseDto) + */ + @EnterpriseEdition + @GET + @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listExternalNetworks( + @EndpointLink("externalnetworks") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /*********************** Cloud ***********************/ + /*********************** Cloud ***********************/ - /** - * @see EnterpriseApi#listVirtualAppliances(EnterpriseDto) - */ - @GET - @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualAppliances( - @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) final EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listVirtualAppliances(EnterpriseDto) + */ + @GET + @Consumes(VirtualAppliancesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualAppliances( + @EndpointLink("virtualappliances") @BinderParam(BindToPath.class) final EnterpriseDto enterprise); - /** - * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) - */ - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachines( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) + */ + @GET + @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachines( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /*********************** Machine ***********************/ + /*********************** Machine ***********************/ - /** - * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) - */ - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listReservedMachines( - @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listVirtualMachines(EnterpriseDto) + */ + @GET + @Consumes(MachinesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listReservedMachines( + @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /*********************** Template definition list ***********************/ + /*********************** Template definition list ***********************/ - /** - * @see EnterpriseApi#listTemplateDefinitionLists(EnterpriseDto) - */ - @GET - @Consumes(TemplateDefinitionListsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTemplateDefinitionLists( - @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise); + /** + * @see EnterpriseApi#listTemplateDefinitionLists(EnterpriseDto) + */ + @GET + @Consumes(TemplateDefinitionListsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listTemplateDefinitionLists( + @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise); - /** - * @see EnterpriseApi#createTemplateDefinitionList(EnterpriseDto, TemplateDefinitionListDto) - */ - @POST - @Produces(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createTemplateDefinitionList( - @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(BindToXMLPayload.class) TemplateDefinitionListDto templateList); + /** + * @see EnterpriseApi#createTemplateDefinitionList(EnterpriseDto, + * TemplateDefinitionListDto) + */ + @POST + @Produces(TemplateDefinitionListDto.BASE_MEDIA_TYPE) + @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createTemplateDefinitionList( + @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(BindToXMLPayload.class) TemplateDefinitionListDto templateList); - /** - * @see EnterpriseApi#updateTemplateDefinitionList(TemplateDefinitionListDto) - */ - @PUT - @Produces(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateTemplateDefinitionList( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) TemplateDefinitionListDto templateList); + /** + * @see EnterpriseApi#updateTemplateDefinitionList(TemplateDefinitionListDto) + */ + @PUT + @Produces(TemplateDefinitionListDto.BASE_MEDIA_TYPE) + @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateTemplateDefinitionList( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) TemplateDefinitionListDto templateList); - /** - * @see EnterpriseApi#deleteTemplateDefinitionList(EnterpriseDto) - */ - @DELETE - ListenableFuture deleteTemplateDefinitionList( - @EndpointLink("edit") @BinderParam(BindToPath.class) TemplateDefinitionListDto templateList); + /** + * @see EnterpriseApi#deleteTemplateDefinitionList(EnterpriseDto) + */ + @DELETE + ListenableFuture deleteTemplateDefinitionList( + @EndpointLink("edit") @BinderParam(BindToPath.class) TemplateDefinitionListDto templateList); - /** - * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) - */ - @GET - @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getTemplateDefinitionList( - @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendToPath.class) Integer templateListId); + /** + * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) + */ + @GET + @Consumes(TemplateDefinitionListDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getTemplateDefinitionList( + @EndpointLink("appslib/templateDefinitionLists") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(AppendToPath.class) Integer templateListId); - /** - * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) - */ - @GET - @Consumes(TemplatesStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTemplateListStatus( - @EndpointLink("repositoryStatus") @BinderParam(BindToPath.class) TemplateDefinitionListDto templateList, - @QueryParam("datacenterId") @ParamParser(ParseDatacenterId.class) DatacenterDto datacenter); + /** + * @see EnterpriseApi#getTemplateDefinitionList(EnterpriseDto, Integer) + */ + @GET + @Consumes(TemplatesStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listTemplateListStatus( + @EndpointLink("repositoryStatus") @BinderParam(BindToPath.class) TemplateDefinitionListDto templateList, + @QueryParam("datacenterId") @ParamParser(ParseDatacenterId.class) DatacenterDto datacenter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventApi.java index 39b6055f82..b6730af9fa 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventApi.java @@ -36,19 +36,18 @@ import com.abiquo.server.core.event.EventsDto; * @author Vivien Mahé */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface EventApi -{ - /** - * List events. - * - * @return The list of events. - */ - EventsDto listEvents(); +public interface EventApi { + /** + * List events. + * + * @return The list of events. + */ + EventsDto listEvents(); - /** - * List events using filters. - * - * @return The list of events using filters. - */ - EventsDto listEvents(EventOptions options); + /** + * List events using filters. + * + * @return The list of events using filters. + */ + EventsDto listEvents(EventOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventAsyncApi.java index ac7580d0cb..5bdbc926f3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/EventAsyncApi.java @@ -41,24 +41,23 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Vivien Mahé */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) -public interface EventAsyncApi -{ - /** - * @see EventApi#listEvents() - */ - @GET - @Path("/events") - @Consumes(EventsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEvents(); +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) +public interface EventAsyncApi { + /** + * @see EventApi#listEvents() + */ + @GET + @Path("/events") + @Consumes(EventsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listEvents(); - /** - * @see EventApi#listEvents() - */ - @GET - @Path("/events") - @Consumes(EventsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listEvents(EventOptions options); + /** + * @see EventApi#listEvents() + */ + @GET + @Path("/events") + @Consumes(EventsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listEvents(EventOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java index 38d57230f6..8ea854abb2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java @@ -83,956 +83,1126 @@ import com.abiquo.server.core.infrastructure.storage.TiersDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface InfrastructureApi -{ - /*********************** Datacenter ***********************/ - - /** - * List all datacenters. - * - * @return The list of Datacenters. - */ - DatacentersDto listDatacenters(); - - /** - * Create a new datacenter. - * - * @param datacenter The datacenter to be created. - * @return The created datacenter. - */ - DatacenterDto createDatacenter(DatacenterDto datacenter); - - /** - * Get the given datacenter. - * - * @param datacenterId The id of the datacenter. - * @return The datacenter or null if it does not exist. - */ - DatacenterDto getDatacenter(Integer datacenterId); - - /** - * Updates an existing datacenter. - * - * @param datacenter The new attributes for the datacenter. - * @return The updated datacenter. - */ - DatacenterDto updateDatacenter(DatacenterDto datacenter); - - /** - * Deletes an existing datacenter. - * - * @param datacenter The datacenter to delete. - */ - void deleteDatacenter(DatacenterDto datacenter); - - /** - * Retrieve remote machine information. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveremotemachineinformation - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - MachineDto discoverSingleMachine(DatacenterDto datacenter, String ip, - HypervisorType hypervisorType, String user, String password); - - /** - * Retrieve remote machine information. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrieveremotemachineinformation - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param options Optional query params. - * @return The physical machine. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - MachineDto discoverSingleMachine(DatacenterDto datacenter, String ip, - HypervisorType hypervisorType, String user, String password, MachineOptions options); - - /** - * Retrieve a list of remote machine information. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievealistofremotemachineinformation - * @param datacenter The datacenter. - * @param ipFrom IP address of the remote first hypervisor to check. - * @param ipTo IP address of the remote last hypervisor to check. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine list. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - MachinesDto discoverMultipleMachines(final DatacenterDto datacenter, final String ipFrom, - final String ipTo, final HypervisorType hypervisorType, final String user, - final String password); - - /** - * Retrieve a list of remote machine information. - * - * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource- - * Retrievealistofremotemachineinformation - * @param datacenter The datacenter. - * @param ipFrom IP address of the remote first hypervisor to check. - * @param ipTo IP address of the remote last hypervisor to check. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param options Optional query params. - * @return The physical machine list. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - MachinesDto discoverMultipleMachines(final DatacenterDto datacenter, final String ipFrom, - final String ipTo, final HypervisorType hypervisorType, final String user, - final String password, final MachineOptions options); - - /** - * Retreives limits for the given datacenter and any enterprise. - * - * @param datacenter The datacenter. - * @return The usage limits for the datacenter on any enterprise. - */ - DatacentersLimitsDto listLimits(DatacenterDto datacenter); - - /** - * Check the state of a remote machine. This machine does not need to be managed by Abiquo. - * - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @return The physical machine state information. - */ - MachineStateDto checkMachineState(DatacenterDto datacenter, String ip, - HypervisorType hypervisorType, String user, String password); - - /** - * Check the state of a remote machine. This machine does not need to be managed by Abiquo. - * - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param hypervisorType Kind of hypervisor we want to connect. Valid values are {vbox, kvm, - * xen-3, vmx-04, hyperv-301, xenserver}. - * @param user User to log in. - * @param password Password to authenticate. - * @param options Optional query params. - * @return The physical machine state information. - */ - MachineStateDto checkMachineState(DatacenterDto datacenter, String ip, - HypervisorType hypervisorType, String user, String password, MachineOptions options); - - /** - * Check the ipmi configuration state of a remote machine. This machine does not need to be - * managed by Abiquo. - * - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param user User to log in. - * @param password Password to authenticate. - * @return The ipmi configuration state information - */ - MachineIpmiStateDto checkMachineIpmiState(DatacenterDto datacenter, String ip, String user, - String password); - - /** - * Check the ipmi configuration state of a remote machine. This machine does not need to be - * managed by Abiquo. - * - * @param datacenter The datacenter. - * @param ip IP address of the remote hypervisor to connect. - * @param user User to log in. - * @param password Password to authenticate. - * @param options Optional query params. - * @return The ipmi configuration state information - */ - MachineIpmiStateDto checkMachineIpmiState(DatacenterDto datacenter, String ip, String user, - String password, IpmiOptions options); - - /*********************** Hypervisor ***********************/ - - /** - * Retreives the hypervisor type of a remote a machine. - * - * @param datacenter The datacenter. - * @param options Optional query params. - * @return The hypervisor type. - */ - String getHypervisorTypeFromMachine(DatacenterDto datacenter, DatacenterOptions options); - - /** - * Retreives the hypervisor types in the datacenter. - * - * @param datacenter The datacenter. - * @return The hypervisor types. - */ - HypervisorTypesDto getHypervisorTypes(DatacenterDto datacenter); - - /*********************** Unmanaged Rack ********************** */ - - /** - * List all not managed racks for a datacenter. - * - * @param datacenter The datacenter. - * @return The list of not managed racks for the datacenter. - */ - RacksDto listRacks(DatacenterDto datacenter); - - /** - * Create a new not managed rack in a datacenter. - * - * @param datacenter The datacenter. - * @param rack The rack to be created. - * @return The created rack. - */ - RackDto createRack(final DatacenterDto datacenter, final RackDto rack); - - /** - * Get the given rack from the given datacenter. - * - * @param datacenter The datacenter. - * @param rackId The id of the rack. - * @return The rack or null if it does not exist. - */ - RackDto getRack(DatacenterDto datacenter, Integer rackId); - - /** - * Updates an existing rack from the given datacenter. - * - * @param rack The new attributes for the rack. - * @return The updated rack. - */ - RackDto updateRack(final RackDto rack); - - /** - * Deletes an existing rack. - * - * @param rack The rack to delete. - */ - void deleteRack(final RackDto rack); - - /*********************** Managed Rack **********************/ - - /** - * List all managed racks for a datacenter. - * - * @param datacenter The datacenter. - * @return The list of managed racks for the datacenter. - */ - @EnterpriseEdition - @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) - UcsRacksDto listManagedRacks(DatacenterDto datacenter); - - /** - * Create a new managed rack in a datacenter. - * - * @param datacenter The datacenter. - * @param rack The managed rack to be created. - * @return The created rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - UcsRackDto createManagedRack(final DatacenterDto datacenter, final UcsRackDto rack); - - /** - * Get the given managed rack from the given datacenter. - * - * @param datacenter The datacenter. - * @param rackId The id of the rack. - * @return The rack or null if it does not exist. - */ - @EnterpriseEdition - @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) - UcsRackDto getManagedRack(DatacenterDto datacenter, Integer rackId); - - /** - * Updates an existing managed rack from the given datacenter. - * - * @param rack The new attributes for the rack. - * @return The updated rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - UcsRackDto updateManagedRack(final UcsRackDto rack); - - /** - * List all service profiles of the ucs rack. - * - * @param rack The ucs rack. - * @return The list of service profiles for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - LogicServersDto listServiceProfiles(UcsRackDto rack); - - /** - * List service profiles of the ucs rack with filtering options. - * - * @param rack The ucs rack. - * @param options Optional query params. - * @return The list of service profiles for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - LogicServersDto listServiceProfiles(UcsRackDto rack, FilterOptions options); - - /** - * List all service profile templates of the ucs rack. - * - * @param rack The ucs rack. - * @return The list of service profile templates for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - LogicServersDto listServiceProfileTemplates(UcsRackDto rack); - - /** - * List all service profile templates of the ucs rack with options. - * - * @param rack The ucs rack. - * @param options Optional query params. - * @return The list of service profile templates for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - LogicServersDto listServiceProfileTemplates(UcsRackDto rack, FilterOptions options); - - /** - * List all organizations of the ucs rack. - * - * @param rack The ucs rack. - * @return The list of organizations for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - OrganizationsDto listOrganizations(UcsRackDto rack); - - /** - * List all organizations of the ucs rack with options. - * - * @param rack The ucs rack. - * @param options Optional query params. - * @return The list of organizations for the rack. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - OrganizationsDto listOrganizations(UcsRackDto rack, FilterOptions options); - - /** - * Clone a service profile. - * - * @param rack The managed rack where thw service profile will be created. - * @param logicServer The original logic server. - * @param organization The organization to be associated. - * @param newName The name of the new service profile. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void cloneLogicServer(UcsRackDto rack, LogicServerDto logicServer, - OrganizationDto organization, String newName); - - /** - * Delete a service profile. - * - * @param rack The managed rack where the service profile will be created. - * @param logicServer The original logic server. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void deleteLogicServer(UcsRackDto rack, LogicServerDto logicServer); - - /** - * Associate a service profile with a blade. - * - * @param rack The managed rack where the service profile is. - * @param logicServer The logic server. - * @param organization The organization to be associated. - * @param bladeName The name of the blade. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void associateLogicServer(UcsRackDto rack, LogicServerDto logicServer, - OrganizationDto organization, String bladeName); - - /** - * Associate a service profile with a blade instantiating a service profile template. - * - * @param rack The managed rack where the service profile is. - * @param logicServer The logic server. - * @param organization The organization to be associated. - * @param newName Name of the new service profile. - * @param bladeName The name of the blade. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void associateTemplate(UcsRackDto rack, LogicServerDto logicServer, - OrganizationDto organization, String newName, String bladeName); - - /** - * Clone a service profile and associate it with a blade. - * - * @param rack The managed rack where the service profile is. - * @param logicServer The logic server. - * @param organization The organization to be associated. - * @param newName Name of the new service profile. - * @param bladeName The name of the blade. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void cloneAndAssociateLogicServer(UcsRackDto rack, LogicServerDto logicServer, - OrganizationDto organization, String newName, String bladeName); - - /** - * Dissociate a service profile from a blade. - * - * @param rack The managed rack where the service profile is. - * @param logicServer The logic server. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - void dissociateLogicServer(UcsRackDto rack, LogicServerDto logicServer); - - /** - * Get FSM list of an entity - * - * @param rack The managed rack where the entity belongs. - * @param dn Distinguished name of the entity. - * @param fsm The fsm. - */ - @EnterpriseEdition - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - FsmsDto listFsms(UcsRackDto rack, String dn); - - /*********************** Remote Service ********************** */ - - /** - * List all remote services of the datacenter. - * - * @param datacenter The datacenter. - * @return The list of remote services for the datacenter. - */ - RemoteServicesDto listRemoteServices(DatacenterDto dataceter); - - /** - * Create a new remote service in a datacenter. - * - * @param datacenter The datacenter. - * @param remoteService The remote service to be created. - * @return The created remote service. - */ - RemoteServiceDto createRemoteService(final DatacenterDto datacenter, - final RemoteServiceDto remoteService); - - /** - * Get the given remote service from the given datacenter. - * - * @param datacenter The datacenter. - * @param remoteServiceType The type of the remote service. - * @return The remote service or null if it does not exist. - */ - RemoteServiceDto getRemoteService(DatacenterDto datacenter, RemoteServiceType remoteServiceType); - - /** - * Updates an existing remote service from the given datacenter. - * - * @param remoteService The new attributes for the remote service. - * @return The updated remote service. - */ - RemoteServiceDto updateRemoteService(RemoteServiceDto remoteService); - - /** - * Deletes an existing remote service. - * - * @param remoteService The remote service to delete. - */ - void deleteRemoteService(RemoteServiceDto remoteService); - - /** - * Check if the given remote service is available and properly configured. - * - * @param remoteService The remote service to check. - * @return A Boolean indicating if the remote service is available. - */ - boolean isAvailable(RemoteServiceDto remoteService); - - /*********************** Machine ********************** */ - - /** - * Create a new physical machine in a rack. - * - * @param rack The rack. - * @param machine The physical machine to be created. - * @return The created physical machine. - */ - MachineDto createMachine(RackDto rack, MachineDto machine); - - /** - * Get the given machine from the given rack. - * - * @param rack The rack. - * @param machineId The id of the machine. - * @return The machine or null if it does not exist. - */ - MachineDto getMachine(RackDto rack, Integer machineId); - - /** - * Checks the real infrastructure state for the given physical machine. The machine is updated - * with the result state. - * - * @param machine The machine to check - * @paran boolean that indicates a database synchronization - * @return A machineStateDto with a machine state value from enum MachineState - */ - MachineStateDto checkMachineState(MachineDto machine, boolean sync); - - /** - * Checks the ipmi configuration state for the given physical machine. - * - * @param machine The machine to check - * @return A machineIpmiStateDto with a machine ipmi configuration state value from enum - * MachineState - */ - MachineIpmiStateDto checkMachineIpmiState(MachineDto machine); - - /** - * Updates an existing physical machine. - * - * @param machine The new attributes for the physical machine. - * @return The updated machine. - */ - MachineDto updateMachine(MachineDto machine); - - /** - * Deletes an existing physical machine. - * - * @param machine The physical machine to delete. - */ - void deleteMachine(MachineDto machine); - - /** - * Reserve the given machine for the given enterprise. - * - * @param enterprise The enterprise reserving the machine. - * @param machine The machine to reserve. - * @return The reserved machine. - */ - MachineDto reserveMachine(EnterpriseDto enterprise, MachineDto machine); - - /** - * Cancels the reservation of the given machine. - * - * @param enterprise The enterprise to cancel reservation. - * @param machine The machine to release. - */ - Void cancelReservation(EnterpriseDto enterprise, MachineDto machine); - - /** - * List all machines racks for a rack. - * - * @param rack The rack. - * @return The list of physical machines for the rack. - */ - MachinesDto listMachines(RackDto rack); - - /*********************** Blade ***********************/ - - /** - * Power off a physical machine in a UCS rack. - * - * @param machime The phyisical machine. - */ - @EnterpriseEdition - void powerOff(MachineDto machine); - - /** - * Power on a physical machine in a UCS rack. - * - * @param machime The phyisical machine. - */ - @EnterpriseEdition - void powerOn(MachineDto machine); - - /** - * Get the logic server associated with a machine in a Cisc UCS rack. - * - * @param machime The phyisical machine. - * @return The logic server. - */ - @EnterpriseEdition - LogicServerDto getLogicServer(MachineDto machine); - - /** - * Turn off locator led of a physical machine in a UCS rack. - * - * @param machime The phyisical machine. - */ - @EnterpriseEdition - void ledOn(MachineDto machine); - - /** - * Light locator led of a physical machine in a UCS rack. - * - * @param machime The phyisical machine. - */ - @EnterpriseEdition - void ledOff(MachineDto machine); - - /** - * Get led locator info from a physical machine in a UCS rack. - * - * @param machime The phyisical machine. - * @return Led locator information. - */ - @EnterpriseEdition - BladeLocatorLedDto getLocatorLed(MachineDto machine); - - /** - * List all virtual machines in a physical machine. - * - * @param machine The physical machine. - * @return The list of virtual machines in the physical machine. - */ - VirtualMachinesWithNodeExtendedDto listVirtualMachinesByMachine(MachineDto machine, - MachineOptions options); - - /** - * Get the given virtual machine - * - * @param machine - * @param virtualMachineId - * @return - */ - VirtualMachineWithNodeExtendedDto getVirtualMachine(MachineDto machine, Integer virtualMachineId); - - /*********************** Storage Device ***********************/ - - /** - * List all storage devices of the datacenter. - * - * @param datacenter The datacenter. - * @return The list of storage devices in the datacenter. - */ - @EnterpriseEdition - StorageDevicesDto listStorageDevices(DatacenterDto datacenter); - - /** - * List all supported storage devices. - * - * @param datacenter The datacenter. - * @return The list of supported storage devices. - */ - @EnterpriseEdition - StorageDevicesMetadataDto listSupportedStorageDevices(DatacenterDto datacenter); - - /** - * Get the storage device. - * - * @param storageDeviceId The id of the storage device. - * @return The storage device or null if it does not exist. - */ - @EnterpriseEdition - StorageDeviceDto getStorageDevice(DatacenterDto datacenter, Integer storageDeviceId); - - /** - * Create a new storage device. - * - * @param datacenter The datacenter. - * @param storageDevice The storage device to be created. - * @return The created storage device. - */ - @EnterpriseEdition - StorageDeviceDto createStorageDevice(final DatacenterDto datacenter, - final StorageDeviceDto storageDevice); - - /** - * Deletes an existing storage device. - * - * @param storageDevice The storage device to delete. - */ - @EnterpriseEdition - void deleteStorageDevice(StorageDeviceDto storageDevice); - - /** - * Updates an existing storage device. - * - * @param storageDevice The new attributes for the storage device. - * @return The updated storage device. - */ - @EnterpriseEdition - StorageDeviceDto updateStorageDevice(StorageDeviceDto storageDevice); - - /*********************** Tier ***********************/ - /** - * List all tiers of the datacenter. - * - * @param datacenter The datacenter. - * @return The list of tiers in the datacenter. - */ - @EnterpriseEdition - TiersDto listTiers(DatacenterDto datacenter); - - /** - * Updates a tier. - * - * @param tier The new attributes for the tier. - * @return The updated tier. - */ - @EnterpriseEdition - TierDto updateTier(TierDto tier); - - /** - * Get the tier. - * - * @param tierId The id of the tier. - * @return The tier or null if it does not exist. - */ - @EnterpriseEdition - TierDto getTier(DatacenterDto datacenter, Integer tierId); - - /*********************** Storage Pool ***********************/ - - /** - * List storage pools on a storage device. - * - * @param storageDevice The storage device. - * @param options Optional query params. - * @return The list of storage pools in the storage device. - */ - @EnterpriseEdition - StoragePoolsDto listStoragePools(StorageDeviceDto storageDeviceDto, - StoragePoolOptions storagePoolOptions); - - /** - * List storage pools on a tier. - * - * @param tier The tier device. - * @return The list of storage pools in the tier. - */ - @EnterpriseEdition - StoragePoolsDto listStoragePools(TierDto tier); - - /** - * Create a new storage pool in a storage device. - * - * @param storageDevice The storage device. - * @param storagePool The storage pool to be created. - * @return The created storage pool. - */ - @EnterpriseEdition - StoragePoolDto createStoragePool(StorageDeviceDto storageDevice, StoragePoolDto storagePool); - - /** - * Updates a storage pool. - * - * @param storagePool The new attributes for the storage pool. - * @return The updated tier. - */ - @EnterpriseEdition - StoragePoolDto updateStoragePool(StoragePoolDto storagePool); - - /** - * Deletes an existing storage pool. - * - * @param storagePool The storage pool to delete. - */ - @EnterpriseEdition - void deleteStoragePool(StoragePoolDto storagePool); - - /** - * Get the storage pool. - * - * @param storageDevice The storage device. - * @param storagePoolId The id of the storage pool. - * @return The storage pool or null if it does not exist. - */ - @EnterpriseEdition - StoragePoolDto getStoragePool(StorageDeviceDto storageDevice, String storagePoolId); - - /** - * Refresh the given storage pool data. - * - * @param storagePool The storage pool to refresh. - * @param options The options to query the storage pool. - * @return The updated storage pool. - */ - @EnterpriseEdition - StoragePoolDto refreshStoragePool(StoragePoolDto storagePool, StoragePoolOptions options); - - /*********************** Network ***********************/ - - /** - * List all public, external and not managed networks of a datacenter. - * - * @param datacenter The datacenter. - * @return The list of not public, external and not managed for the datacenter. - */ - @EnterpriseEdition - VLANNetworksDto listNetworks(DatacenterDto datacenter); - - /** - * List networks of a datacenter with options. - * - * @param datacenter The datacenter. - * @param options Optional query params. - * @return The list of not public, external and not managed for the datacenter. - */ - @EnterpriseEdition - VLANNetworksDto listNetworks(DatacenterDto datacenter, NetworkOptions options); - - /** - * Get the given network from the given datacenter. - * - * @param datacenter The datacenter. - * @param networkId The id of the network. - * @return The rack or null if it does not exist. - */ - VLANNetworkDto getNetwork(DatacenterDto datacenter, Integer networkId); - - /** - * Create a new public network. - * - * @param storageDevice The storage device. - * @param storagePool The storage pool to be created. - * @return The created storage pool. - */ - @EnterpriseEdition - VLANNetworkDto createNetwork(DatacenterDto datacenter, VLANNetworkDto network); - - /** - * Updates a network. - * - * @param network The new attributes for the network. - * @return The updated tier. - */ - @EnterpriseEdition - VLANNetworkDto updateNetwork(VLANNetworkDto network); - - /** - * Deletes an existing network. - * - * @param network The network to delete. - */ - @EnterpriseEdition - void deleteNetwork(VLANNetworkDto network); - - /** - * Check the availability of a tag. - * - * @param datacenter The datacenter. - * @param tag Tag to check. - * @return A tag availability object. - */ - @EnterpriseEdition - VlanTagAvailabilityDto checkTagAvailability(DatacenterDto datacenter, Integer tag); - - /*********************** Network IPs ***********************/ - - /** - * List all the IPs in the given public network. - * - * @param network The public network. - * @return The IPs in the given public network. - * @since 2.3 - */ - PublicIpsDto listPublicIps(VLANNetworkDto network); - - /** - * List all the IPs in the given public network. - * - * @param network The public network. - * @param options The filtering options. - * @return The IPs in the given public network. - * @since 2.3 - */ - PublicIpsDto listPublicIps(VLANNetworkDto network, IpOptions options); - - /** - * Get the given public ip. - * - * @param network The public network. - * @param ipId The id of the ip to get. - * @return The requested ip. - * @since 2.3 - */ - PublicIpDto getPublicIp(VLANNetworkDto network, Integer ipId); - - /** - * List all the IPs in the given external network. - * - * @param network The external network. - * @return The IPs in the given external network. - * @since 2.3 - */ - ExternalIpsDto listExternalIps(VLANNetworkDto network); - - /** - * List all the IPs in the given external network. - * - * @param network The external network. - * @param options The filtering options. - * @return The IPs in the given external network. - * @since 2.3 - */ - ExternalIpsDto listExternalIps(VLANNetworkDto network, IpOptions options); - - /** - * Get the given external ip. - * - * @param network The external network. - * @param ipId The id of the ip to get. - * @return The requested ip. - * @since 2.3 - */ - ExternalIpDto getExternalIp(VLANNetworkDto network, Integer ipId); - - /** - * List all the IPs in the given unmanaged network. - * - * @param network The unmanaged network. - * @return The IPs in the given unmanaged network. - * @since 2.3 - */ - UnmanagedIpsDto listUnmanagedIps(VLANNetworkDto network); - - /** - * List all the IPs in the given unmanaged network. - * - * @param network The unmanaged network. - * @param options The filtering options. - * @return The IPs in the given unmanaged network. - * @since 2.3 - */ - UnmanagedIpsDto listUnmanagedIps(VLANNetworkDto network, IpOptions options); - - /** - * Get the given unmanaged ip. - * - * @param network The unmanaged network. - * @param ipId The id of the ip to get. - * @return The requested ip. - * @since 2.3 - */ - UnmanagedIpDto getUnmanagedIp(VLANNetworkDto network, Integer ipId); +public interface InfrastructureApi { + /*********************** Datacenter ***********************/ + + /** + * List all datacenters. + * + * @return The list of Datacenters. + */ + DatacentersDto listDatacenters(); + + /** + * Create a new datacenter. + * + * @param datacenter + * The datacenter to be created. + * @return The created datacenter. + */ + DatacenterDto createDatacenter(DatacenterDto datacenter); + + /** + * Get the given datacenter. + * + * @param datacenterId + * The id of the datacenter. + * @return The datacenter or null if it does not exist. + */ + DatacenterDto getDatacenter(Integer datacenterId); + + /** + * Updates an existing datacenter. + * + * @param datacenter + * The new attributes for the datacenter. + * @return The updated datacenter. + */ + DatacenterDto updateDatacenter(DatacenterDto datacenter); + + /** + * Deletes an existing datacenter. + * + * @param datacenter + * The datacenter to delete. + */ + void deleteDatacenter(DatacenterDto datacenter); + + /** + * Retrieve remote machine information. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveremotemachineinformation + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + MachineDto discoverSingleMachine(DatacenterDto datacenter, String ip, HypervisorType hypervisorType, String user, + String password); + + /** + * Retrieve remote machine information. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrieveremotemachineinformation + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param options + * Optional query params. + * @return The physical machine. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + MachineDto discoverSingleMachine(DatacenterDto datacenter, String ip, HypervisorType hypervisorType, String user, + String password, MachineOptions options); + + /** + * Retrieve a list of remote machine information. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievealistofremotemachineinformation + * @param datacenter + * The datacenter. + * @param ipFrom + * IP address of the remote first hypervisor to check. + * @param ipTo + * IP address of the remote last hypervisor to check. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine list. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + MachinesDto discoverMultipleMachines(final DatacenterDto datacenter, final String ipFrom, final String ipTo, + final HypervisorType hypervisorType, final String user, final String password); + + /** + * Retrieve a list of remote machine information. + * + * @see API: http://community.abiquo.com/display/ABI20/DatacenterResource# + * DatacenterResource- Retrievealistofremotemachineinformation + * @param datacenter + * The datacenter. + * @param ipFrom + * IP address of the remote first hypervisor to check. + * @param ipTo + * IP address of the remote last hypervisor to check. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param options + * Optional query params. + * @return The physical machine list. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + MachinesDto discoverMultipleMachines(final DatacenterDto datacenter, final String ipFrom, final String ipTo, + final HypervisorType hypervisorType, final String user, final String password, final MachineOptions options); + + /** + * Retreives limits for the given datacenter and any enterprise. + * + * @param datacenter + * The datacenter. + * @return The usage limits for the datacenter on any enterprise. + */ + DatacentersLimitsDto listLimits(DatacenterDto datacenter); + + /** + * Check the state of a remote machine. This machine does not need to be + * managed by Abiquo. + * + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The physical machine state information. + */ + MachineStateDto checkMachineState(DatacenterDto datacenter, String ip, HypervisorType hypervisorType, String user, + String password); + + /** + * Check the state of a remote machine. This machine does not need to be + * managed by Abiquo. + * + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param hypervisorType + * Kind of hypervisor we want to connect. Valid values are {vbox, + * kvm, xen-3, vmx-04, hyperv-301, xenserver}. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param options + * Optional query params. + * @return The physical machine state information. + */ + MachineStateDto checkMachineState(DatacenterDto datacenter, String ip, HypervisorType hypervisorType, String user, + String password, MachineOptions options); + + /** + * Check the ipmi configuration state of a remote machine. This machine does + * not need to be managed by Abiquo. + * + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @return The ipmi configuration state information + */ + MachineIpmiStateDto checkMachineIpmiState(DatacenterDto datacenter, String ip, String user, String password); + + /** + * Check the ipmi configuration state of a remote machine. This machine does + * not need to be managed by Abiquo. + * + * @param datacenter + * The datacenter. + * @param ip + * IP address of the remote hypervisor to connect. + * @param user + * User to log in. + * @param password + * Password to authenticate. + * @param options + * Optional query params. + * @return The ipmi configuration state information + */ + MachineIpmiStateDto checkMachineIpmiState(DatacenterDto datacenter, String ip, String user, String password, + IpmiOptions options); + + /*********************** Hypervisor ***********************/ + + /** + * Retreives the hypervisor type of a remote a machine. + * + * @param datacenter + * The datacenter. + * @param options + * Optional query params. + * @return The hypervisor type. + */ + String getHypervisorTypeFromMachine(DatacenterDto datacenter, DatacenterOptions options); + + /** + * Retreives the hypervisor types in the datacenter. + * + * @param datacenter + * The datacenter. + * @return The hypervisor types. + */ + HypervisorTypesDto getHypervisorTypes(DatacenterDto datacenter); + + /*********************** Unmanaged Rack ********************** */ + + /** + * List all not managed racks for a datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of not managed racks for the datacenter. + */ + RacksDto listRacks(DatacenterDto datacenter); + + /** + * Create a new not managed rack in a datacenter. + * + * @param datacenter + * The datacenter. + * @param rack + * The rack to be created. + * @return The created rack. + */ + RackDto createRack(final DatacenterDto datacenter, final RackDto rack); + + /** + * Get the given rack from the given datacenter. + * + * @param datacenter + * The datacenter. + * @param rackId + * The id of the rack. + * @return The rack or null if it does not exist. + */ + RackDto getRack(DatacenterDto datacenter, Integer rackId); + + /** + * Updates an existing rack from the given datacenter. + * + * @param rack + * The new attributes for the rack. + * @return The updated rack. + */ + RackDto updateRack(final RackDto rack); + + /** + * Deletes an existing rack. + * + * @param rack + * The rack to delete. + */ + void deleteRack(final RackDto rack); + + /*********************** Managed Rack **********************/ + + /** + * List all managed racks for a datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of managed racks for the datacenter. + */ + @EnterpriseEdition + @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) + UcsRacksDto listManagedRacks(DatacenterDto datacenter); + + /** + * Create a new managed rack in a datacenter. + * + * @param datacenter + * The datacenter. + * @param rack + * The managed rack to be created. + * @return The created rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + UcsRackDto createManagedRack(final DatacenterDto datacenter, final UcsRackDto rack); + + /** + * Get the given managed rack from the given datacenter. + * + * @param datacenter + * The datacenter. + * @param rackId + * The id of the rack. + * @return The rack or null if it does not exist. + */ + @EnterpriseEdition + @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) + UcsRackDto getManagedRack(DatacenterDto datacenter, Integer rackId); + + /** + * Updates an existing managed rack from the given datacenter. + * + * @param rack + * The new attributes for the rack. + * @return The updated rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + UcsRackDto updateManagedRack(final UcsRackDto rack); + + /** + * List all service profiles of the ucs rack. + * + * @param rack + * The ucs rack. + * @return The list of service profiles for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + LogicServersDto listServiceProfiles(UcsRackDto rack); + + /** + * List service profiles of the ucs rack with filtering options. + * + * @param rack + * The ucs rack. + * @param options + * Optional query params. + * @return The list of service profiles for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + LogicServersDto listServiceProfiles(UcsRackDto rack, FilterOptions options); + + /** + * List all service profile templates of the ucs rack. + * + * @param rack + * The ucs rack. + * @return The list of service profile templates for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + LogicServersDto listServiceProfileTemplates(UcsRackDto rack); + + /** + * List all service profile templates of the ucs rack with options. + * + * @param rack + * The ucs rack. + * @param options + * Optional query params. + * @return The list of service profile templates for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + LogicServersDto listServiceProfileTemplates(UcsRackDto rack, FilterOptions options); + + /** + * List all organizations of the ucs rack. + * + * @param rack + * The ucs rack. + * @return The list of organizations for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + OrganizationsDto listOrganizations(UcsRackDto rack); + + /** + * List all organizations of the ucs rack with options. + * + * @param rack + * The ucs rack. + * @param options + * Optional query params. + * @return The list of organizations for the rack. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + OrganizationsDto listOrganizations(UcsRackDto rack, FilterOptions options); + + /** + * Clone a service profile. + * + * @param rack + * The managed rack where thw service profile will be created. + * @param logicServer + * The original logic server. + * @param organization + * The organization to be associated. + * @param newName + * The name of the new service profile. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void cloneLogicServer(UcsRackDto rack, LogicServerDto logicServer, OrganizationDto organization, String newName); + + /** + * Delete a service profile. + * + * @param rack + * The managed rack where the service profile will be created. + * @param logicServer + * The original logic server. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void deleteLogicServer(UcsRackDto rack, LogicServerDto logicServer); + + /** + * Associate a service profile with a blade. + * + * @param rack + * The managed rack where the service profile is. + * @param logicServer + * The logic server. + * @param organization + * The organization to be associated. + * @param bladeName + * The name of the blade. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void associateLogicServer(UcsRackDto rack, LogicServerDto logicServer, OrganizationDto organization, String bladeName); + + /** + * Associate a service profile with a blade instantiating a service profile + * template. + * + * @param rack + * The managed rack where the service profile is. + * @param logicServer + * The logic server. + * @param organization + * The organization to be associated. + * @param newName + * Name of the new service profile. + * @param bladeName + * The name of the blade. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void associateTemplate(UcsRackDto rack, LogicServerDto logicServer, OrganizationDto organization, String newName, + String bladeName); + + /** + * Clone a service profile and associate it with a blade. + * + * @param rack + * The managed rack where the service profile is. + * @param logicServer + * The logic server. + * @param organization + * The organization to be associated. + * @param newName + * Name of the new service profile. + * @param bladeName + * The name of the blade. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void cloneAndAssociateLogicServer(UcsRackDto rack, LogicServerDto logicServer, OrganizationDto organization, + String newName, String bladeName); + + /** + * Dissociate a service profile from a blade. + * + * @param rack + * The managed rack where the service profile is. + * @param logicServer + * The logic server. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + void dissociateLogicServer(UcsRackDto rack, LogicServerDto logicServer); + + /** + * Get FSM list of an entity + * + * @param rack + * The managed rack where the entity belongs. + * @param dn + * Distinguished name of the entity. + * @param fsm + * The fsm. + */ + @EnterpriseEdition + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + FsmsDto listFsms(UcsRackDto rack, String dn); + + /*********************** Remote Service ********************** */ + + /** + * List all remote services of the datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of remote services for the datacenter. + */ + RemoteServicesDto listRemoteServices(DatacenterDto dataceter); + + /** + * Create a new remote service in a datacenter. + * + * @param datacenter + * The datacenter. + * @param remoteService + * The remote service to be created. + * @return The created remote service. + */ + RemoteServiceDto createRemoteService(final DatacenterDto datacenter, final RemoteServiceDto remoteService); + + /** + * Get the given remote service from the given datacenter. + * + * @param datacenter + * The datacenter. + * @param remoteServiceType + * The type of the remote service. + * @return The remote service or null if it does not exist. + */ + RemoteServiceDto getRemoteService(DatacenterDto datacenter, RemoteServiceType remoteServiceType); + + /** + * Updates an existing remote service from the given datacenter. + * + * @param remoteService + * The new attributes for the remote service. + * @return The updated remote service. + */ + RemoteServiceDto updateRemoteService(RemoteServiceDto remoteService); + + /** + * Deletes an existing remote service. + * + * @param remoteService + * The remote service to delete. + */ + void deleteRemoteService(RemoteServiceDto remoteService); + + /** + * Check if the given remote service is available and properly configured. + * + * @param remoteService + * The remote service to check. + * @return A Boolean indicating if the remote service is available. + */ + boolean isAvailable(RemoteServiceDto remoteService); + + /*********************** Machine ********************** */ + + /** + * Create a new physical machine in a rack. + * + * @param rack + * The rack. + * @param machine + * The physical machine to be created. + * @return The created physical machine. + */ + MachineDto createMachine(RackDto rack, MachineDto machine); + + /** + * Get the given machine from the given rack. + * + * @param rack + * The rack. + * @param machineId + * The id of the machine. + * @return The machine or null if it does not exist. + */ + MachineDto getMachine(RackDto rack, Integer machineId); + + /** + * Checks the real infrastructure state for the given physical machine. The + * machine is updated with the result state. + * + * @param machine + * The machine to check + * @paran boolean that indicates a database synchronization + * @return A machineStateDto with a machine state value from enum + * MachineState + */ + MachineStateDto checkMachineState(MachineDto machine, boolean sync); + + /** + * Checks the ipmi configuration state for the given physical machine. + * + * @param machine + * The machine to check + * @return A machineIpmiStateDto with a machine ipmi configuration state + * value from enum MachineState + */ + MachineIpmiStateDto checkMachineIpmiState(MachineDto machine); + + /** + * Updates an existing physical machine. + * + * @param machine + * The new attributes for the physical machine. + * @return The updated machine. + */ + MachineDto updateMachine(MachineDto machine); + + /** + * Deletes an existing physical machine. + * + * @param machine + * The physical machine to delete. + */ + void deleteMachine(MachineDto machine); + + /** + * Reserve the given machine for the given enterprise. + * + * @param enterprise + * The enterprise reserving the machine. + * @param machine + * The machine to reserve. + * @return The reserved machine. + */ + MachineDto reserveMachine(EnterpriseDto enterprise, MachineDto machine); + + /** + * Cancels the reservation of the given machine. + * + * @param enterprise + * The enterprise to cancel reservation. + * @param machine + * The machine to release. + */ + Void cancelReservation(EnterpriseDto enterprise, MachineDto machine); + + /** + * List all machines racks for a rack. + * + * @param rack + * The rack. + * @return The list of physical machines for the rack. + */ + MachinesDto listMachines(RackDto rack); + + /*********************** Blade ***********************/ + + /** + * Power off a physical machine in a UCS rack. + * + * @param machime + * The phyisical machine. + */ + @EnterpriseEdition + void powerOff(MachineDto machine); + + /** + * Power on a physical machine in a UCS rack. + * + * @param machime + * The phyisical machine. + */ + @EnterpriseEdition + void powerOn(MachineDto machine); + + /** + * Get the logic server associated with a machine in a Cisc UCS rack. + * + * @param machime + * The phyisical machine. + * @return The logic server. + */ + @EnterpriseEdition + LogicServerDto getLogicServer(MachineDto machine); + + /** + * Turn off locator led of a physical machine in a UCS rack. + * + * @param machime + * The phyisical machine. + */ + @EnterpriseEdition + void ledOn(MachineDto machine); + + /** + * Light locator led of a physical machine in a UCS rack. + * + * @param machime + * The phyisical machine. + */ + @EnterpriseEdition + void ledOff(MachineDto machine); + + /** + * Get led locator info from a physical machine in a UCS rack. + * + * @param machime + * The phyisical machine. + * @return Led locator information. + */ + @EnterpriseEdition + BladeLocatorLedDto getLocatorLed(MachineDto machine); + + /** + * List all virtual machines in a physical machine. + * + * @param machine + * The physical machine. + * @return The list of virtual machines in the physical machine. + */ + VirtualMachinesWithNodeExtendedDto listVirtualMachinesByMachine(MachineDto machine, MachineOptions options); + + /** + * Get the given virtual machine + * + * @param machine + * @param virtualMachineId + * @return + */ + VirtualMachineWithNodeExtendedDto getVirtualMachine(MachineDto machine, Integer virtualMachineId); + + /*********************** Storage Device ***********************/ + + /** + * List all storage devices of the datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of storage devices in the datacenter. + */ + @EnterpriseEdition + StorageDevicesDto listStorageDevices(DatacenterDto datacenter); + + /** + * List all supported storage devices. + * + * @param datacenter + * The datacenter. + * @return The list of supported storage devices. + */ + @EnterpriseEdition + StorageDevicesMetadataDto listSupportedStorageDevices(DatacenterDto datacenter); + + /** + * Get the storage device. + * + * @param storageDeviceId + * The id of the storage device. + * @return The storage device or null if it does not exist. + */ + @EnterpriseEdition + StorageDeviceDto getStorageDevice(DatacenterDto datacenter, Integer storageDeviceId); + + /** + * Create a new storage device. + * + * @param datacenter + * The datacenter. + * @param storageDevice + * The storage device to be created. + * @return The created storage device. + */ + @EnterpriseEdition + StorageDeviceDto createStorageDevice(final DatacenterDto datacenter, final StorageDeviceDto storageDevice); + + /** + * Deletes an existing storage device. + * + * @param storageDevice + * The storage device to delete. + */ + @EnterpriseEdition + void deleteStorageDevice(StorageDeviceDto storageDevice); + + /** + * Updates an existing storage device. + * + * @param storageDevice + * The new attributes for the storage device. + * @return The updated storage device. + */ + @EnterpriseEdition + StorageDeviceDto updateStorageDevice(StorageDeviceDto storageDevice); + + /*********************** Tier ***********************/ + /** + * List all tiers of the datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of tiers in the datacenter. + */ + @EnterpriseEdition + TiersDto listTiers(DatacenterDto datacenter); + + /** + * Updates a tier. + * + * @param tier + * The new attributes for the tier. + * @return The updated tier. + */ + @EnterpriseEdition + TierDto updateTier(TierDto tier); + + /** + * Get the tier. + * + * @param tierId + * The id of the tier. + * @return The tier or null if it does not exist. + */ + @EnterpriseEdition + TierDto getTier(DatacenterDto datacenter, Integer tierId); + + /*********************** Storage Pool ***********************/ + + /** + * List storage pools on a storage device. + * + * @param storageDevice + * The storage device. + * @param options + * Optional query params. + * @return The list of storage pools in the storage device. + */ + @EnterpriseEdition + StoragePoolsDto listStoragePools(StorageDeviceDto storageDeviceDto, StoragePoolOptions storagePoolOptions); + + /** + * List storage pools on a tier. + * + * @param tier + * The tier device. + * @return The list of storage pools in the tier. + */ + @EnterpriseEdition + StoragePoolsDto listStoragePools(TierDto tier); + + /** + * Create a new storage pool in a storage device. + * + * @param storageDevice + * The storage device. + * @param storagePool + * The storage pool to be created. + * @return The created storage pool. + */ + @EnterpriseEdition + StoragePoolDto createStoragePool(StorageDeviceDto storageDevice, StoragePoolDto storagePool); + + /** + * Updates a storage pool. + * + * @param storagePool + * The new attributes for the storage pool. + * @return The updated tier. + */ + @EnterpriseEdition + StoragePoolDto updateStoragePool(StoragePoolDto storagePool); + + /** + * Deletes an existing storage pool. + * + * @param storagePool + * The storage pool to delete. + */ + @EnterpriseEdition + void deleteStoragePool(StoragePoolDto storagePool); + + /** + * Get the storage pool. + * + * @param storageDevice + * The storage device. + * @param storagePoolId + * The id of the storage pool. + * @return The storage pool or null if it does not exist. + */ + @EnterpriseEdition + StoragePoolDto getStoragePool(StorageDeviceDto storageDevice, String storagePoolId); + + /** + * Refresh the given storage pool data. + * + * @param storagePool + * The storage pool to refresh. + * @param options + * The options to query the storage pool. + * @return The updated storage pool. + */ + @EnterpriseEdition + StoragePoolDto refreshStoragePool(StoragePoolDto storagePool, StoragePoolOptions options); + + /*********************** Network ***********************/ + + /** + * List all public, external and not managed networks of a datacenter. + * + * @param datacenter + * The datacenter. + * @return The list of not public, external and not managed for the + * datacenter. + */ + @EnterpriseEdition + VLANNetworksDto listNetworks(DatacenterDto datacenter); + + /** + * List networks of a datacenter with options. + * + * @param datacenter + * The datacenter. + * @param options + * Optional query params. + * @return The list of not public, external and not managed for the + * datacenter. + */ + @EnterpriseEdition + VLANNetworksDto listNetworks(DatacenterDto datacenter, NetworkOptions options); + + /** + * Get the given network from the given datacenter. + * + * @param datacenter + * The datacenter. + * @param networkId + * The id of the network. + * @return The rack or null if it does not exist. + */ + VLANNetworkDto getNetwork(DatacenterDto datacenter, Integer networkId); + + /** + * Create a new public network. + * + * @param storageDevice + * The storage device. + * @param storagePool + * The storage pool to be created. + * @return The created storage pool. + */ + @EnterpriseEdition + VLANNetworkDto createNetwork(DatacenterDto datacenter, VLANNetworkDto network); + + /** + * Updates a network. + * + * @param network + * The new attributes for the network. + * @return The updated tier. + */ + @EnterpriseEdition + VLANNetworkDto updateNetwork(VLANNetworkDto network); + + /** + * Deletes an existing network. + * + * @param network + * The network to delete. + */ + @EnterpriseEdition + void deleteNetwork(VLANNetworkDto network); + + /** + * Check the availability of a tag. + * + * @param datacenter + * The datacenter. + * @param tag + * Tag to check. + * @return A tag availability object. + */ + @EnterpriseEdition + VlanTagAvailabilityDto checkTagAvailability(DatacenterDto datacenter, Integer tag); + + /*********************** Network IPs ***********************/ + + /** + * List all the IPs in the given public network. + * + * @param network + * The public network. + * @return The IPs in the given public network. + * @since 2.3 + */ + PublicIpsDto listPublicIps(VLANNetworkDto network); + + /** + * List all the IPs in the given public network. + * + * @param network + * The public network. + * @param options + * The filtering options. + * @return The IPs in the given public network. + * @since 2.3 + */ + PublicIpsDto listPublicIps(VLANNetworkDto network, IpOptions options); + + /** + * Get the given public ip. + * + * @param network + * The public network. + * @param ipId + * The id of the ip to get. + * @return The requested ip. + * @since 2.3 + */ + PublicIpDto getPublicIp(VLANNetworkDto network, Integer ipId); + + /** + * List all the IPs in the given external network. + * + * @param network + * The external network. + * @return The IPs in the given external network. + * @since 2.3 + */ + ExternalIpsDto listExternalIps(VLANNetworkDto network); + + /** + * List all the IPs in the given external network. + * + * @param network + * The external network. + * @param options + * The filtering options. + * @return The IPs in the given external network. + * @since 2.3 + */ + ExternalIpsDto listExternalIps(VLANNetworkDto network, IpOptions options); + + /** + * Get the given external ip. + * + * @param network + * The external network. + * @param ipId + * The id of the ip to get. + * @return The requested ip. + * @since 2.3 + */ + ExternalIpDto getExternalIp(VLANNetworkDto network, Integer ipId); + + /** + * List all the IPs in the given unmanaged network. + * + * @param network + * The unmanaged network. + * @return The IPs in the given unmanaged network. + * @since 2.3 + */ + UnmanagedIpsDto listUnmanagedIps(VLANNetworkDto network); + + /** + * List all the IPs in the given unmanaged network. + * + * @param network + * The unmanaged network. + * @param options + * The filtering options. + * @return The IPs in the given unmanaged network. + * @since 2.3 + */ + UnmanagedIpsDto listUnmanagedIps(VLANNetworkDto network, IpOptions options); + + /** + * Get the given unmanaged ip. + * + * @param network + * The unmanaged network. + * @param ipId + * The id of the ip to get. + * @return The requested ip. + * @since 2.3 + */ + UnmanagedIpDto getUnmanagedIp(VLANNetworkDto network, Integer ipId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureAsyncApi.java index 892b79bad1..a0d77e4724 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureAsyncApi.java @@ -114,997 +114,968 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/admin") -public interface InfrastructureAsyncApi -{ - /*********************** Datacenter ***********************/ - - /** - * @see InfrastructureApi#listDatacenters() - */ - @GET - @Path("/datacenters") - @Consumes(DatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listDatacenters(); - - /** - * @see InfrastructureApi#createDatacenter(DatacenterDto) - */ - @POST - @Path("/datacenters") - @Produces(DatacenterDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createDatacenter( - @BinderParam(BindToXMLPayload.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#getDatacenter(Integer) - */ - @GET - @Path("/datacenters/{datacenter}") - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getDatacenter(@PathParam("datacenter") Integer datacenterId); - - /** - * @see InfrastructureApi#updateDatacenter(DatacenterDto) - */ - @PUT - @Produces(DatacenterDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateDatacenter( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#deleteDatacenter(DatacenterDto) - */ - @DELETE - ListenableFuture deleteDatacenter( - @EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#discoverSingleMachine(DatacenterDto, String, HypervisorType, String, - * String) - */ - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture discoverSingleMachine( - @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password); - - /** - * @see InfrastructureApi#discoverSingleMachine(DatacenterDto, String, HypervisorType, String, - * String, MachineOptions) - */ - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture discoverSingleMachine( - @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password, - MachineOptions options); - - /** - * @see InfrastructureApi#discoverMultipleMachines(DatacenterDto, String, String, - * HypervisorType, String, String) - */ - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture discoverMultipleMachines( - @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, - @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, - @QueryParam("password") String password); - - /** - * @see InfrastructureApi#discoverMultipleMachines(DatacenterDto, String, String, - * HypervisorType, String, String, MachineOptions) - */ - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture discoverMultipleMachines( - @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, - @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, - @QueryParam("password") String password, MachineOptions options); - - /** - * @see InfrastructureApi#listLimits(DatacenterDto) - */ - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listLimits( - @EndpointLink("getLimits") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#checkMachineState(DatacenterDto, String, String, HypervisorType, - * String, String) - */ - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture checkMachineState( - @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password); - - /** - * @see InfrastructureApi#checkMachineState(DatacenterDto, String, String, HypervisorType, - * String, String, MachineOptions) - */ - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture checkMachineState( - @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password, - MachineOptions options); - - /** - * @see InfrastructureApi#checkMachineIpmiState(DatacenterDto, String, String, String) - */ - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture checkMachineIpmiState( - @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("user") String user, - @QueryParam("password") String password); - - /** - * @see InfrastructureApi#checkMachineIpmiState(DatacenterDto, String, String, String, - * IpmiOptions) - */ - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) - ListenableFuture checkMachineIpmiState( - @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("user") String user, - @QueryParam("password") String password, IpmiOptions options); - - /*********************** Hypervisor ***********************/ - /** - * @see InfrastructureApi#getHypervisorTypeFromMachine(DatacenterDto, DatacenterOptions) - */ - @GET - @Consumes(MediaType.TEXT_PLAIN) - @ResponseParser(ReturnStringIf2xx.class) - ListenableFuture getHypervisorTypeFromMachine( - @EndpointLink("hypervisor") @BinderParam(BindToPath.class) DatacenterDto datacenter, - DatacenterOptions options); - - /** - * @see InfrastructureApi#getHypervisorTypes(DatacenterDto) - */ - @GET - @Consumes(HypervisorTypesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getHypervisorTypes( - @EndpointLink("hypervisors") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /*********************** Unmanaged Rack ***********************/ - - /** - * @see InfrastructureApi#listRacks(DatacenterDto) - */ - @GET - @Consumes(RacksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRacks( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createRack(DatacenterDto, RackDto) - */ - @POST - @Produces(RackDto.BASE_MEDIA_TYPE) - @Consumes(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createRack( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) RackDto rack); - - /** - * @see InfrastructureApi#getRack(DatacenterDto, Integer) - */ - @GET - @Consumes(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRack( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer rackId); - - /** - * @see InfrastructureApi#updateRack(RackDto) - */ - @PUT - @Consumes(RackDto.BASE_MEDIA_TYPE) - @Produces(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateRack( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RackDto rack); - - /** - * @see InfrastructureApi#deleteRack(RackDto) - */ - @DELETE - ListenableFuture deleteRack( - @EndpointLink("edit") @BinderParam(BindToPath.class) RackDto rack); - - /*********************** Managed Rack ***********************/ - - /** - * @see InfrastructureApi#listManagedRacks(DatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(UcsRacksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listManagedRacks( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createManagedRack(DatacenterDto, UcsRackDto) - */ - @EnterpriseEdition - @POST - @Produces(UcsRackDto.BASE_MEDIA_TYPE) - @Consumes(UcsRackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createManagedRack( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#getManagedRack(DatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @Consumes(UcsRackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getManagedRack( - @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer rackId); - - /** - * @see InfrastructureApi#updateManagedRack(UcsRackDto) - */ - @EnterpriseEdition - @PUT - @Consumes(UcsRackDto.BASE_MEDIA_TYPE) - @Produces(UcsRackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateManagedRack( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listServiceProfiles(UcsRackDto) - */ - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfiles( - @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listServiceProfiles(UcsRackDto, QueryOptions) - */ - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfiles( - @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack, - FilterOptions options); - - /** - * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto) - */ - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfileTemplates( - @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto, LogicServerOptions) - */ - @EnterpriseEdition - @GET - @Consumes(LogicServersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listServiceProfileTemplates( - @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack, - FilterOptions options); - - /** - * @see InfrastructureApi#listOrganizations(UcsRackDto) - */ - @EnterpriseEdition - @GET - @Consumes(OrganizationsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listOrganizations( - @EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack); - - /** - * @see InfrastructureApi#listOrganizations(UcsRackDto, OrganizationOptions) - */ - @EnterpriseEdition - @GET - @Consumes(OrganizationsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listOrganizations( - @EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack, - FilterOptions options); - - /** - * @see InfrastructureApi#cloneLogicServer(UcsRackDto, LogicServerDto, OrganizationDto, String) - */ - @EnterpriseEdition - @POST - ListenableFuture cloneLogicServer( - @EndpointLink("ls-clone") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, - @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, - @QueryParam("newName") String newName); - - /** - * @see InfrastructureApi#associateLogicServer(UcsRackDto, LogicServerDto, OrganizationDto, - * String) - */ - @EnterpriseEdition - @POST - ListenableFuture associateLogicServer( - @EndpointLink("ls-associate") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, - @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, - @QueryParam("bladeDn") String bladeName); - - /** - * @see InfrastructureApi#associateTemplate(UcsRackDto, LogicServerDto, OrganizationDto, String, - * String) - */ - @EnterpriseEdition - @POST - ListenableFuture associateTemplate( - @EndpointLink("ls-associatetemplate") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, - @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, - @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName); - - /** - * @see InfrastructureApi#cloneAndAssociateLogicServer(UcsRackDto, LogicServerDto, - * OrganizationDto, String, String) - */ - @EnterpriseEdition - @POST - ListenableFuture cloneAndAssociateLogicServer( - @EndpointLink("ls-associateclone") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, - @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, - @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName); - - /** - * @see InfrastructureApi#dissociateLogicServer(UcsRackDto, LogicServerDto) - */ - @EnterpriseEdition - @POST - ListenableFuture dissociateLogicServer( - @EndpointLink("ls-dissociate") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); - - /** - * @see InfrastructureApi#deleteLogicServer(UcsRackDto, LogicServerDto) - */ - @EnterpriseEdition - @POST - ListenableFuture deleteLogicServer( - @EndpointLink("ls-delete") @BinderParam(BindToPath.class) UcsRackDto rack, - @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); - - /** - * @see InfrastructureApi#listFsms(UcsRackDto, String) - */ - @EnterpriseEdition - @GET - @Consumes(FsmsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listFsms( - @EndpointLink("fsm") @BinderParam(BindToPath.class) UcsRackDto rack, - @QueryParam("dn") String dn); - - /*********************** Remote Service ***********************/ - - /** - * @see InfrastructureApi#listRemoteServices(DatacenterDto) - */ - @GET - @Consumes(RemoteServicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listRemoteServices( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#createRemoteService(DatacenterDto, RemoteServiceDto) - */ - @POST - @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createRemoteService( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) RemoteServiceDto remoteService); - - /** - * @see InfrastructureApi#getRemoteService(DatacenterDto, RemoteServiceType) - */ - @GET - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRemoteService( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) final DatacenterDto datacenter, - @BinderParam(AppendRemoteServiceTypeToPath.class) final RemoteServiceType remoteServiceType); - - /** - * @see InfrastructureApi#updateRemoteService(RemoteServiceDto) - */ - @PUT - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateRemoteService( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RemoteServiceDto remoteService); - - /** - * @see InfrastructureApi#deleteRemoteService(RemoteServiceDto) - */ - @DELETE - ListenableFuture deleteRemoteService( - @EndpointLink("edit") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /** - * @see InfrastructureApi#isAvailable(RemoteServiceDto) - */ - @GET - @ExceptionParser(ReturnFalseIfNotAvailable.class) - ListenableFuture isAvailable( - @EndpointLink("check") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /*********************** Machine ***********************/ - - /** - * @see InfrastructureApi#listMachines(RackDto) - */ - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listMachines( - @EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack); - - /** - * @see InfrastructureApi#createMachine(RackDto, MachineDto) - */ - @POST - @Produces(MachineDto.BASE_MEDIA_TYPE) - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createMachine( - @EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack, - @BinderParam(BindToXMLPayload.class) MachineDto machine); - - /** - * @see InfrastructureApi#getMachine(RackDto, Integer) - */ - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getMachine( - @EndpointLink("machines") @BinderParam(BindToPath.class) final RackDto rack, - @BinderParam(AppendToPath.class) Integer machineId); - - /** - * @see InfrastructureApi#checkMachineState(MachineDto) - */ - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture checkMachineState( - @EndpointLink("checkstate") @BinderParam(BindToPath.class) final MachineDto machine, - @QueryParam("sync") boolean sync); - - /** - * @see InfrastructureApi#checkMachineIpmiState(MachineDto) - */ - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture checkMachineIpmiState( - @EndpointLink("checkipmistate") @BinderParam(BindToPath.class) final MachineDto machine); - - /** - * @see InfrastructureApi#updateMachine(MachineDto) - */ - @PUT - @Produces(MachineDto.BASE_MEDIA_TYPE) - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateMachine( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#deleteMachine(MachineDto) - */ - @DELETE - ListenableFuture deleteMachine( - @EndpointLink("edit") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#reserveMachine(EnterpriseDto, MachineDto) - */ - @POST - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @Produces(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture reserveMachine( - @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(BindToXMLPayload.class) MachineDto machine); - - /** - * @see InfrastructureApi#cancelReservation(EnterpriseDto, MachineDto) - */ - @DELETE - ListenableFuture cancelReservation( - @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendMachineIdToPath.class) MachineDto machine); - - /*********************** Blade ***********************/ - - /** - * @see InfrastructureApi#powerOff(MachineDto) - */ - @EnterpriseEdition - @PUT - ListenableFuture powerOff( - @EndpointLink("poweroff") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#powerOn(MachineDto) - */ - @EnterpriseEdition - @PUT - ListenableFuture powerOn( - @EndpointLink("poweron") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#getLogicServer(MachineDto) - */ - @EnterpriseEdition - @GET - @Consumes(LogicServerDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getLogicServer( - @EndpointLink("logicserver") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#ledOn(MachineDto) - */ - @EnterpriseEdition - @POST - ListenableFuture ledOn( - @EndpointLink("ledon") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#ledOff(MachineDto) - */ - @EnterpriseEdition - @POST - ListenableFuture ledOff( - @EndpointLink("ledoff") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * @see InfrastructureApi#getLedLocator(MachineDto) - */ - @EnterpriseEdition - @GET - @Consumes(BladeLocatorLedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getLocatorLed( - @EndpointLink("led") @BinderParam(BindToPath.class) MachineDto machine); - - /*********************** Storage Device ***********************/ - - /** - * @see InfrastructureApi#listVirtualMachinesByMachine(MachineDto) - */ - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachinesByMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, - MachineOptions options); - - /** - * @see InfrastructureApi#getVirtualMachine(MachineDto, Integer) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getVirtualMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, - @BinderParam(AppendToPath.class) Integer virtualMachineId); - - /*********************** Storage Device ***********************/ - - /** - * @see InfrastructureApi#listStorageDevices(DatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(StorageDevicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStorageDevices( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#listSupportedStorageDevices(DatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(StorageDevicesMetadataDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listSupportedStorageDevices( - @EndpointLink("devices") @BinderParam(BindSupportedDevicesLinkToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#getStorageDevice(DatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getStorageDevice( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer storageDeviceId); - - /** - * @see InfrastructureApi#createStorageDevice(DatacenterDto, StorageDeviceDto) - */ - @EnterpriseEdition - @POST - @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createStorageDevice( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) StorageDeviceDto storageDevice); - - /** - * @see InfrastructureApi#deleteStorageDevice(StorageDeviceDto) - */ - @EnterpriseEdition - @DELETE - ListenableFuture deleteStorageDevice( - @EndpointLink("edit") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice); - - /** - * @see InfrastructureApi#updateStorageDevice(StorageDeviceDto) - */ - @EnterpriseEdition - @PUT - @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateStorageDevice( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StorageDeviceDto storageDevice); - - /*********************** Tier ***********************/ - - /** - * @see InfrastructureApi#listTiers(DatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(TiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTiers( - @EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#updateTier(TierDto) - */ - @EnterpriseEdition - @PUT - @Produces(TierDto.BASE_MEDIA_TYPE) - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateTier( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) TierDto tier); - - /** - * @see InfrastructureApi#getTier(DatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getTier( - @EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer tierId); - - /*********************** Storage Pool ***********************/ - - /** - * @see InfrastructureApi#listStoragePools(StorageDeviceDto, StoragePoolOptions) - */ - @EnterpriseEdition - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStoragePools( - @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, - StoragePoolOptions options); - - /** - * @see InfrastructureApi#listStoragePools(TierDto) - */ - @EnterpriseEdition - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listStoragePools( - @EndpointLink("pools") @BinderParam(BindToPath.class) TierDto tier); - - /** - * @see InfrastructureApi#createStoragePool(StorageDeviceDto, StoragePoolDto) - */ - @EnterpriseEdition - @POST - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @Produces(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createStoragePool( - @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, - @BinderParam(BindToXMLPayload.class) StoragePoolDto storagePool); - - /** - * @see InfrastructureApi#updateStoragePool(StoragePoolDto) - */ - @EnterpriseEdition - @PUT - // For the most strangest reason in world, compiler does not accept - // constants StoragePoolDto.BASE_MEDIA_TYPE for this method. - @Consumes("application/vnd.abiquo.storagepool+xml") - @Produces("application/vnd.abiquo.storagepool+xml") - @JAXBResponseParser - ListenableFuture updateStoragePool( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StoragePoolDto StoragePoolDto); - - /** - * @see InfrastructureApi#deleteStoragePool(StoragePoolDto) - */ - @EnterpriseEdition - @DELETE - ListenableFuture deleteStoragePool( - @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool); - - /** - * @see InfrastructureApi#getStoragePool(StorageDeviceDto, String) - */ - @EnterpriseEdition - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getStoragePool( - @EndpointLink("pools") @BinderParam(BindToPath.class) final StorageDeviceDto storageDevice, - @BinderParam(AppendToPath.class) final String storagePoolId); - - /** - * @see InfrastructureApi#refreshStoragePool(StoragePoolDto, StoragePoolOptions) - */ - @EnterpriseEdition - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture refreshStoragePool( - @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool, - StoragePoolOptions options); - - /*********************** Network ***********************/ - - /** - * @see InfrastructureApi#listNetworks(DatacenterDto) - */ - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworks( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * @see InfrastructureApi#listNetwork(DatacenterDto, NetworkOptions) - */ - @EnterpriseEdition - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listNetworks( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - NetworkOptions options); - - /** - * @see InfrastructureApi#getNetwork(DatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetwork( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer networkId); - - /** - * @see InfrastructureApi#createNetwork(DatacenterDto, VLANNetworkDto) - */ - @EnterpriseEdition - @POST - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createNetwork( - @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#updateNetwork(VLANNetworkDto) - */ - @EnterpriseEdition - @PUT - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateNetwork( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#deleteNetwork(VLANNetworkDto) - */ - @EnterpriseEdition - @DELETE - ListenableFuture deleteNetwork( - @EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#checkTagAvailability(DatacenterDto, Integer) - */ - @EnterpriseEdition - @GET - @Path("/datacenters/{datacenter}/network/action/checkavailability") - @Consumes(VlanTagAvailabilityDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture checkTagAvailability( - @PathParam("datacenter") @ParamParser(ParseDatacenterId.class) DatacenterDto datacenter, - @QueryParam("tag") Integer tag); - - /*********************** Public Network IPs ***********************/ - - /** - * @see InfrastructureApi#listPublicIps(VLANNetworkDto) - */ - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPublicIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listPublicIps(VLANNetworkDto, IpOptions) - */ - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPublicIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - IpOptions options); - - /** - * @see InfrastructureApi#getPublicIp(VLANNetworkDto, Integer) - */ - @GET - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getPublicIp( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /** - * @see InfrastructureApi#listExternalIps(VLANNetworkDto) - */ - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listExternalIps(VLANNetworkDto, IpOptions) - */ - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - IpOptions options); - - /** - * @see InfrastructureApi#getExternalIp(VLANNetworkDto, Integer) - */ - @GET - @Consumes(ExternalIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getExternalIp( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /** - * @see InfrastructureApi#listUnmanagedIps(VLANNetworkDto) - */ - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * @see InfrastructureApi#listUnmanagedIps(VLANNetworkDto, IpOptions) - */ - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - IpOptions options); - - /** - * @see InfrastructureApi#getUnmanagedIp(VLANNetworkDto, Integer) - */ - @GET - @Consumes(UnmanagedIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture getUnmanagedIp( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); +public interface InfrastructureAsyncApi { + /*********************** Datacenter ***********************/ + + /** + * @see InfrastructureApi#listDatacenters() + */ + @GET + @Path("/datacenters") + @Consumes(DatacentersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listDatacenters(); + + /** + * @see InfrastructureApi#createDatacenter(DatacenterDto) + */ + @POST + @Path("/datacenters") + @Produces(DatacenterDto.BASE_MEDIA_TYPE) + @Consumes(DatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createDatacenter(@BinderParam(BindToXMLPayload.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#getDatacenter(Integer) + */ + @GET + @Path("/datacenters/{datacenter}") + @Consumes(DatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getDatacenter(@PathParam("datacenter") Integer datacenterId); + + /** + * @see InfrastructureApi#updateDatacenter(DatacenterDto) + */ + @PUT + @Produces(DatacenterDto.BASE_MEDIA_TYPE) + @Consumes(DatacenterDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateDatacenter( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#deleteDatacenter(DatacenterDto) + */ + @DELETE + ListenableFuture deleteDatacenter(@EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#discoverSingleMachine(DatacenterDto, String, + * HypervisorType, String, String) + */ + @GET + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture discoverSingleMachine( + @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, + @QueryParam("user") String user, @QueryParam("password") String password); + + /** + * @see InfrastructureApi#discoverSingleMachine(DatacenterDto, String, + * HypervisorType, String, String, MachineOptions) + */ + @GET + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture discoverSingleMachine( + @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, + @QueryParam("user") String user, @QueryParam("password") String password, MachineOptions options); + + /** + * @see InfrastructureApi#discoverMultipleMachines(DatacenterDto, String, + * String, HypervisorType, String, String) + */ + @GET + @Consumes(MachinesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture discoverMultipleMachines( + @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, + @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, + @QueryParam("password") String password); + + /** + * @see InfrastructureApi#discoverMultipleMachines(DatacenterDto, String, + * String, HypervisorType, String, String, MachineOptions) + */ + @GET + @Consumes(MachinesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture discoverMultipleMachines( + @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, + @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, + @QueryParam("password") String password, MachineOptions options); + + /** + * @see InfrastructureApi#listLimits(DatacenterDto) + */ + @GET + @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listLimits( + @EndpointLink("getLimits") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#checkMachineState(DatacenterDto, String, String, + * HypervisorType, String, String) + */ + @GET + @Consumes(MachineStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture checkMachineState( + @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, + @QueryParam("user") String user, @QueryParam("password") String password); + + /** + * @see InfrastructureApi#checkMachineState(DatacenterDto, String, String, + * HypervisorType, String, String, MachineOptions) + */ + @GET + @Consumes(MachineStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture checkMachineState( + @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, + @QueryParam("user") String user, @QueryParam("password") String password, MachineOptions options); + + /** + * @see InfrastructureApi#checkMachineIpmiState(DatacenterDto, String, + * String, String) + */ + @GET + @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture checkMachineIpmiState( + @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("user") String user, @QueryParam("password") String password); + + /** + * @see InfrastructureApi#checkMachineIpmiState(DatacenterDto, String, + * String, String, IpmiOptions) + */ + @GET + @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnAbiquoExceptionOnNotFoundOr4xx.class) + ListenableFuture checkMachineIpmiState( + @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @QueryParam("ip") String ip, @QueryParam("user") String user, @QueryParam("password") String password, + IpmiOptions options); + + /*********************** Hypervisor ***********************/ + /** + * @see InfrastructureApi#getHypervisorTypeFromMachine(DatacenterDto, + * DatacenterOptions) + */ + @GET + @Consumes(MediaType.TEXT_PLAIN) + @ResponseParser(ReturnStringIf2xx.class) + ListenableFuture getHypervisorTypeFromMachine( + @EndpointLink("hypervisor") @BinderParam(BindToPath.class) DatacenterDto datacenter, DatacenterOptions options); + + /** + * @see InfrastructureApi#getHypervisorTypes(DatacenterDto) + */ + @GET + @Consumes(HypervisorTypesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getHypervisorTypes( + @EndpointLink("hypervisors") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /*********************** Unmanaged Rack ***********************/ + + /** + * @see InfrastructureApi#listRacks(DatacenterDto) + */ + @GET + @Consumes(RacksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listRacks(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#createRack(DatacenterDto, RackDto) + */ + @POST + @Produces(RackDto.BASE_MEDIA_TYPE) + @Consumes(RackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) RackDto rack); + + /** + * @see InfrastructureApi#getRack(DatacenterDto, Integer) + */ + @GET + @Consumes(RackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(AppendToPath.class) Integer rackId); + + /** + * @see InfrastructureApi#updateRack(RackDto) + */ + @PUT + @Consumes(RackDto.BASE_MEDIA_TYPE) + @Produces(RackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateRack(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RackDto rack); + + /** + * @see InfrastructureApi#deleteRack(RackDto) + */ + @DELETE + ListenableFuture deleteRack(@EndpointLink("edit") @BinderParam(BindToPath.class) RackDto rack); + + /*********************** Managed Rack ***********************/ + + /** + * @see InfrastructureApi#listManagedRacks(DatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(UcsRacksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listManagedRacks( + @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#createManagedRack(DatacenterDto, UcsRackDto) + */ + @EnterpriseEdition + @POST + @Produces(UcsRackDto.BASE_MEDIA_TYPE) + @Consumes(UcsRackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createManagedRack( + @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) UcsRackDto rack); + + /** + * @see InfrastructureApi#getManagedRack(DatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @Consumes(UcsRackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getManagedRack( + @EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(AppendToPath.class) Integer rackId); + + /** + * @see InfrastructureApi#updateManagedRack(UcsRackDto) + */ + @EnterpriseEdition + @PUT + @Consumes(UcsRackDto.BASE_MEDIA_TYPE) + @Produces(UcsRackDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateManagedRack( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) UcsRackDto rack); + + /** + * @see InfrastructureApi#listServiceProfiles(UcsRackDto) + */ + @EnterpriseEdition + @GET + @Consumes(LogicServersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listServiceProfiles( + @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack); + + /** + * @see InfrastructureApi#listServiceProfiles(UcsRackDto, QueryOptions) + */ + @EnterpriseEdition + @GET + @Consumes(LogicServersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listServiceProfiles( + @EndpointLink("logicservers") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options); + + /** + * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto) + */ + @EnterpriseEdition + @GET + @Consumes(LogicServersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listServiceProfileTemplates( + @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack); + + /** + * @see InfrastructureApi#listServiceProfileTemplates(UcsRackDto, + * LogicServerOptions) + */ + @EnterpriseEdition + @GET + @Consumes(LogicServersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listServiceProfileTemplates( + @EndpointLink("ls-templates") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options); + + /** + * @see InfrastructureApi#listOrganizations(UcsRackDto) + */ + @EnterpriseEdition + @GET + @Consumes(OrganizationsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listOrganizations( + @EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack); + + /** + * @see InfrastructureApi#listOrganizations(UcsRackDto, OrganizationOptions) + */ + @EnterpriseEdition + @GET + @Consumes(OrganizationsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listOrganizations( + @EndpointLink("organizations") @BinderParam(BindToPath.class) UcsRackDto rack, FilterOptions options); + + /** + * @see InfrastructureApi#cloneLogicServer(UcsRackDto, LogicServerDto, + * OrganizationDto, String) + */ + @EnterpriseEdition + @POST + ListenableFuture cloneLogicServer(@EndpointLink("ls-clone") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, + @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, + @QueryParam("newName") String newName); + + /** + * @see InfrastructureApi#associateLogicServer(UcsRackDto, LogicServerDto, + * OrganizationDto, String) + */ + @EnterpriseEdition + @POST + ListenableFuture associateLogicServer( + @EndpointLink("ls-associate") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, + @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, + @QueryParam("bladeDn") String bladeName); + + /** + * @see InfrastructureApi#associateTemplate(UcsRackDto, LogicServerDto, + * OrganizationDto, String, String) + */ + @EnterpriseEdition + @POST + ListenableFuture associateTemplate( + @EndpointLink("ls-associatetemplate") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, + @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, + @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName); + + /** + * @see InfrastructureApi#cloneAndAssociateLogicServer(UcsRackDto, + * LogicServerDto, OrganizationDto, String, String) + */ + @EnterpriseEdition + @POST + ListenableFuture cloneAndAssociateLogicServer( + @EndpointLink("ls-associateclone") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer, + @BinderParam(BindOrganizationParameters.class) OrganizationDto organization, + @QueryParam("newName") String newName, @QueryParam("bladeDn") String bladeName); + + /** + * @see InfrastructureApi#dissociateLogicServer(UcsRackDto, LogicServerDto) + */ + @EnterpriseEdition + @POST + ListenableFuture dissociateLogicServer( + @EndpointLink("ls-dissociate") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); + + /** + * @see InfrastructureApi#deleteLogicServer(UcsRackDto, LogicServerDto) + */ + @EnterpriseEdition + @POST + ListenableFuture deleteLogicServer(@EndpointLink("ls-delete") @BinderParam(BindToPath.class) UcsRackDto rack, + @BinderParam(BindLogicServerParameters.class) LogicServerDto logicServer); + + /** + * @see InfrastructureApi#listFsms(UcsRackDto, String) + */ + @EnterpriseEdition + @GET + @Consumes(FsmsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listFsms(@EndpointLink("fsm") @BinderParam(BindToPath.class) UcsRackDto rack, + @QueryParam("dn") String dn); + + /*********************** Remote Service ***********************/ + + /** + * @see InfrastructureApi#listRemoteServices(DatacenterDto) + */ + @GET + @Consumes(RemoteServicesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listRemoteServices( + @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#createRemoteService(DatacenterDto, + * RemoteServiceDto) + */ + @POST + @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) + @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createRemoteService( + @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) RemoteServiceDto remoteService); + + /** + * @see InfrastructureApi#getRemoteService(DatacenterDto, RemoteServiceType) + */ + @GET + @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRemoteService( + @EndpointLink("remoteservices") @BinderParam(BindToPath.class) final DatacenterDto datacenter, + @BinderParam(AppendRemoteServiceTypeToPath.class) final RemoteServiceType remoteServiceType); + + /** + * @see InfrastructureApi#updateRemoteService(RemoteServiceDto) + */ + @PUT + @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) + @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateRemoteService( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RemoteServiceDto remoteService); + + /** + * @see InfrastructureApi#deleteRemoteService(RemoteServiceDto) + */ + @DELETE + ListenableFuture deleteRemoteService( + @EndpointLink("edit") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); + + /** + * @see InfrastructureApi#isAvailable(RemoteServiceDto) + */ + @GET + @ExceptionParser(ReturnFalseIfNotAvailable.class) + ListenableFuture isAvailable( + @EndpointLink("check") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); + + /*********************** Machine ***********************/ + + /** + * @see InfrastructureApi#listMachines(RackDto) + */ + @GET + @Consumes(MachinesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listMachines(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack); + + /** + * @see InfrastructureApi#createMachine(RackDto, MachineDto) + */ + @POST + @Produces(MachineDto.BASE_MEDIA_TYPE) + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createMachine(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack, + @BinderParam(BindToXMLPayload.class) MachineDto machine); + + /** + * @see InfrastructureApi#getMachine(RackDto, Integer) + */ + @GET + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getMachine(@EndpointLink("machines") @BinderParam(BindToPath.class) final RackDto rack, + @BinderParam(AppendToPath.class) Integer machineId); + + /** + * @see InfrastructureApi#checkMachineState(MachineDto) + */ + @GET + @Consumes(MachineStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture checkMachineState( + @EndpointLink("checkstate") @BinderParam(BindToPath.class) final MachineDto machine, + @QueryParam("sync") boolean sync); + + /** + * @see InfrastructureApi#checkMachineIpmiState(MachineDto) + */ + @GET + @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture checkMachineIpmiState( + @EndpointLink("checkipmistate") @BinderParam(BindToPath.class) final MachineDto machine); + + /** + * @see InfrastructureApi#updateMachine(MachineDto) + */ + @PUT + @Produces(MachineDto.BASE_MEDIA_TYPE) + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateMachine( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#deleteMachine(MachineDto) + */ + @DELETE + ListenableFuture deleteMachine(@EndpointLink("edit") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#reserveMachine(EnterpriseDto, MachineDto) + */ + @POST + @Consumes(MachineDto.BASE_MEDIA_TYPE) + @Produces(MachineDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture reserveMachine( + @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(BindToXMLPayload.class) MachineDto machine); + + /** + * @see InfrastructureApi#cancelReservation(EnterpriseDto, MachineDto) + */ + @DELETE + ListenableFuture cancelReservation( + @EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, + @BinderParam(AppendMachineIdToPath.class) MachineDto machine); + + /*********************** Blade ***********************/ + + /** + * @see InfrastructureApi#powerOff(MachineDto) + */ + @EnterpriseEdition + @PUT + ListenableFuture powerOff(@EndpointLink("poweroff") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#powerOn(MachineDto) + */ + @EnterpriseEdition + @PUT + ListenableFuture powerOn(@EndpointLink("poweron") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#getLogicServer(MachineDto) + */ + @EnterpriseEdition + @GET + @Consumes(LogicServerDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getLogicServer( + @EndpointLink("logicserver") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#ledOn(MachineDto) + */ + @EnterpriseEdition + @POST + ListenableFuture ledOn(@EndpointLink("ledon") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#ledOff(MachineDto) + */ + @EnterpriseEdition + @POST + ListenableFuture ledOff(@EndpointLink("ledoff") @BinderParam(BindToPath.class) MachineDto machine); + + /** + * @see InfrastructureApi#getLedLocator(MachineDto) + */ + @EnterpriseEdition + @GET + @Consumes(BladeLocatorLedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getLocatorLed( + @EndpointLink("led") @BinderParam(BindToPath.class) MachineDto machine); + + /*********************** Storage Device ***********************/ + + /** + * @see InfrastructureApi#listVirtualMachinesByMachine(MachineDto) + */ + @GET + @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachinesByMachine( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, MachineOptions options); + + /** + * @see InfrastructureApi#getVirtualMachine(MachineDto, Integer) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getVirtualMachine( + @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, + @BinderParam(AppendToPath.class) Integer virtualMachineId); + + /*********************** Storage Device ***********************/ + + /** + * @see InfrastructureApi#listStorageDevices(DatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(StorageDevicesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listStorageDevices( + @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#listSupportedStorageDevices(DatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(StorageDevicesMetadataDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listSupportedStorageDevices( + @EndpointLink("devices") @BinderParam(BindSupportedDevicesLinkToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#getStorageDevice(DatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getStorageDevice( + @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(AppendToPath.class) Integer storageDeviceId); + + /** + * @see InfrastructureApi#createStorageDevice(DatacenterDto, + * StorageDeviceDto) + */ + @EnterpriseEdition + @POST + @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) + @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createStorageDevice( + @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) StorageDeviceDto storageDevice); + + /** + * @see InfrastructureApi#deleteStorageDevice(StorageDeviceDto) + */ + @EnterpriseEdition + @DELETE + ListenableFuture deleteStorageDevice( + @EndpointLink("edit") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice); + + /** + * @see InfrastructureApi#updateStorageDevice(StorageDeviceDto) + */ + @EnterpriseEdition + @PUT + @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) + @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateStorageDevice( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StorageDeviceDto storageDevice); + + /*********************** Tier ***********************/ + + /** + * @see InfrastructureApi#listTiers(DatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(TiersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listTiers(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#updateTier(TierDto) + */ + @EnterpriseEdition + @PUT + @Produces(TierDto.BASE_MEDIA_TYPE) + @Consumes(TierDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateTier(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) TierDto tier); + + /** + * @see InfrastructureApi#getTier(DatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @Consumes(TierDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getTier(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(AppendToPath.class) Integer tierId); + + /*********************** Storage Pool ***********************/ + + /** + * @see InfrastructureApi#listStoragePools(StorageDeviceDto, + * StoragePoolOptions) + */ + @EnterpriseEdition + @GET + @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listStoragePools( + @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, + StoragePoolOptions options); + + /** + * @see InfrastructureApi#listStoragePools(TierDto) + */ + @EnterpriseEdition + @GET + @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listStoragePools(@EndpointLink("pools") @BinderParam(BindToPath.class) TierDto tier); + + /** + * @see InfrastructureApi#createStoragePool(StorageDeviceDto, StoragePoolDto) + */ + @EnterpriseEdition + @POST + @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) + @Produces(StoragePoolDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createStoragePool( + @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, + @BinderParam(BindToXMLPayload.class) StoragePoolDto storagePool); + + /** + * @see InfrastructureApi#updateStoragePool(StoragePoolDto) + */ + @EnterpriseEdition + @PUT + // For the most strangest reason in world, compiler does not accept + // constants StoragePoolDto.BASE_MEDIA_TYPE for this method. + @Consumes("application/vnd.abiquo.storagepool+xml") + @Produces("application/vnd.abiquo.storagepool+xml") + @JAXBResponseParser + ListenableFuture updateStoragePool( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StoragePoolDto StoragePoolDto); + + /** + * @see InfrastructureApi#deleteStoragePool(StoragePoolDto) + */ + @EnterpriseEdition + @DELETE + ListenableFuture deleteStoragePool( + @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool); + + /** + * @see InfrastructureApi#getStoragePool(StorageDeviceDto, String) + */ + @EnterpriseEdition + @GET + @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getStoragePool( + @EndpointLink("pools") @BinderParam(BindToPath.class) final StorageDeviceDto storageDevice, + @BinderParam(AppendToPath.class) final String storagePoolId); + + /** + * @see InfrastructureApi#refreshStoragePool(StoragePoolDto, + * StoragePoolOptions) + */ + @EnterpriseEdition + @GET + @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture refreshStoragePool( + @EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool, StoragePoolOptions options); + + /*********************** Network ***********************/ + + /** + * @see InfrastructureApi#listNetworks(DatacenterDto) + */ + @EnterpriseEdition + @GET + @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listNetworks( + @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter); + + /** + * @see InfrastructureApi#listNetwork(DatacenterDto, NetworkOptions) + */ + @EnterpriseEdition + @GET + @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listNetworks( + @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, NetworkOptions options); + + /** + * @see InfrastructureApi#getNetwork(DatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork( + @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(AppendToPath.class) Integer networkId); + + /** + * @see InfrastructureApi#createNetwork(DatacenterDto, VLANNetworkDto) + */ + @EnterpriseEdition + @POST + @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createNetwork( + @EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, + @BinderParam(BindToXMLPayload.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#updateNetwork(VLANNetworkDto) + */ + @EnterpriseEdition + @PUT + @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) + @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateNetwork( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#deleteNetwork(VLANNetworkDto) + */ + @EnterpriseEdition + @DELETE + ListenableFuture deleteNetwork(@EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#checkTagAvailability(DatacenterDto, Integer) + */ + @EnterpriseEdition + @GET + @Path("/datacenters/{datacenter}/network/action/checkavailability") + @Consumes(VlanTagAvailabilityDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture checkTagAvailability( + @PathParam("datacenter") @ParamParser(ParseDatacenterId.class) DatacenterDto datacenter, + @QueryParam("tag") Integer tag); + + /*********************** Public Network IPs ***********************/ + + /** + * @see InfrastructureApi#listPublicIps(VLANNetworkDto) + */ + @GET + @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPublicIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#listPublicIps(VLANNetworkDto, IpOptions) + */ + @GET + @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPublicIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); + + /** + * @see InfrastructureApi#getPublicIp(VLANNetworkDto, Integer) + */ + @GET + @Consumes(PublicIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getPublicIp( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, + @BinderParam(AppendToPath.class) Integer ipId); + + /** + * @see InfrastructureApi#listExternalIps(VLANNetworkDto) + */ + @GET + @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listExternalIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#listExternalIps(VLANNetworkDto, IpOptions) + */ + @GET + @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listExternalIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); + + /** + * @see InfrastructureApi#getExternalIp(VLANNetworkDto, Integer) + */ + @GET + @Consumes(ExternalIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getExternalIp( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, + @BinderParam(AppendToPath.class) Integer ipId); + + /** + * @see InfrastructureApi#listUnmanagedIps(VLANNetworkDto) + */ + @GET + @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listUnmanagedIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); + + /** + * @see InfrastructureApi#listUnmanagedIps(VLANNetworkDto, IpOptions) + */ + @GET + @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listUnmanagedIps( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); + + /** + * @see InfrastructureApi#getUnmanagedIp(VLANNetworkDto, Integer) + */ + @GET + @Consumes(UnmanagedIpDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture getUnmanagedIp( + @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, + @BinderParam(AppendToPath.class) Integer ipId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java index 1d33510aa6..d52734d08a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingApi.java @@ -44,199 +44,214 @@ import com.abiquo.server.core.pricing.PricingTiersDto; * @author Susana Acedo */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface PricingApi -{ +public interface PricingApi { - /*********************** Currency ********************** */ + /*********************** Currency ********************** */ - /** - * List all currencies - * - * @return The list of currencies - */ - CurrenciesDto listCurrencies(); + /** + * List all currencies + * + * @return The list of currencies + */ + CurrenciesDto listCurrencies(); - /** - * Get the given currency - * - * @param currencyId The id of the currency - * @return The currency - */ - CurrencyDto getCurrency(Integer currencyId); + /** + * Get the given currency + * + * @param currencyId + * The id of the currency + * @return The currency + */ + CurrencyDto getCurrency(Integer currencyId); - /** - * Create a new currency - * - * @param currency The currency to be created. - * @return The created currency. - */ - CurrencyDto createCurrency(CurrencyDto currency); + /** + * Create a new currency + * + * @param currency + * The currency to be created. + * @return The created currency. + */ + CurrencyDto createCurrency(CurrencyDto currency); - /** - * Updates an existing currency - * - * @param currency The new attributes for the currency - * @return The updated currency - */ - CurrencyDto updateCurrency(final CurrencyDto currency); + /** + * Updates an existing currency + * + * @param currency + * The new attributes for the currency + * @return The updated currency + */ + CurrencyDto updateCurrency(final CurrencyDto currency); - /** - * Deletes an existing currency - * - * @param currency The currency to delete - */ - void deleteCurrency(final CurrencyDto currency); + /** + * Deletes an existing currency + * + * @param currency + * The currency to delete + */ + void deleteCurrency(final CurrencyDto currency); - /*********************** CostCode ********************** */ + /*********************** CostCode ********************** */ - /** - * List all costcodes - * - * @return The list of costcodes - */ - CostCodesDto listCostCodes(); + /** + * List all costcodes + * + * @return The list of costcodes + */ + CostCodesDto listCostCodes(); - /** - * Get the given costcode - * - * @param costcodeId The id of the costcode - * @return The costcode - */ - CostCodeDto getCostCode(Integer costcodeId); + /** + * Get the given costcode + * + * @param costcodeId + * The id of the costcode + * @return The costcode + */ + CostCodeDto getCostCode(Integer costcodeId); - /** - * Create a new costcode - * - * @param costcode The costcode to be created. - * @return The created costcode. - */ - CostCodeDto createCostCode(CostCodeDto costcode); + /** + * Create a new costcode + * + * @param costcode + * The costcode to be created. + * @return The created costcode. + */ + CostCodeDto createCostCode(CostCodeDto costcode); - /** - * Updates an existing costcode - * - * @param costcode The new attributes for the costcode - * @return The updated costcode - */ - CostCodeDto updateCostCode(CostCodeDto costcode); + /** + * Updates an existing costcode + * + * @param costcode + * The new attributes for the costcode + * @return The updated costcode + */ + CostCodeDto updateCostCode(CostCodeDto costcode); - /** - * Deletes an existing costcode - * - * @param currency The costcode to delete - */ - void deleteCostCode(CostCodeDto costcode); + /** + * Deletes an existing costcode + * + * @param currency + * The costcode to delete + */ + void deleteCostCode(CostCodeDto costcode); - /*********************** PricingTemplate ********************** */ + /*********************** PricingTemplate ********************** */ - /** - * List all pricingtemplates - * - * @return The list of pricingtemplates - */ - PricingTemplatesDto listPricingTemplates(); + /** + * List all pricingtemplates + * + * @return The list of pricingtemplates + */ + PricingTemplatesDto listPricingTemplates(); - /** - * Get the given pricingtemplate - * - * @param pricingTemplateId The id of the pricingtemplate - * @return The pricingtemplate - */ - PricingTemplateDto getPricingTemplate(Integer pricingTemplateId); + /** + * Get the given pricingtemplate + * + * @param pricingTemplateId + * The id of the pricingtemplate + * @return The pricingtemplate + */ + PricingTemplateDto getPricingTemplate(Integer pricingTemplateId); - /** - * Create a new pricing template - * - * @param pricingtemplate The pricingtemplate to be created - * @return The created pricingtemplate - */ - PricingTemplateDto createPricingTemplate(PricingTemplateDto pricingtemplate); + /** + * Create a new pricing template + * + * @param pricingtemplate + * The pricingtemplate to be created + * @return The created pricingtemplate + */ + PricingTemplateDto createPricingTemplate(PricingTemplateDto pricingtemplate); - /** - * Updates an existing pricing template - * - * @param pricingtemplate The new attributes for the pricingtemplate - * @return The updated pricingtemplate - */ - PricingTemplateDto updatePricingTemplate(PricingTemplateDto pricingtemplate); + /** + * Updates an existing pricing template + * + * @param pricingtemplate + * The new attributes for the pricingtemplate + * @return The updated pricingtemplate + */ + PricingTemplateDto updatePricingTemplate(PricingTemplateDto pricingtemplate); - /** - * Deletes an existing pricingtemplate - * - * @param pricingtemplate The pricingtemplate to delete - */ - void deletePricingTemplate(PricingTemplateDto pricingtemplate); + /** + * Deletes an existing pricingtemplate + * + * @param pricingtemplate + * The pricingtemplate to delete + */ + void deletePricingTemplate(PricingTemplateDto pricingtemplate); - /*********************** CostCodeCurrency ********************** */ + /*********************** CostCodeCurrency ********************** */ - /** - * Get the given costcodecurrency - * - * @param costcodecurrencyId The id of the costcodecurrency - * @return The costcodecurrency - */ - CostCodeCurrenciesDto getCostCodeCurrencies(Integer costcodeId, Integer currencyId); + /** + * Get the given costcodecurrency + * + * @param costcodecurrencyId + * The id of the costcodecurrency + * @return The costcodecurrency + */ + CostCodeCurrenciesDto getCostCodeCurrencies(Integer costcodeId, Integer currencyId); - /** - * Updates cost code currencies - * - * @param costcodeCurrency The new attributes for the costcodecurrencies - * @return The updated costcodecurrencies - */ - CostCodeCurrenciesDto updateCostCodeCurrencies(Integer costcodeId, - CostCodeCurrenciesDto costcodeCurrencies); + /** + * Updates cost code currencies + * + * @param costcodeCurrency + * The new attributes for the costcodecurrencies + * @return The updated costcodecurrencies + */ + CostCodeCurrenciesDto updateCostCodeCurrencies(Integer costcodeId, CostCodeCurrenciesDto costcodeCurrencies); - /*********************** PricingTemplateCostCode ********************** */ + /*********************** PricingTemplateCostCode ********************** */ - /** - * Get the pricing cost codes for a pricing template - * - * @param pricingTemplateId - * @return pricingcostcodes - */ - PricingCostCodesDto getPricingCostCodes(Integer pricingTemplateId); + /** + * Get the pricing cost codes for a pricing template + * + * @param pricingTemplateId + * @return pricingcostcodes + */ + PricingCostCodesDto getPricingCostCodes(Integer pricingTemplateId); - /** - * Get the given pricing cost code - * - * @param pricingCostCodeId the id of the pricing cost code - * @return The pricingcostcode - */ - PricingCostCodeDto getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId); + /** + * Get the given pricing cost code + * + * @param pricingCostCodeId + * the id of the pricing cost code + * @return The pricingcostcode + */ + PricingCostCodeDto getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId); - /** - * Updates an existing pricingcostcode - * - * @param costcodeCurrency The new attributes for the pricingcostcode - * @return The updated pricingcostcode - */ - PricingCostCodeDto updatePricingCostCode(PricingCostCodeDto pricingCostCode, - Integer pricingTemplateId, Integer pricingCostCodeId); + /** + * Updates an existing pricingcostcode + * + * @param costcodeCurrency + * The new attributes for the pricingcostcode + * @return The updated pricingcostcode + */ + PricingCostCodeDto updatePricingCostCode(PricingCostCodeDto pricingCostCode, Integer pricingTemplateId, + Integer pricingCostCodeId); - /*********************** PricingTemplateTier ********************** */ + /*********************** PricingTemplateTier ********************** */ - /** - * Get the pricing tiers for a pricing template - * - * @param pricingTemplateId - * @return pricingtiers - */ - PricingTiersDto getPricingTiers(Integer pricingTemplateId); + /** + * Get the pricing tiers for a pricing template + * + * @param pricingTemplateId + * @return pricingtiers + */ + PricingTiersDto getPricingTiers(Integer pricingTemplateId); - /** - * Get the given pricing tier - * - * @param pricingTierId The id of the pricing tier - * @return The pricingtier - */ - PricingTierDto getPricingTier(Integer pricingTemplateId, Integer pricingTierId); + /** + * Get the given pricing tier + * + * @param pricingTierId + * The id of the pricing tier + * @return The pricingtier + */ + PricingTierDto getPricingTier(Integer pricingTemplateId, Integer pricingTierId); - /** - * Updates an existing pricing tier - * - * @param costcodeCurrency The new attributes for the pricing tier - * @return The updated pricing tier - */ - PricingTierDto updatePricingTier(PricingTierDto pricingTier, Integer pricingTemplateId, - Integer pricingTierId); + /** + * Updates an existing pricing tier + * + * @param costcodeCurrency + * The new attributes for the pricing tier + * @return The updated pricing tier + */ + PricingTierDto updatePricingTier(PricingTierDto pricingTier, Integer pricingTemplateId, Integer pricingTierId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingAsyncApi.java index 688b7749fa..952c7c483e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/PricingAsyncApi.java @@ -62,256 +62,243 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Susana Acedo */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/config") -public interface PricingAsyncApi -{ - /*********************** Currency ********************** */ +public interface PricingAsyncApi { + /*********************** Currency ********************** */ - /** - * @see ConfigApi#listCurrencies() - */ - @GET - @Path("/currencies") - @Consumes(CurrenciesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCurrencies(); + /** + * @see ConfigApi#listCurrencies() + */ + @GET + @Path("/currencies") + @Consumes(CurrenciesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listCurrencies(); - /** - * @see ConfigApi#getCurrency(Integer) - */ - @GET - @Path("/currencies/{currency}") - @Consumes(CurrencyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCurrency(@PathParam("currency") Integer currencyId); + /** + * @see ConfigApi#getCurrency(Integer) + */ + @GET + @Path("/currencies/{currency}") + @Consumes(CurrencyDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCurrency(@PathParam("currency") Integer currencyId); - /** - * @see ConfigApi#createCurrency(CurrencyDto) - */ - @POST - @Path("/currencies") - @Produces(CurrencyDto.BASE_MEDIA_TYPE) - @Consumes(CurrencyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createCurrency( - @BinderParam(BindToXMLPayload.class) CurrencyDto currency); + /** + * @see ConfigApi#createCurrency(CurrencyDto) + */ + @POST + @Path("/currencies") + @Produces(CurrencyDto.BASE_MEDIA_TYPE) + @Consumes(CurrencyDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createCurrency(@BinderParam(BindToXMLPayload.class) CurrencyDto currency); - /** - * @see ConfigApi#updateCurrency(CurrencyDto) - */ - @PUT - @Produces(CurrencyDto.BASE_MEDIA_TYPE) - @Consumes(CurrencyDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateCurrency( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CurrencyDto currency); + /** + * @see ConfigApi#updateCurrency(CurrencyDto) + */ + @PUT + @Produces(CurrencyDto.BASE_MEDIA_TYPE) + @Consumes(CurrencyDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateCurrency( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CurrencyDto currency); - /** - * @see ConfigApi#deleteCurrency(CurrencyDto) - */ - @DELETE - ListenableFuture deleteCurrency( - @EndpointLink("edit") @BinderParam(BindToPath.class) CurrencyDto currency); + /** + * @see ConfigApi#deleteCurrency(CurrencyDto) + */ + @DELETE + ListenableFuture deleteCurrency(@EndpointLink("edit") @BinderParam(BindToPath.class) CurrencyDto currency); - /*********************** CostCode ********************** */ + /*********************** CostCode ********************** */ - /** - * @see PricingApi#listCostCodes() - */ - @GET - @Path("/costcodes") - @Consumes(CostCodesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listCostCodes(); + /** + * @see PricingApi#listCostCodes() + */ + @GET + @Path("/costcodes") + @Consumes(CostCodesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listCostCodes(); - /** - * @see PricingApi#getCostCode(Integer) - */ - @GET - @Path("/costcodes/{costcode}") - @Consumes(CostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCostCode(@PathParam("costcode") Integer costcodeId); + /** + * @see PricingApi#getCostCode(Integer) + */ + @GET + @Path("/costcodes/{costcode}") + @Consumes(CostCodeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCostCode(@PathParam("costcode") Integer costcodeId); - /** - * @see PricingApi#createCostCode(CostCodeDto) - */ - @POST - @Path("/costcodes") - @Produces(CostCodeDto.BASE_MEDIA_TYPE) - @Consumes(CostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createCostCode( - @BinderParam(BindToXMLPayload.class) CostCodeDto costcode); + /** + * @see PricingApi#createCostCode(CostCodeDto) + */ + @POST + @Path("/costcodes") + @Produces(CostCodeDto.BASE_MEDIA_TYPE) + @Consumes(CostCodeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createCostCode(@BinderParam(BindToXMLPayload.class) CostCodeDto costcode); - /** - * @see PricingApi#updateCostCode(CostCodeDto) - */ - @PUT - @Produces(CostCodeDto.BASE_MEDIA_TYPE) - @Consumes(CostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateCostCode( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CostCodeDto costcode); + /** + * @see PricingApi#updateCostCode(CostCodeDto) + */ + @PUT + @Produces(CostCodeDto.BASE_MEDIA_TYPE) + @Consumes(CostCodeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateCostCode( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) CostCodeDto costcode); - /** - * @see PricingApi#deleteCostCode(CostCodeDto) - */ - @DELETE - ListenableFuture deleteCostCode( - @EndpointLink("edit") @BinderParam(BindToPath.class) CostCodeDto costcode); + /** + * @see PricingApi#deleteCostCode(CostCodeDto) + */ + @DELETE + ListenableFuture deleteCostCode(@EndpointLink("edit") @BinderParam(BindToPath.class) CostCodeDto costcode); - /*********************** PricingTemplate ********************** */ + /*********************** PricingTemplate ********************** */ - /** - * @see PricingApi#listPricingTemplates() - */ - @GET - @Path("/pricingtemplates") - @Consumes(PricingTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listPricingTemplates(); + /** + * @see PricingApi#listPricingTemplates() + */ + @GET + @Path("/pricingtemplates") + @Consumes(PricingTemplatesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listPricingTemplates(); - /** - * @see PricingApi#getPricingTemplate(Integer) - */ - @GET - @Path("/pricingtemplates/{pricingtemplate}") - @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPricingTemplate( - @PathParam("pricingtemplate") Integer pricingTemplateId); + /** + * @see PricingApi#getPricingTemplate(Integer) + */ + @GET + @Path("/pricingtemplates/{pricingtemplate}") + @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPricingTemplate(@PathParam("pricingtemplate") Integer pricingTemplateId); - /** - * @see PricingApi#createPricingTemplate(PricingTemplateDto) - */ - @POST - @Path("/pricingtemplates") - @Produces(PricingTemplateDto.BASE_MEDIA_TYPE) - @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture createPricingTemplate( - @BinderParam(BindToXMLPayload.class) PricingTemplateDto pricingtemplate); + /** + * @see PricingApi#createPricingTemplate(PricingTemplateDto) + */ + @POST + @Path("/pricingtemplates") + @Produces(PricingTemplateDto.BASE_MEDIA_TYPE) + @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture createPricingTemplate( + @BinderParam(BindToXMLPayload.class) PricingTemplateDto pricingtemplate); - /** - * @see PricingApi#updatePricingTemplate(PricingTemplateDto) - */ - @PUT - @Produces(PricingTemplateDto.BASE_MEDIA_TYPE) - @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updatePricingTemplate( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTemplateDto pricingtemplate); + /** + * @see PricingApi#updatePricingTemplate(PricingTemplateDto) + */ + @PUT + @Produces(PricingTemplateDto.BASE_MEDIA_TYPE) + @Consumes(PricingTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updatePricingTemplate( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTemplateDto pricingtemplate); - /** - * @see PricingApi#deletePricingTemplate(PricingTemplateDto) - */ - @DELETE - ListenableFuture deletePricingTemplate( - @EndpointLink("edit") @BinderParam(BindToPath.class) PricingTemplateDto pricingtemplate); + /** + * @see PricingApi#deletePricingTemplate(PricingTemplateDto) + */ + @DELETE + ListenableFuture deletePricingTemplate( + @EndpointLink("edit") @BinderParam(BindToPath.class) PricingTemplateDto pricingtemplate); - /*********************** CostCodeCurrency ********************** */ + /*********************** CostCodeCurrency ********************** */ - /** - * @see PricingApi#getCostCodeCurrency(Integer) - */ - @GET - @Path("/costcodes/{costcode}/currencies") - @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCostCodeCurrencies( - @PathParam("costcode") Integer costcodeId, @QueryParam("idCurrency") Integer currencyId); + /** + * @see PricingApi#getCostCodeCurrency(Integer) + */ + @GET + @Path("/costcodes/{costcode}/currencies") + @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCostCodeCurrencies(@PathParam("costcode") Integer costcodeId, + @QueryParam("idCurrency") Integer currencyId); - /** - * @see PricingApi#updateCostCodeCurrencies(CostCodeCurrenciesDto) - */ - @PUT - @Path("/costcodes/{costcode}/currencies") - @Produces(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) - @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateCostCodeCurrencies( - @PathParam("costcode") Integer costcodeId, - @BinderParam(BindToXMLPayload.class) CostCodeCurrenciesDto costcodecurrencies); + /** + * @see PricingApi#updateCostCodeCurrencies(CostCodeCurrenciesDto) + */ + @PUT + @Path("/costcodes/{costcode}/currencies") + @Produces(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) + @Consumes(CostCodeCurrenciesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateCostCodeCurrencies(@PathParam("costcode") Integer costcodeId, + @BinderParam(BindToXMLPayload.class) CostCodeCurrenciesDto costcodecurrencies); - /*********************** PricingCostCode ********************** */ + /*********************** PricingCostCode ********************** */ - /** - * @see PricingApi#getPricingCostCodes(Integer) - */ - @GET - @Path("/pricingtemplates/{pricingtemplate}/costcodes") - @Consumes(PricingCostCodesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPricingCostCodes( - @PathParam("pricingtemplate") Integer pricingTemplateId); + /** + * @see PricingApi#getPricingCostCodes(Integer) + */ + @GET + @Path("/pricingtemplates/{pricingtemplate}/costcodes") + @Consumes(PricingCostCodesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPricingCostCodes(@PathParam("pricingtemplate") Integer pricingTemplateId); - /** - * @see PricingApi#getPricingCostCode(Integer) - */ - @GET - @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}") - @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPricingCostCode( - @PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("costcode") Integer pricingCostcodeId); + /** + * @see PricingApi#getPricingCostCode(Integer) + */ + @GET + @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}") + @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPricingCostCode(@PathParam("pricingtemplate") Integer pricingTemplateId, + @PathParam("costcode") Integer pricingCostcodeId); - /** - * @see PricingApi#updatePricingCostCode(PricingCostCodeDto) - */ - @PUT - @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}") - @Produces(PricingCostCodeDto.BASE_MEDIA_TYPE) - @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updatePricingCostCode( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingCostCodeDto pricingcostcode, - @PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("costcode") Integer pricingCostcodeId); + /** + * @see PricingApi#updatePricingCostCode(PricingCostCodeDto) + */ + @PUT + @Path("/pricingtemplates/{pricingtemplate}/costcodes/{costcode}") + @Produces(PricingCostCodeDto.BASE_MEDIA_TYPE) + @Consumes(PricingCostCodeDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updatePricingCostCode( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingCostCodeDto pricingcostcode, + @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("costcode") Integer pricingCostcodeId); - /*********************** PricingTier ********************** */ + /*********************** PricingTier ********************** */ - /** - * @see PricingApi#getPricingTiers(Integer) - */ - @GET - @Path("/pricingtemplates/{pricingtemplate}/tiers") - @Consumes(PricingTiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPricingTiers( - @PathParam("pricingtemplate") Integer pricingTemplateId); + /** + * @see PricingApi#getPricingTiers(Integer) + */ + @GET + @Path("/pricingtemplates/{pricingtemplate}/tiers") + @Consumes(PricingTiersDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPricingTiers(@PathParam("pricingtemplate") Integer pricingTemplateId); - /** - * @see PricingApi#getPricingTier(Integer) - */ - @GET - @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}") - @Consumes(PricingTierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPricingTier( - @PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("tier") Integer pricingTierId); + /** + * @see PricingApi#getPricingTier(Integer) + */ + @GET + @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}") + @Consumes(PricingTierDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPricingTier(@PathParam("pricingtemplate") Integer pricingTemplateId, + @PathParam("tier") Integer pricingTierId); - /** - * @see PricingApi#updatePricingTier(PricingTierDto) - */ - @PUT - @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}") - @Produces(PricingTierDto.BASE_MEDIA_TYPE) - @Consumes(PricingTierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updatePricingTier( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTierDto pricingtier, - @PathParam("pricingtemplate") Integer pricingTemplateId, - @PathParam("tier") Integer pricingTierId); + /** + * @see PricingApi#updatePricingTier(PricingTierDto) + */ + @PUT + @Path("/pricingtemplates/{pricingtemplate}/tiers/{tier}") + @Produces(PricingTierDto.BASE_MEDIA_TYPE) + @Consumes(PricingTierDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updatePricingTier( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) PricingTierDto pricingtier, + @PathParam("pricingtemplate") Integer pricingTemplateId, @PathParam("tier") Integer pricingTierId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java index 92505dccff..cb4b32423a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java @@ -38,23 +38,24 @@ import com.abiquo.server.core.task.TasksDto; * @author Francesc Montserrat */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface TaskApi -{ - /*********************** Task ***********************/ +public interface TaskApi { + /*********************** Task ***********************/ - /** - * Get a task from its link. - * - * @param link The link of the task. - * @return The task. - */ - TaskDto getTask(final RESTLink link); + /** + * Get a task from its link. + * + * @param link + * The link of the task. + * @return The task. + */ + TaskDto getTask(final RESTLink link); - /** - * Get the list of tasks of the given object. - * - * @param dto The object. - * @return The list of tasks for the given object. - */ - TasksDto listTasks(T dto); + /** + * Get the list of tasks of the given object. + * + * @param dto + * The object. + * @return The list of tasks for the given object. + */ + TasksDto listTasks(T dto); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskAsyncApi.java index 1c1bd5be91..9d5531dc63 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/TaskAsyncApi.java @@ -48,26 +48,25 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) -public interface TaskAsyncApi -{ - /*********************** Task ***********************/ +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) +public interface TaskAsyncApi { + /*********************** Task ***********************/ - /** - * @see TaskApi#getTask(RESTLink) - */ - @GET - @Consumes(TaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOn303.class) - ListenableFuture getTask(@BinderParam(BindLinkToPath.class) RESTLink link); + /** + * @see TaskApi#getTask(RESTLink) + */ + @GET + @Consumes(TaskDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOn303.class) + ListenableFuture getTask(@BinderParam(BindLinkToPath.class) RESTLink link); - /** - * @see TaskApi#listTasks(SingleResourceTransportDto) - */ - @GET - @Consumes(TasksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listTasks( - @EndpointLink("tasks") @BinderParam(BindToPath.class) T dto); + /** + * @see TaskApi#listTasks(SingleResourceTransportDto) + */ + @GET + @Consumes(TasksDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listTasks( + @EndpointLink("tasks") @BinderParam(BindToPath.class) T dto); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java index 8fa30ea194..3c8237ace5 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java @@ -43,109 +43,134 @@ import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; * @author Francesc Montserrat */ @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) -public interface VirtualMachineTemplateApi -{ - /*********************** Virtual Machine Template ***********************/ +public interface VirtualMachineTemplateApi { + /*********************** Virtual Machine Template ***********************/ - /** - * List all virtual machine templates for an enterprise in a datacenter repository. - * - * @param enterpriseId Id of the enterprise. - * @param datacenterRepositoryId Id of the datacenter repository contaning the templates. - * @return The list of virtual machine templates for the enterprise in the datacenter - * repository. - */ - VirtualMachineTemplatesDto listVirtualMachineTemplates(Integer enterpriseId, - Integer datacenterRepositoryId); + /** + * List all virtual machine templates for an enterprise in a datacenter + * repository. + * + * @param enterpriseId + * Id of the enterprise. + * @param datacenterRepositoryId + * Id of the datacenter repository contaning the templates. + * @return The list of virtual machine templates for the enterprise in the + * datacenter repository. + */ + VirtualMachineTemplatesDto listVirtualMachineTemplates(Integer enterpriseId, Integer datacenterRepositoryId); - /** - * List all virtual machine templates for an enterprise in a datacenter repository. - * - * @param enterpriseId Id of the enterprise. - * @param datacenterRepositoryId Id of the datacenter repository contaning the templates. - * @param options The options to query the virtual machine templates. - * @return The filtered list of virtual machine templates for the enterprise in the datacenter - * repository. - */ - VirtualMachineTemplatesDto listVirtualMachineTemplates(Integer enterpriseId, - Integer datacenterRepositoryId, VirtualMachineTemplateOptions options); + /** + * List all virtual machine templates for an enterprise in a datacenter + * repository. + * + * @param enterpriseId + * Id of the enterprise. + * @param datacenterRepositoryId + * Id of the datacenter repository contaning the templates. + * @param options + * The options to query the virtual machine templates. + * @return The filtered list of virtual machine templates for the enterprise + * in the datacenter repository. + */ + VirtualMachineTemplatesDto listVirtualMachineTemplates(Integer enterpriseId, Integer datacenterRepositoryId, + VirtualMachineTemplateOptions options); - /** - * Get the given virtual machine template. - * - * @param enterpriseId Id of the enterprise. - * @param datacenterRepositoryId Id of the datacenter repository contaning the templates. - * @param enterpriseId The id of the virtual machine template. - * @return The virtual machine template or null if it does not exist. - */ - VirtualMachineTemplateDto getVirtualMachineTemplate(Integer entepriseId, - Integer datacenterRepositoryId, Integer virtualMachineTemplateId); + /** + * Get the given virtual machine template. + * + * @param enterpriseId + * Id of the enterprise. + * @param datacenterRepositoryId + * Id of the datacenter repository contaning the templates. + * @param enterpriseId + * The id of the virtual machine template. + * @return The virtual machine template or null if it does not + * exist. + */ + VirtualMachineTemplateDto getVirtualMachineTemplate(Integer entepriseId, Integer datacenterRepositoryId, + Integer virtualMachineTemplateId); - /** - * Updates an existing virtual machine template. - * - * @param template The new attributes for the template. - * @return The updated template. - */ - VirtualMachineTemplateDto updateVirtualMachineTemplate(VirtualMachineTemplateDto template); + /** + * Updates an existing virtual machine template. + * + * @param template + * The new attributes for the template. + * @return The updated template. + */ + VirtualMachineTemplateDto updateVirtualMachineTemplate(VirtualMachineTemplateDto template); - /** - * Deletes an existing virtual machine template. - * - * @param template The virtual machine template to delete. - */ - void deleteVirtualMachineTemplate(VirtualMachineTemplateDto template); + /** + * Deletes an existing virtual machine template. + * + * @param template + * The virtual machine template to delete. + */ + void deleteVirtualMachineTemplate(VirtualMachineTemplateDto template); - /** - * Creates a persistent virtual machine template from other virtual machine template. - * - * @param dcRepository The repository where the persistent virtual machine template will be - * created. - * @param options The persistent options like name, volume/tier, virtual datacenter and original - * template. - * @return Response message to the persistent request. - */ - @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) - AcceptedRequestDto createPersistentVirtualMachineTemplate(Integer enterpriseId, - Integer datacenterRepositoryId, VirtualMachineTemplatePersistentDto persistentOptions); + /** + * Creates a persistent virtual machine template from other virtual machine + * template. + * + * @param dcRepository + * The repository where the persistent virtual machine template + * will be created. + * @param options + * The persistent options like name, volume/tier, virtual + * datacenter and original template. + * @return Response message to the persistent request. + */ + @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) + AcceptedRequestDto createPersistentVirtualMachineTemplate(Integer enterpriseId, + Integer datacenterRepositoryId, VirtualMachineTemplatePersistentDto persistentOptions); - /** - * List all the conversions for a virtual machine template. - * - * @param template, The virtual machine template of the conversions. - * @return The list of conversions for the virtual machine template. - */ - ConversionsDto listConversions(VirtualMachineTemplateDto template); + /** + * List all the conversions for a virtual machine template. + * + * @param template + * , The virtual machine template of the conversions. + * @return The list of conversions for the virtual machine template. + */ + ConversionsDto listConversions(VirtualMachineTemplateDto template); - /** - * List conversions for a virtual machine template. - * - * @param template, The virtual machine template of the conversions - * @param options, Optionally filter compatible conversions with a provided hypervisor or with - * the desired state. - * @return The list of conversions for the virtual machine template with the applied constrains. - */ - ConversionsDto listConversions(VirtualMachineTemplateDto template, ConversionOptions options); + /** + * List conversions for a virtual machine template. + * + * @param template + * , The virtual machine template of the conversions + * @param options + * , Optionally filter compatible conversions with a provided + * hypervisor or with the desired state. + * @return The list of conversions for the virtual machine template with the + * applied constrains. + */ + ConversionsDto listConversions(VirtualMachineTemplateDto template, ConversionOptions options); - /** - * Get the conversions for a virtual machine template and the desired target format. - * - * @param template, The virtual machine template of the conversion - * @param targetFormat The disk format type of the requested conversion - * @return The conversions for the virtual machine template with the desired target disk format - * type. - */ - ConversionDto getConversion(VirtualMachineTemplateDto template, DiskFormatType targetFormat); + /** + * Get the conversions for a virtual machine template and the desired target + * format. + * + * @param template + * , The virtual machine template of the conversion + * @param targetFormat + * The disk format type of the requested conversion + * @return The conversions for the virtual machine template with the desired + * target disk format type. + */ + ConversionDto getConversion(VirtualMachineTemplateDto template, DiskFormatType targetFormat); - /** - * Starts a V2V conversion of the current virtual machine template, or updates a failed - * conversion. - * - * @param template The virtual machine template to convert - * @param targetFormat The requested target {@link DiskFormatType} of the conversion. - * @param conversion, the dto representing the conversion - * @return an accepted request with a link to track the progress of the conversion tasks. - */ - AcceptedRequestDto requestConversion(VirtualMachineTemplateDto template, - DiskFormatType targetFormat, ConversionDto conversion); + /** + * Starts a V2V conversion of the current virtual machine template, or + * updates a failed conversion. + * + * @param template + * The virtual machine template to convert + * @param targetFormat + * The requested target {@link DiskFormatType} of the conversion. + * @param conversion + * , the dto representing the conversion + * @return an accepted request with a link to track the progress of the + * conversion tasks. + */ + AcceptedRequestDto requestConversion(VirtualMachineTemplateDto template, DiskFormatType targetFormat, + ConversionDto conversion); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApi.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApi.java index ed3821bd3b..88497766e7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApi.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApi.java @@ -56,129 +56,130 @@ import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Abiquo Abiquo Apps library API. * @see API: + * Provides asynchronous access to Abiquo Abiquo Apps library API. * @see API: + * * http://community.abiquo.com/display/ABI20/API+Reference * * @see VirtualMachineTemplateApi * @author Ignasi Barrera * @author Francesc Montserrat */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) @Path("/admin/enterprises") -public interface VirtualMachineTemplateAsyncApi -{ - /*********************** Virtual Machine Template ***********************/ +public interface VirtualMachineTemplateAsyncApi { + /*********************** Virtual Machine Template ***********************/ - /** - * @see VirtualMachineTemplateApi#listVirtualMachineTemplates(Integer, Integer) - */ - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachineTemplates( - @PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId); + /** + * @see VirtualMachineTemplateApi#listVirtualMachineTemplates(Integer, + * Integer) + */ + @GET + @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") + @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachineTemplates( + @PathParam("enterprise") Integer enterpriseId, + @PathParam("datacenterrepository") Integer datacenterRepositoryId); - /** - * @see VirtualMachineTemplateApi#listVirtualMachineTemplates(Integer, Integer, - * VirtualMachineTemplateOptions) - */ - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listVirtualMachineTemplates( - @PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - VirtualMachineTemplateOptions options); + /** + * @see VirtualMachineTemplateApi#listVirtualMachineTemplates(Integer, + * Integer, VirtualMachineTemplateOptions) + */ + @GET + @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") + @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listVirtualMachineTemplates( + @PathParam("enterprise") Integer enterpriseId, + @PathParam("datacenterrepository") Integer datacenterRepositoryId, VirtualMachineTemplateOptions options); - /** - * @see VirtualMachineTemplateApi#getVirtualMachineTemplate(Integer, Integer, Integer) - */ - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates/{virtualmachinetemplate}") - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualMachineTemplate( - @PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - @PathParam("virtualmachinetemplate") Integer virtualMachineTemplateId); + /** + * @see VirtualMachineTemplateApi#getVirtualMachineTemplate(Integer, Integer, + * Integer) + */ + @GET + @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates/{virtualmachinetemplate}") + @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualMachineTemplate(@PathParam("enterprise") Integer enterpriseId, + @PathParam("datacenterrepository") Integer datacenterRepositoryId, + @PathParam("virtualmachinetemplate") Integer virtualMachineTemplateId); - /** - * @see VirtualMachineTemplateApi#updateVirtualMachineTemplate(VirtualMachineTemplateDto) - */ - @PUT - @Produces(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture updateVirtualMachineTemplate( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineTemplateDto template); + /** + * @see VirtualMachineTemplateApi#updateVirtualMachineTemplate(VirtualMachineTemplateDto) + */ + @PUT + @Produces(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) + @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture updateVirtualMachineTemplate( + @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineTemplateDto template); - /** - * @see VirtualMachineTemplateApi#deleteVirtualMachineTemplate(VirtualMachineTemplateDto) - */ - @DELETE - ListenableFuture deleteVirtualMachineTemplate( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); + /** + * @see VirtualMachineTemplateApi#deleteVirtualMachineTemplate(VirtualMachineTemplateDto) + */ + @DELETE + ListenableFuture deleteVirtualMachineTemplate( + @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - /** - * @see VirtualMachineTemplateApi#createPersistentVirtualMachineTemplate(DatacenterRepositoryDto, - * VirtualMachineTemplatePersistentDto) - */ - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTemplatePersistentDto.BASE_MEDIA_TYPE) - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @JAXBResponseParser - ListenableFuture> createPersistentVirtualMachineTemplate( - @PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - @BinderParam(BindToXMLPayload.class) VirtualMachineTemplatePersistentDto persistentOptions); + /** + * @see VirtualMachineTemplateApi#createPersistentVirtualMachineTemplate(DatacenterRepositoryDto, + * VirtualMachineTemplatePersistentDto) + */ + @POST + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(VirtualMachineTemplatePersistentDto.BASE_MEDIA_TYPE) + @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") + @JAXBResponseParser + ListenableFuture> createPersistentVirtualMachineTemplate( + @PathParam("enterprise") Integer enterpriseId, + @PathParam("datacenterrepository") Integer datacenterRepositoryId, + @BinderParam(BindToXMLPayload.class) VirtualMachineTemplatePersistentDto persistentOptions); - /*********************** Conversions ***********************/ + /*********************** Conversions ***********************/ - /** - * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto) - */ - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); + /** + * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto) + */ + @GET + @Consumes(ConversionsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listConversions( + @EndpointLink("conversions") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - /** - * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto, ConversionOptions) - */ - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ListenableFuture listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - ConversionOptions options); + /** + * @see VirtualMachineTemplateApi#listConversions(VirtualMachineTemplateDto, + * ConversionOptions) + */ + @GET + @Consumes(ConversionsDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + ListenableFuture listConversions( + @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, + ConversionOptions options); - /** - * @see VirtualMachineTemplateApi#getConversion(VirtualMachineTemplateDto, DiskFormatType) - */ - @GET - @Consumes(ConversionDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getConversion( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - @BinderParam(AppendToPath.class) DiskFormatType targetFormat); + /** + * @see VirtualMachineTemplateApi#getConversion(VirtualMachineTemplateDto, + * DiskFormatType) + */ + @GET + @Consumes(ConversionDto.BASE_MEDIA_TYPE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getConversion( + @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, + @BinderParam(AppendToPath.class) DiskFormatType targetFormat); - /** - * @see VirtualMachineTemplateApi#updateConversion(ConversinoDto) - */ - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(ConversionDto.BASE_MEDIA_TYPE) - ListenableFuture> requestConversion( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - @BinderParam(AppendToPath.class) DiskFormatType targetFormat, - @BinderParam(BindToXMLPayload.class) ConversionDto conversion); + /** + * @see VirtualMachineTemplateApi#updateConversion(ConversinoDto) + */ + @PUT + @ResponseParser(ReturnTaskReferenceOrNull.class) + @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) + @Produces(ConversionDto.BASE_MEDIA_TYPE) + ListenableFuture> requestConversion( + @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, + @BinderParam(AppendToPath.class) DiskFormatType targetFormat, + @BinderParam(BindToXMLPayload.class) ConversionDto conversion); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java index ab483b20ed..a6648d171e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java @@ -43,199 +43,206 @@ import com.google.inject.ImplementedBy; * @author Francesc Montserrat */ @ImplementedBy(BaseAdministrationService.class) -public interface AdministrationService -{ - /*********************** Datacenter ***********************/ +public interface AdministrationService { + /*********************** Datacenter ***********************/ - /** - * Get the list of all datacenters. - */ - Iterable listDatacenters(); + /** + * Get the list of all datacenters. + */ + Iterable listDatacenters(); - /** - * Get the list of datacenters matching the given filter. - */ - Iterable listDatacenters(final Predicate filter); + /** + * Get the list of datacenters matching the given filter. + */ + Iterable listDatacenters(final Predicate filter); - /** - * Get the first datacenter that matches the given filter or null if none is found. - */ - Datacenter findDatacenter(final Predicate filter); + /** + * Get the first datacenter that matches the given filter or + * null if none is found. + */ + Datacenter findDatacenter(final Predicate filter); - /** - * Get the datacenter with the given id. - */ - Datacenter getDatacenter(final Integer datacenterId); + /** + * Get the datacenter with the given id. + */ + Datacenter getDatacenter(final Integer datacenterId); - /** - * Get the list of datacenters with the given ids. - */ - Iterable getDatacenters(final List datacenterIds); + /** + * Get the list of datacenters with the given ids. + */ + Iterable getDatacenters(final List datacenterIds); - /*********************** Machine ***********************/ + /*********************** Machine ***********************/ - /** - * Get the list of all machines in the infrastructure. - */ - public Iterable listMachines(); + /** + * Get the list of all machines in the infrastructure. + */ + public Iterable listMachines(); - /** - * Get the list of all machines in the infrastructure matching the given filter. - */ - public Iterable listMachines(Predicate filter); + /** + * Get the list of all machines in the infrastructure matching the given + * filter. + */ + public Iterable listMachines(Predicate filter); - /** - * Get the first machine in the infrastructure that matches the given filter. - */ - public Machine findMachine(Predicate filter); + /** + * Get the first machine in the infrastructure that matches the given filter. + */ + public Machine findMachine(Predicate filter); - /*********************** Enterprise ***********************/ + /*********************** Enterprise ***********************/ - /** - * Get the list of all enterprises. - */ - Iterable listEnterprises(); + /** + * Get the list of all enterprises. + */ + Iterable listEnterprises(); - /** - * Get the list of enterprises matching the given filter. - */ - Iterable listEnterprises(final Predicate filter); + /** + * Get the list of enterprises matching the given filter. + */ + Iterable listEnterprises(final Predicate filter); - /** - * Get the first enterprises that matches the given filter or null if none is - * found. - */ - Enterprise findEnterprise(final Predicate filter); + /** + * Get the first enterprises that matches the given filter or + * null if none is found. + */ + Enterprise findEnterprise(final Predicate filter); - /** - * Get the enterprise with the given id. - */ - Enterprise getEnterprise(final Integer enterpriseId); + /** + * Get the enterprise with the given id. + */ + Enterprise getEnterprise(final Integer enterpriseId); - /*********************** Enterprise Properties ***********************/ - /** - * Get the properties of an enterprise. - */ - EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise); + /*********************** Enterprise Properties ***********************/ + /** + * Get the properties of an enterprise. + */ + EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise); - /*********************** Role ***********************/ + /*********************** Role ***********************/ - /** - * Get the list of global roles. - */ - Iterable listRoles(); + /** + * Get the list of global roles. + */ + Iterable listRoles(); - /** - * Get the list of roles matching the given filter. - */ - Iterable listRoles(final Predicate filter); + /** + * Get the list of roles matching the given filter. + */ + Iterable listRoles(final Predicate filter); - /** - * Get the first role that matches the given filter or null if none is found. - */ - Role findRole(final Predicate filter); + /** + * Get the first role that matches the given filter or null if + * none is found. + */ + Role findRole(final Predicate filter); - /** - * Get the role with the given id. - */ - Role getRole(final Integer roleId); + /** + * Get the role with the given id. + */ + Role getRole(final Integer roleId); - /*********************** Privilege ***********************/ + /*********************** Privilege ***********************/ - /** - * Get the list of global privileges. - */ - Iterable listPrivileges(); + /** + * Get the list of global privileges. + */ + Iterable listPrivileges(); - /** - * Get the list of privileges matching the given filter. - */ - Iterable listPrivileges(final Predicate filter); + /** + * Get the list of privileges matching the given filter. + */ + Iterable listPrivileges(final Predicate filter); - /** - * Get the first privilege that matches the given filter or null if none is found. - */ - Privilege findPrivilege(final Predicate filter); + /** + * Get the first privilege that matches the given filter or null + * if none is found. + */ + Privilege findPrivilege(final Predicate filter); - /*********************** User ***********************/ + /*********************** User ***********************/ - /** - * Get the current user. - */ - User getCurrentUser(); + /** + * Get the current user. + */ + User getCurrentUser(); - /** - * Get the enterprise of the current user. - */ - Enterprise getCurrentEnterprise(); + /** + * Get the enterprise of the current user. + */ + Enterprise getCurrentEnterprise(); - /*********************** License ***********************/ + /*********************** License ***********************/ - /** - * Get the list of all licenses. - */ - Iterable listLicenses(); + /** + * Get the list of all licenses. + */ + Iterable listLicenses(); - /** - * Get the list of all active/inactive licenses. - * - * @param active Defines if searching for active (true) or inactive ( - * false) licenses. - */ - Iterable listLicenses(boolean active); + /** + * Get the list of all active/inactive licenses. + * + * @param active + * Defines if searching for active (true) or inactive + * ( false) licenses. + */ + Iterable listLicenses(boolean active); - /** - * Get the list of licenses matching the given filter. - */ - Iterable listLicenses(final Predicate filter); + /** + * Get the list of licenses matching the given filter. + */ + Iterable listLicenses(final Predicate filter); - /** - * Get the first license that matches the given filter or null if none is found. - */ - License findLicense(final Predicate filter); + /** + * Get the first license that matches the given filter or null + * if none is found. + */ + License findLicense(final Predicate filter); - /*********************** System Properties ***********************/ + /*********************** System Properties ***********************/ - /** - * Get the list of system properties. - */ - Iterable listSystemProperties(); + /** + * Get the list of system properties. + */ + Iterable listSystemProperties(); - /** - * Get the list of system properties matching the given filter. - */ - Iterable listSystemProperties(final Predicate filter); + /** + * Get the list of system properties matching the given filter. + */ + Iterable listSystemProperties(final Predicate filter); - /** - * Get the first system property that matches the given filter or null if none is - * found. - */ - SystemProperty findSystemProperty(final Predicate filter); + /** + * Get the first system property that matches the given filter or + * null if none is found. + */ + SystemProperty findSystemProperty(final Predicate filter); - /** - * Get the system property with the give name or null if none is found. - */ - SystemProperty getSystemProperty(String name); + /** + * Get the system property with the give name or null if none is + * found. + */ + SystemProperty getSystemProperty(String name); - /** - * Get the list of system properties with options. - */ - Iterable listSystemProperties(String component); + /** + * Get the list of system properties with options. + */ + Iterable listSystemProperties(String component); - /*********************** Category ***********************/ + /*********************** Category ***********************/ - /** - * Get the list of categories. - */ - Iterable listCategories(); + /** + * Get the list of categories. + */ + Iterable listCategories(); - /** - * Get the list of categories matching the given filter. - */ - Iterable listCategories(final Predicate filter); + /** + * Get the list of categories matching the given filter. + */ + Iterable listCategories(final Predicate filter); - /** - * Get the first categories that matches the given filter or null if none is found. - */ - Category findCategory(final Predicate filter); + /** + * Get the first categories that matches the given filter or + * null if none is found. + */ + Category findCategory(final Predicate filter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java index 18e597cbb2..9ab79e84c8 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java @@ -37,75 +37,76 @@ import com.google.inject.ImplementedBy; * @author Francesc Montserrat */ @ImplementedBy(BaseCloudService.class) -public interface CloudService -{ - /*********************** Virtual Datacenter ***********************/ +public interface CloudService { + /*********************** Virtual Datacenter ***********************/ - /** - * Get the list of all virtual datacenters. - */ - Iterable listVirtualDatacenters(); + /** + * Get the list of all virtual datacenters. + */ + Iterable listVirtualDatacenters(); - /** - * Get the list of all virtual datacenters for a pair enterprise-datacenter. - * - * @param enterprise The given enterprise. - * @param datacenter The given datacenter. - */ - Iterable listVirtualDatacenters(final Enterprise enterprise); + /** + * Get the list of all virtual datacenters for a pair enterprise-datacenter. + * + * @param enterprise + * The given enterprise. + * @param datacenter + * The given datacenter. + */ + Iterable listVirtualDatacenters(final Enterprise enterprise); - /** - * Get the list of virtual datacenters matching the given filter. - */ - Iterable listVirtualDatacenters(final Predicate filter); + /** + * Get the list of virtual datacenters matching the given filter. + */ + Iterable listVirtualDatacenters(final Predicate filter); - /** - * Get the first virtual datacenter that matches the given filter or null if none - * is found. - */ - VirtualDatacenter findVirtualDatacenter(final Predicate filter); + /** + * Get the first virtual datacenter that matches the given filter or + * null if none is found. + */ + VirtualDatacenter findVirtualDatacenter(final Predicate filter); - /** - * Get the virtual datacenter with the given id. - */ - VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId); + /** + * Get the virtual datacenter with the given id. + */ + VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId); - /** - * Get the list of virtual datacenter with the given ids. - */ - Iterable getVirtualDatacenters(final List virtualDatacenterIds); + /** + * Get the list of virtual datacenter with the given ids. + */ + Iterable getVirtualDatacenters(final List virtualDatacenterIds); - /*********************** Virtual Appliance ***********************/ + /*********************** Virtual Appliance ***********************/ - /** - * Get the list of all virtual appliances. - */ - Iterable listVirtualAppliances(); + /** + * Get the list of all virtual appliances. + */ + Iterable listVirtualAppliances(); - /** - * Get the list of the virtual appliances matching the given filter. - */ - Iterable listVirtualAppliances(Predicate filter); + /** + * Get the list of the virtual appliances matching the given filter. + */ + Iterable listVirtualAppliances(Predicate filter); - /** - * Get the first virtual appliance that matches the given filter. - */ - VirtualAppliance findVirtualAppliance(Predicate filter); + /** + * Get the first virtual appliance that matches the given filter. + */ + VirtualAppliance findVirtualAppliance(Predicate filter); - /*********************** Virtual Machine ***********************/ + /*********************** Virtual Machine ***********************/ - /** - * Get the list of all virtual machines. - */ - Iterable listVirtualMachines(); + /** + * Get the list of all virtual machines. + */ + Iterable listVirtualMachines(); - /** - * Get the list of the virtual machines matching the given filter. - */ - Iterable listVirtualMachines(Predicate filter); + /** + * Get the list of the virtual machines matching the given filter. + */ + Iterable listVirtualMachines(Predicate filter); - /** - * Get the first virtual machine that matches the given filter. - */ - VirtualMachine findVirtualMachine(Predicate filter); + /** + * Get the first virtual machine that matches the given filter. + */ + VirtualMachine findVirtualMachine(Predicate filter); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java index cf25fc6130..37fdaf373c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java @@ -32,15 +32,14 @@ import com.google.inject.ImplementedBy; * @author Vivien Mahé */ @ImplementedBy(BaseEventService.class) -public interface EventService -{ - /** - * Get the list of all events. - */ - Iterable listEvents(); +public interface EventService { + /** + * Get the list of all events. + */ + Iterable listEvents(); - /** - * Get the list of all events using filters as query params. - */ - Iterable listEvents(EventOptions options); + /** + * Get the list of all events using filters as query params. + */ + Iterable listEvents(EventOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java index 1706f39fde..812134bff3 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java @@ -39,99 +39,113 @@ import com.google.inject.ImplementedBy; * @author Francesc Montserrat */ @ImplementedBy(BaseMonitoringService.class) -public interface MonitoringService -{ +public interface MonitoringService { - /*************** Generic monitoring methods ***************/ + /*************** Generic monitoring methods ***************/ - /** - * Monitor the given objects using the given complete condition. - * - * @param completeCondition The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects The objects to monitor. - */ - public void awaitCompletion(final Function completeCondition, - final T... objects); + /** + * Monitor the given objects using the given complete condition. + * + * @param completeCondition + * The function that will be used to decide if the asynchronous + * operations have finished. + * @param objects + * The objects to monitor. + */ + public void awaitCompletion(final Function completeCondition, final T... objects); - /** - * Monitor the given objects using the given complete condition. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param completeCondition The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects The objects to monitor. - */ - public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final Function completeCondition, final T... objects); + /** + * Monitor the given objects using the given complete condition. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param completeCondition + * The function that will be used to decide if the asynchronous + * operations have finished. + * @param objects + * The objects to monitor. + */ + public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, + final Function completeCondition, final T... objects); - /** - * Monitor the given objects using the given complete condition. - * - * @param completeCondition The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects The objects to monitor. - */ - public void monitor(final Function completeCondition, final T... objects); + /** + * Monitor the given objects using the given complete condition. + * + * @param completeCondition + * The function that will be used to decide if the asynchronous + * operations have finished. + * @param objects + * The objects to monitor. + */ + public void monitor(final Function completeCondition, final T... objects); - /** - * Monitor the given objects using the given complete condition. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param completeCondition The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects The objects to monitor. - */ - public void monitor(final Long maxWait, final TimeUnit timeUnit, - final Function completeCondition, final T... objects); + /** + * Monitor the given objects using the given complete condition. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param completeCondition + * The function that will be used to decide if the asynchronous + * operations have finished. + * @param objects + * The objects to monitor. + */ + public void monitor(final Long maxWait, final TimeUnit timeUnit, + final Function completeCondition, final T... objects); - /*************** Handler registration methods ***************/ + /*************** Handler registration methods ***************/ - /** - * Registers the given event handler. - * - * @param The type of event handler to register. - * @param handler The event handler to register. - */ - public > void register(T handler); + /** + * Registers the given event handler. + * + * @param + * The type of event handler to register. + * @param handler + * The event handler to register. + */ + public > void register(T handler); - /** - * Unregisters the given event handler. - * - * @param The type of event handler to unregister. - * @param handler The event handler to unregister. - */ - public > void unregister(T handler); + /** + * Unregisters the given event handler. + * + * @param + * The type of event handler to unregister. + * @param handler + * The event handler to unregister. + */ + public > void unregister(T handler); - /*************** Delegating monitors ***************/ + /*************** Delegating monitors ***************/ - /** - * Gets the virtual machine monitor service. - * - * @return The virtual machine monitor service. - */ - public VirtualMachineMonitor getVirtualMachineMonitor(); + /** + * Gets the virtual machine monitor service. + * + * @return The virtual machine monitor service. + */ + public VirtualMachineMonitor getVirtualMachineMonitor(); - /** - * Gets the virtual appliance monitor service. - * - * @return The virtual appliance monitor service. - */ - public VirtualApplianceMonitor getVirtualApplianceMonitor(); + /** + * Gets the virtual appliance monitor service. + * + * @return The virtual appliance monitor service. + */ + public VirtualApplianceMonitor getVirtualApplianceMonitor(); - /** - * Gets the asynchronous task monitor service. - * - * @return The asynchronous task monitor service. - */ - public AsyncTaskMonitor getAsyncTaskMonitor(); + /** + * Gets the asynchronous task monitor service. + * + * @return The asynchronous task monitor service. + */ + public AsyncTaskMonitor getAsyncTaskMonitor(); - /** - * Gets the conversion monitor service. - * - * @return The conversion monitor service. - */ - public ConversionMonitor getConversionMonitor(); + /** + * Gets the conversion monitor service. + * + * @return The conversion monitor service. + */ + public ConversionMonitor getConversionMonitor(); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java index 51347b198a..dd26afdb3e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/PricingService.java @@ -39,90 +39,91 @@ import com.google.inject.ImplementedBy; * @author Susana Acedo */ @ImplementedBy(BasePricingService.class) -public interface PricingService -{ +public interface PricingService { - /*********************** Currency ***********************/ + /*********************** Currency ***********************/ - /** - * Get the list of currencies. - */ - Iterable listCurrencies(); + /** + * Get the list of currencies. + */ + Iterable listCurrencies(); - /** - * Get the list of currencies matching the given filter. - */ - Iterable listCurrencies(final Predicate filter); + /** + * Get the list of currencies matching the given filter. + */ + Iterable listCurrencies(final Predicate filter); - /** - * Get the first currencies that matches the given filter or null if none is found. - */ - Currency findCurrency(final Predicate filter); + /** + * Get the first currencies that matches the given filter or + * null if none is found. + */ + Currency findCurrency(final Predicate filter); - /*********************** CostCode ***********************/ + /*********************** CostCode ***********************/ - /** - * Get the list of costcodes. - */ - Iterable listCostCodes(); + /** + * Get the list of costcodes. + */ + Iterable listCostCodes(); - /** - * Get the list of costcodes matching the given filter. - */ - Iterable listCostCodes(final Predicate filter); + /** + * Get the list of costcodes matching the given filter. + */ + Iterable listCostCodes(final Predicate filter); - /** - * Get the first costcodes that matches the given filter or null if none is found. - */ - CostCode findCostCode(final Predicate filter); + /** + * Get the first costcodes that matches the given filter or null + * if none is found. + */ + CostCode findCostCode(final Predicate filter); - /*********************** PricingTemplate ***********************/ + /*********************** PricingTemplate ***********************/ - /** - * Get the list of pricingtemplates. - */ - public Iterable listPricingTemplates(); + /** + * Get the list of pricingtemplates. + */ + public Iterable listPricingTemplates(); - /** - * Get the list of pricingtemplates matching the given filter. - */ - public Iterable listPricingTemplates(final Predicate filter); + /** + * Get the list of pricingtemplates matching the given filter. + */ + public Iterable listPricingTemplates(final Predicate filter); - /** - * Get the first pricingtemplates that matches the given filter or null if none is - * found. - */ - public PricingTemplate findPricingTemplate(final Predicate filter); + /** + * Get the first pricingtemplates that matches the given filter or + * null if none is found. + */ + public PricingTemplate findPricingTemplate(final Predicate filter); - /*********************** CostCodeCurrency ***********************/ + /*********************** CostCodeCurrency ***********************/ - /** - * Get a cost code currency - */ - public Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); + /** + * Get a cost code currency + */ + public Iterable getCostCodeCurrencies(Integer costcodeid, Integer currencyid); - /*********************** PricingCostCode ***********************/ + /*********************** PricingCostCode ***********************/ - /** - * Get pricing cost codes - */ - public Collection getPricingCostCodes(Integer pricingTemplateId); + /** + * Get pricing cost codes + */ + public Collection getPricingCostCodes(Integer pricingTemplateId); - /** - * Get a pricing cost code - */ - PricingCostCode getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId); + /** + * Get a pricing cost code + */ + PricingCostCode getPricingCostCode(Integer pricingTemplateId, Integer pricingCostCodeId); - /*********************** PricingTier ***********************/ + /*********************** PricingTier ***********************/ - /** - * Get pricing tiers - */ - Collection getPricingTiers(Integer pricingTemplateId); + /** + * Get pricing tiers + */ + Collection getPricingTiers(Integer pricingTemplateId); - /** - * Get a pricing tier - */ - PricingTier getPricingTier(Integer pricingTemplateId, Integer pricingTierId); + /** + * Get a pricing tier + */ + PricingTier getPricingTier(Integer pricingTemplateId, Integer pricingTierId); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java index 33b6df4eba..d4d1c3033f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/features/services/SearchService.java @@ -46,98 +46,108 @@ import com.google.inject.ImplementedBy; * @author Francesc Montserrat */ @ImplementedBy(BaseSearchService.class) -public interface SearchService -{ - /*********************** Enterprise ***********************/ +public interface SearchService { + /*********************** Enterprise ***********************/ - /** - * Get the list of filtered enterprises. - * - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchEnterprises(final EnterpriseOptions options); + /** + * Get the list of filtered enterprises. + * + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchEnterprises(final EnterpriseOptions options); - /** - * Get the list of filtered enterprises for a datacenter. - * - * @param datacenter The given datacenter. - * @param options The set of filtering and pagination options of the search. - * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource#DatacenterResource- - * Retrievealistofenterprisesusingdatacenter - */ - Iterable searchEnterprisesUsingDatacenter(final Datacenter datacenter, - final EnterpriseOptions options); + /** + * Get the list of filtered enterprises for a datacenter. + * + * @param datacenter + * The given datacenter. + * @param options + * The set of filtering and pagination options of the search. + * @see API: http://community.abiquo.com/display/ABI20/Datacenter+Resource# + * DatacenterResource- Retrievealistofenterprisesusingdatacenter + */ + Iterable searchEnterprisesUsingDatacenter(final Datacenter datacenter, final EnterpriseOptions options); - /*********************** Volume ***********************/ + /*********************** Volume ***********************/ - /** - * Get the list of filtered volumes for a virtual datacenter. - * - * @param virtualDatacenter The given virtual datacenter. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchVolumes(final VirtualDatacenter virtualDatacenter, - final VolumeOptions options); + /** + * Get the list of filtered volumes for a virtual datacenter. + * + * @param virtualDatacenter + * The given virtual datacenter. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchVolumes(final VirtualDatacenter virtualDatacenter, final VolumeOptions options); - /*********************** Storage Pool ***********************/ + /*********************** Storage Pool ***********************/ - /** - * Get the list of filtered storage pools for a storage device. - * - * @param device The given storage device. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchStoragePools(final StorageDevice device, - final StoragePoolOptions options); + /** + * Get the list of filtered storage pools for a storage device. + * + * @param device + * The given storage device. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchStoragePools(final StorageDevice device, final StoragePoolOptions options); - /*********************** Private IPs ***********************/ + /*********************** Private IPs ***********************/ - /** - * Get the list of filtered ips for a private network. - * - * @param network The given private network. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchPrivateIps(final PrivateNetwork network, final IpOptions options); + /** + * Get the list of filtered ips for a private network. + * + * @param network + * The given private network. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchPrivateIps(final PrivateNetwork network, final IpOptions options); - /*********************** Public IPs ***********************/ + /*********************** Public IPs ***********************/ - /** - * Get the list of filtered public ips to purchase by a virtual datacenter. - * - * @param virtualDatacenter The given virtual datacenter. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchPublicIpsToPurchase(final VirtualDatacenter virtualDatacenter, - final IpOptions options); + /** + * Get the list of filtered public ips to purchase by a virtual datacenter. + * + * @param virtualDatacenter + * The given virtual datacenter. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchPublicIpsToPurchase(final VirtualDatacenter virtualDatacenter, final IpOptions options); - /** - * Get the list of filtered purchased public ips by a virtual datacenter. - * - * @param virtualDatacenter The given virtual datacenter. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, - final IpOptions options); + /** + * Get the list of filtered purchased public ips by a virtual datacenter. + * + * @param virtualDatacenter + * The given virtual datacenter. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, final IpOptions options); - /*********************** Logic Server ***********************/ + /*********************** Logic Server ***********************/ - /** - * Get the list of service profiles for managed rack. - * - * @param managedRack The given rack. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchServiceProfiles(final ManagedRack rack, final FilterOptions options); + /** + * Get the list of service profiles for managed rack. + * + * @param managedRack + * The given rack. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchServiceProfiles(final ManagedRack rack, final FilterOptions options); - /** - * Get the list of service profile templates for managed rack. - * - * @param managedRack The given rack. - * @param options The set of filtering and pagination options of the search. - */ - Iterable searchServiceProfileTemplates(final ManagedRack rack, - final FilterOptions options); + /** + * Get the list of service profile templates for managed rack. + * + * @param managedRack + * The given rack. + * @param options + * The set of filtering and pagination options of the search. + */ + Iterable searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java index e611341f36..00e9d3f940 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java @@ -35,38 +35,31 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Singleton -public class AppendApiVersionToAbiquoMimeType implements Function -{ - /** The prefix for Abiquo custom media types. */ - private static final String ABIQUO_MIME_TYPE_PREFIX = "application/vnd.abiquo."; +public class AppendApiVersionToAbiquoMimeType implements Function { + /** The prefix for Abiquo custom media types. */ + private static final String ABIQUO_MIME_TYPE_PREFIX = "application/vnd.abiquo."; - /** The version to append to media types without version. */ - protected String apiVersion; + /** The version to append to media types without version. */ + protected String apiVersion; - @Inject - public AppendApiVersionToAbiquoMimeType(@ApiVersion final String apiVersion) - { - super(); - this.apiVersion = checkNotNull(apiVersion, "apiVersion"); - } + @Inject + public AppendApiVersionToAbiquoMimeType(@ApiVersion final String apiVersion) { + super(); + this.apiVersion = checkNotNull(apiVersion, "apiVersion"); + } - @Override - public String apply(final String input) - { - MediaType mediaType = MediaType.valueOf(checkNotNull(input, "input")); - if (isAbiquoMimeType(input) && !mediaType.getParameters().containsKey("version")) - { - return mediaType.toString() + ";version=" + apiVersion; - } - else - { - return mediaType.toString(); - } - } + @Override + public String apply(final String input) { + MediaType mediaType = MediaType.valueOf(checkNotNull(input, "input")); + if (isAbiquoMimeType(input) && !mediaType.getParameters().containsKey("version")) { + return mediaType.toString() + ";version=" + apiVersion; + } else { + return mediaType.toString(); + } + } - private static boolean isAbiquoMimeType(final String mimeType) - { - return mimeType.startsWith(ABIQUO_MIME_TYPE_PREFIX); - } + private static boolean isAbiquoMimeType(final String mimeType) { + return mimeType.startsWith(ABIQUO_MIME_TYPE_PREFIX); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java index 52a31ff8fb..2042cc2a90 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java @@ -34,12 +34,10 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Singleton -public class ParseErrors extends ParseXMLWithJAXB -{ - @Inject - public ParseErrors(final XMLParser xml, final TypeLiteral type) - { - super(xml, type); - } +public class ParseErrors extends ParseXMLWithJAXB { + @Inject + public ParseErrors(final XMLParser xml, final TypeLiteral type) { + super(xml, type); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xx.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xx.java index c755d03b9b..81d3f120b8 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xx.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xx.java @@ -35,29 +35,21 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class ReturnAbiquoExceptionOnNotFoundOr4xx implements Function -{ - @Override - public Object apply(final Exception from) - { - Throwable exception = - Iterables.find(Throwables.getCausalChain(from), isNotFoundAndHasAbiquoException(from), - null); +public class ReturnAbiquoExceptionOnNotFoundOr4xx implements Function { + @Override + public Object apply(final Exception from) { + Throwable exception = Iterables + .find(Throwables.getCausalChain(from), isNotFoundAndHasAbiquoException(from), null); - throw Throwables.propagate(exception == null ? from : (AbiquoException) exception - .getCause()); - } + throw Throwables.propagate(exception == null ? from : (AbiquoException) exception.getCause()); + } - private static Predicate isNotFoundAndHasAbiquoException(final Throwable exception) - { - return new Predicate() - { - @Override - public boolean apply(final Throwable input) - { - return input instanceof ResourceNotFoundException - && input.getCause() instanceof AbiquoException; - } - }; - } + private static Predicate isNotFoundAndHasAbiquoException(final Throwable exception) { + return new Predicate() { + @Override + public boolean apply(final Throwable input) { + return input instanceof ResourceNotFoundException && input.getCause() instanceof AbiquoException; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailable.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailable.java index b1babe8543..2753e14ca7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailable.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailable.java @@ -36,52 +36,39 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class ReturnFalseIfNotAvailable implements Function -{ - @Override - public Object apply(final Exception from) - { - Throwable exception = - Iterables.find(Throwables.getCausalChain(from), isNotAvailableException(from), null); +public class ReturnFalseIfNotAvailable implements Function { + @Override + public Object apply(final Exception from) { + Throwable exception = Iterables.find(Throwables.getCausalChain(from), isNotAvailableException(from), null); - if (exception != null) - { - if (exception instanceof HttpResponseException) - { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); + if (exception != null) { + if (exception instanceof HttpResponseException) { + HttpResponseException responseException = (HttpResponseException) exception; + HttpResponse response = responseException.getResponse(); - if (response != null && response.getStatusCode() >= 500 - && response.getStatusCode() < 600) - { - return false; - } + if (response != null && response.getStatusCode() >= 500 && response.getStatusCode() < 600) { + return false; } - else - { - // Will enter here when exception is a ResourceNotFoundException - return false; - } - } + } else { + // Will enter here when exception is a ResourceNotFoundException + return false; + } + } - throw Throwables.propagate(from); - } + throw Throwables.propagate(from); + } - private static Predicate isNotAvailableException(final Throwable exception) - { - return new Predicate() - { - @Override - public boolean apply(final Throwable input) - { - boolean notAvailable = - input instanceof HttpResponseException - && ((HttpResponseException) input).getResponse() != null; + private static Predicate isNotAvailableException(final Throwable exception) { + return new Predicate() { + @Override + public boolean apply(final Throwable input) { + boolean notAvailable = input instanceof HttpResponseException + && ((HttpResponseException) input).getResponse() != null; - notAvailable |= input instanceof ResourceNotFoundException; + notAvailable |= input instanceof ResourceNotFoundException; - return notAvailable; - } - }; - } + return notAvailable; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseOn5xx.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseOn5xx.java index 150b8c45bd..73bf340903 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseOn5xx.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnFalseOn5xx.java @@ -35,39 +35,29 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class ReturnFalseOn5xx implements Function -{ - @Override - public Object apply(final Exception from) - { - Throwable exception = - Iterables.find(Throwables.getCausalChain(from), hasResponse(from), null); +public class ReturnFalseOn5xx implements Function { + @Override + public Object apply(final Exception from) { + Throwable exception = Iterables.find(Throwables.getCausalChain(from), hasResponse(from), null); - if (exception != null) - { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); + if (exception != null) { + HttpResponseException responseException = (HttpResponseException) exception; + HttpResponse response = responseException.getResponse(); - if (response != null && response.getStatusCode() >= 500 - && response.getStatusCode() < 600) - { - return false; - } - } + if (response != null && response.getStatusCode() >= 500 && response.getStatusCode() < 600) { + return false; + } + } - throw Throwables.propagate(from); - } + throw Throwables.propagate(from); + } - private static Predicate hasResponse(final Throwable exception) - { - return new Predicate() - { - @Override - public boolean apply(final Throwable input) - { - return input instanceof HttpResponseException - && ((HttpResponseException) input).getResponse() != null; - } - }; - } + private static Predicate hasResponse(final Throwable exception) { + return new Predicate() { + @Override + public boolean apply(final Throwable input) { + return input instanceof HttpResponseException && ((HttpResponseException) input).getResponse() != null; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnMovedResource.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnMovedResource.java index ec2bc2421b..f22a84c60f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnMovedResource.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnMovedResource.java @@ -34,44 +34,35 @@ import com.google.common.collect.Iterables; * * @author Ignasi Barrera */ -public abstract class ReturnMovedResource implements Function -{ +public abstract class ReturnMovedResource implements Function { - @Override - public T apply(final Exception from) - { - Throwable exception = - Iterables.find(Throwables.getCausalChain(from), isMovedException(from), null); + @Override + public T apply(final Exception from) { + Throwable exception = Iterables.find(Throwables.getCausalChain(from), isMovedException(from), null); - if (exception != null) - { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); + if (exception != null) { + HttpResponseException responseException = (HttpResponseException) exception; + HttpResponse response = responseException.getResponse(); - return getMovedEntity(response); - } + return getMovedEntity(response); + } - throw Throwables.propagate(from); - } + throw Throwables.propagate(from); + } - protected abstract T getMovedEntity(HttpResponse response); + protected abstract T getMovedEntity(HttpResponse response); - private static Predicate isMovedException(final Throwable exception) - { - return new Predicate() - { - @Override - public boolean apply(final Throwable input) - { - if (input instanceof HttpResponseException) - { - HttpResponse response = ((HttpResponseException) input).getResponse(); - return response != null - && response.getStatusCode() == Status.MOVED_PERMANENTLY.getStatusCode(); - } - - return false; + private static Predicate isMovedException(final Throwable exception) { + return new Predicate() { + @Override + public boolean apply(final Throwable input) { + if (input instanceof HttpResponseException) { + HttpResponse response = ((HttpResponseException) input).getResponse(); + return response != null && response.getStatusCode() == Status.MOVED_PERMANENTLY.getStatusCode(); } - }; - } + + return false; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnNullOn303.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnNullOn303.java index 630d6f3067..6a3dd6167e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnNullOn303.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnNullOn303.java @@ -36,38 +36,29 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Singleton -public class ReturnNullOn303 implements Function -{ - @Override - public Object apply(final Exception from) - { - Throwable exception = - Iterables.find(Throwables.getCausalChain(from), hasResponse(from), null); +public class ReturnNullOn303 implements Function { + @Override + public Object apply(final Exception from) { + Throwable exception = Iterables.find(Throwables.getCausalChain(from), hasResponse(from), null); - if (exception != null) - { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); + if (exception != null) { + HttpResponseException responseException = (HttpResponseException) exception; + HttpResponse response = responseException.getResponse(); - if (response != null && response.getStatusCode() == Status.SEE_OTHER.getStatusCode()) - { - return null; - } - } + if (response != null && response.getStatusCode() == Status.SEE_OTHER.getStatusCode()) { + return null; + } + } - throw Throwables.propagate(from); - } + throw Throwables.propagate(from); + } - private static Predicate hasResponse(final Throwable exception) - { - return new Predicate() - { - @Override - public boolean apply(final Throwable input) - { - return input instanceof HttpResponseException - && ((HttpResponseException) input).getResponse() != null; - } - }; - } + private static Predicate hasResponse(final Throwable exception) { + return new Predicate() { + @Override + public boolean apply(final Throwable input) { + return input instanceof HttpResponseException && ((HttpResponseException) input).getResponse() != null; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java index ee5c8bf5b1..d5d9691e91 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java @@ -33,40 +33,33 @@ import com.abiquo.model.transport.AcceptedRequestDto; import com.google.inject.TypeLiteral; /** - * Return an {@link AcceptedRequestDto} representing the asynchronous task or null if - * the operation completed synchronously. + * Return an {@link AcceptedRequestDto} representing the asynchronous task or + * null if the operation completed synchronously. *

* Operations that generate asynchronous tasks will return one of the following: *

    *
  • 204 if the operation completed synchronously
  • - *
  • 202 with the asynchronous task reference in the body if the operation has been submitted and - * will be executed asynchronously
  • + *
  • 202 with the asynchronous task reference in the body if the operation has + * been submitted and will be executed asynchronously
  • *
* * @author Ignasi Barrera */ @Singleton -public class ReturnTaskReferenceOrNull extends ParseXMLWithJAXB> -{ - @Inject - public ReturnTaskReferenceOrNull(final XMLParser xml, - final TypeLiteral> type) - { - super(xml, type); - } +public class ReturnTaskReferenceOrNull extends ParseXMLWithJAXB> { + @Inject + public ReturnTaskReferenceOrNull(final XMLParser xml, final TypeLiteral> type) { + super(xml, type); + } - @Override - public AcceptedRequestDto apply(final HttpResponse from) - { - if (from.getStatusCode() == Status.NO_CONTENT.getStatusCode()) - { - releasePayload(from); - return null; - } - else - { - return super.apply(from); - } - } + @Override + public AcceptedRequestDto apply(final HttpResponse from) { + if (from.getStatusCode() == Status.NO_CONTENT.getStatusCode()) { + releasePayload(from); + return null; + } else { + return super.apply(from); + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMoveVolumeReference.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMoveVolumeReference.java index 41fb84b958..77fd42d19c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMoveVolumeReference.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMoveVolumeReference.java @@ -29,17 +29,16 @@ import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto; import com.google.inject.TypeLiteral; /** - * Return an {@link MovedVolumeDto} representing the reference to a moved resource. + * Return an {@link MovedVolumeDto} representing the reference to a moved + * resource. * * @author Ignasi Barrera */ @Singleton -public class ReturnMoveVolumeReference extends ParseXMLWithJAXB -{ - @Inject - public ReturnMoveVolumeReference(final XMLParser xml, final TypeLiteral type) - { - super(xml, type); - } +public class ReturnMoveVolumeReference extends ParseXMLWithJAXB { + @Inject + public ReturnMoveVolumeReference(final XMLParser xml, final TypeLiteral type) { + super(xml, type); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolume.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolume.java index 78ed3f1e07..88befbfd27 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolume.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolume.java @@ -33,20 +33,17 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * @author Ignasi Barrera */ @Singleton -public class ReturnMovedVolume extends ReturnMovedResource -{ - private ReturnMoveVolumeReference parser; +public class ReturnMovedVolume extends ReturnMovedResource { + private ReturnMoveVolumeReference parser; - @Inject - public ReturnMovedVolume(final ReturnMoveVolumeReference parser) - { - super(); - this.parser = parser; - } + @Inject + public ReturnMovedVolume(final ReturnMoveVolumeReference parser) { + super(); + this.parser = parser; + } - @Override - protected VolumeManagementDto getMovedEntity(final HttpResponse response) - { - return parser.apply(response).getVolume(); - } + @Override + protected VolumeManagementDto getMovedEntity(final HttpResponse response) { + return parser.apply(response).getVolume(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java index ca00e58b36..d8e8728539 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseId.java @@ -33,15 +33,13 @@ import com.google.common.base.Function; * @author Francesc Montserrat */ @Singleton -public class ParseEnterpriseId implements Function -{ - @Override - public String apply(final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof EnterpriseDto, +public class ParseEnterpriseId implements Function { + @Override + public String apply(final Object input) { + checkArgument(checkNotNull(input, "input") instanceof EnterpriseDto, "This parser is only valid for EnterpriseDto objects"); - return ((EnterpriseDto) input).getId().toString(); - } + return ((EnterpriseDto) input).getId().toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java index 423575565c..cadee5c762 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterId.java @@ -33,15 +33,13 @@ import com.google.common.base.Function; * @author Francesc Montserrat */ @Singleton -public class ParseDatacenterId implements Function -{ - @Override - public String apply(final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof DatacenterDto, +public class ParseDatacenterId implements Function { + @Override + public String apply(final Object input) { + checkArgument(checkNotNull(input, "input") instanceof DatacenterDto, "This parser is only valid for DatacenterDto objects"); - return ((DatacenterDto) input).getId().toString(); - } + return ((DatacenterDto) input).getId().toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java index 54d1ef693e..25e9b3b4ca 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineId.java @@ -33,15 +33,13 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Singleton -public class ParseMachineId implements Function -{ - @Override - public String apply(final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof MachineDto, +public class ParseMachineId implements Function { + @Override + public String apply(final Object input) { + checkArgument(checkNotNull(input, "input") instanceof MachineDto, "This parser is only valid for MachineDto objects"); - return ((MachineDto) input).getId().toString(); - } + return ((MachineDto) input).getId().toString(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java index c30891c3c9..bac565a5fd 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceType.java @@ -28,21 +28,19 @@ import com.abiquo.model.enumerator.RemoteServiceType; import com.google.common.base.Function; /** - * Parses a {@link ParseRemoteServiceType} object to extract its type in the format that the API - * expects it. + * Parses a {@link ParseRemoteServiceType} object to extract its type in the + * format that the API expects it. * * @author Francesc Montserrat */ @Singleton -public class ParseRemoteServiceType implements Function -{ - @Override - public String apply(final Object input) - { - checkArgument(checkNotNull(input, "input") instanceof RemoteServiceType, +public class ParseRemoteServiceType implements Function { + @Override + public String apply(final Object input) { + checkArgument(checkNotNull(input, "input") instanceof RemoteServiceType, "This parser is only valid for RemoteServiceType objects"); - return ((RemoteServiceType) input).name().replaceAll("_", "").toLowerCase(); - } + return ((RemoteServiceType) input).name().replaceAll("_", "").toLowerCase(); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java index 22aa74676f..3d68d61b0c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/handlers/AbiquoErrorHandler.java @@ -42,96 +42,81 @@ import com.google.common.io.Closeables; * @author Ignasi Barrera */ @Singleton -public class AbiquoErrorHandler implements HttpErrorHandler -{ - /** The error parser. */ - private ParseErrors errorParser; +public class AbiquoErrorHandler implements HttpErrorHandler { + /** The error parser. */ + private ParseErrors errorParser; - @Inject - AbiquoErrorHandler(final ParseErrors errorParser) - { - super(); - this.errorParser = errorParser; - } + @Inject + AbiquoErrorHandler(final ParseErrors errorParser) { + super(); + this.errorParser = errorParser; + } - @Override - public void handleError(final HttpCommand command, final HttpResponse response) - { - Exception exception = null; - String defaultMessage = - String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); + @Override + public void handleError(final HttpCommand command, final HttpResponse response) { + Exception exception = null; + String defaultMessage = String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), + response.getStatusLine()); - try - { - switch (response.getStatusCode()) - { - case 401: - case 403: - // Autorization exceptions do not return an errors DTO, so we encapsulate a - // generic exception - exception = - new AuthorizationException(defaultMessage, - new HttpResponseException(command, response, defaultMessage)); - break; - case 404: - exception = - new ResourceNotFoundException(defaultMessage, getExceptionToPropagate( - command, response, defaultMessage)); - break; - case 301: - // Moved resources in Abiquo should be handled with the ReturnMovedResource - // exception parser to return the moved entity. - exception = new HttpResponseException(command, response, defaultMessage); - break; - default: - exception = getExceptionToPropagate(command, response, defaultMessage); - break; - } - } - finally - { - if (response.getPayload() != null) - { - Closeables.closeQuietly(response.getPayload().getInput()); - } - command.setException(exception); - } - } + try { + switch (response.getStatusCode()) { + case 401: + case 403: + // Autorization exceptions do not return an errors DTO, so we + // encapsulate a + // generic exception + exception = new AuthorizationException(defaultMessage, new HttpResponseException(command, response, + defaultMessage)); + break; + case 404: + exception = new ResourceNotFoundException(defaultMessage, getExceptionToPropagate(command, response, + defaultMessage)); + break; + case 301: + // Moved resources in Abiquo should be handled with the + // ReturnMovedResource + // exception parser to return the moved entity. + exception = new HttpResponseException(command, response, defaultMessage); + break; + default: + exception = getExceptionToPropagate(command, response, defaultMessage); + break; + } + } finally { + if (response.getPayload() != null) { + Closeables.closeQuietly(response.getPayload().getInput()); + } + command.setException(exception); + } + } - private Exception getExceptionToPropagate(final HttpCommand command, - final HttpResponse response, final String defaultMessage) - { - Exception exception = null; + private Exception getExceptionToPropagate(final HttpCommand command, final HttpResponse response, + final String defaultMessage) { + Exception exception = null; - if (hasPayload(response)) - { - try - { - ErrorsDto errors = errorParser.apply(response); - exception = new AbiquoException(fromStatusCode(response.getStatusCode()), errors); - } - catch (Exception ex) - { - // If it is not an Abiquo Exception (can not be unmarshalled), propagate a standard - // HttpResponseException - exception = new HttpResponseException(command, response, defaultMessage); - } - } - else - { - // If it is not an Abiquo Exception (there is not an errors xml in the payload) - // propagate a standard HttpResponseException + if (hasPayload(response)) { + try { + ErrorsDto errors = errorParser.apply(response); + exception = new AbiquoException(fromStatusCode(response.getStatusCode()), errors); + } catch (Exception ex) { + // If it is not an Abiquo Exception (can not be unmarshalled), + // propagate a standard + // HttpResponseException exception = new HttpResponseException(command, response, defaultMessage); - } + } + } else { + // If it is not an Abiquo Exception (there is not an errors xml in the + // payload) + // propagate a standard HttpResponseException + exception = new HttpResponseException(command, response, defaultMessage); + } - return exception; - } + return exception; + } - private static boolean hasPayload(final HttpResponse response) - { - return response.getPayload() != null && response.getPayload().getContentMetadata() != null + private static boolean hasPayload(final HttpResponse response) { + return response.getPayload() != null && response.getPayload().getContentMetadata() != null && response.getPayload().getContentMetadata().getContentLength() != null && response.getPayload().getContentMetadata().getContentLength() > 0L; - } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java index e48ba2d5ef..f126249426 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AbiquoAuthentication.java @@ -38,53 +38,46 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; /** - * Authenticates using Basic Authentication or a generated token from previous API sessions. + * Authenticates using Basic Authentication or a generated token from previous + * API sessions. * * @author Ignasi Barrera */ @Singleton -public class AbiquoAuthentication implements HttpRequestFilter -{ - /** The name of the authentication token. */ - public static final String AUTH_TOKEN_NAME = "auth"; +public class AbiquoAuthentication implements HttpRequestFilter { + /** The name of the authentication token. */ + public static final String AUTH_TOKEN_NAME = "auth"; - protected String identity; + protected String identity; - protected String credential; + protected String credential; - protected boolean credentialIsToken; + protected boolean credentialIsToken; - @Inject - public AbiquoAuthentication(@Identity final String identity, - @Credential final String credential, - @Named(CREDENTIAL_IS_TOKEN) final String credentialIsToken) - { - this.identity = checkNotNull(identity, "identity"); - this.credential = checkNotNull(credential, "credential"); - this.credentialIsToken = Boolean.valueOf(credentialIsToken); - } + @Inject + public AbiquoAuthentication(@Identity final String identity, @Credential final String credential, + @Named(CREDENTIAL_IS_TOKEN) final String credentialIsToken) { + this.identity = checkNotNull(identity, "identity"); + this.credential = checkNotNull(credential, "credential"); + this.credentialIsToken = Boolean.valueOf(credentialIsToken); + } - @Override - public HttpRequest filter(final HttpRequest request) throws HttpException - { - String header = credentialIsToken ? tokenAuth(credential) : basicAuth(identity, credential); - return request - .toBuilder() - .replaceHeader(credentialIsToken ? HttpHeaders.COOKIE : HttpHeaders.AUTHORIZATION, - header).build(); - } + @Override + public HttpRequest filter(final HttpRequest request) throws HttpException { + String header = credentialIsToken ? tokenAuth(credential) : basicAuth(identity, credential); + return request.toBuilder() + .replaceHeader(credentialIsToken ? HttpHeaders.COOKIE : HttpHeaders.AUTHORIZATION, header).build(); + } - @VisibleForTesting - static String basicAuth(final String user, final String password) - { - return "Basic " + @VisibleForTesting + static String basicAuth(final String user, final String password) { + return "Basic " + CryptoStreams.base64(String.format("%s:%s", checkNotNull(user, "user"), - checkNotNull(password, "password")).getBytes(Charsets.UTF_8)); - } + checkNotNull(password, "password")).getBytes(Charsets.UTF_8)); + } - @VisibleForTesting - static String tokenAuth(final String token) - { - return AUTH_TOKEN_NAME + "=" + checkNotNull(token, "token"); - } + @VisibleForTesting + static String tokenAuth(final String token) { + return AUTH_TOKEN_NAME + "=" + checkNotNull(token, "token"); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java index 6a6ba06c59..a671315042 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaType.java @@ -34,52 +34,45 @@ import com.google.common.collect.Iterables; import com.google.common.net.HttpHeaders; /** - * Appends the api version to the Abiquo mime types to ensure the input and output of api calls will - * be in the desired format. + * Appends the api version to the Abiquo mime types to ensure the input and + * output of api calls will be in the desired format. * * @author Ignasi Barrera */ @Singleton -public class AppendApiVersionToMediaType implements HttpRequestFilter -{ - /** The function used to append the version to media types. */ - private AppendApiVersionToAbiquoMimeType versionAppender; +public class AppendApiVersionToMediaType implements HttpRequestFilter { + /** The function used to append the version to media types. */ + private AppendApiVersionToAbiquoMimeType versionAppender; - @Inject - public AppendApiVersionToMediaType(final AppendApiVersionToAbiquoMimeType versionAppender) - { - super(); - this.versionAppender = versionAppender; - } + @Inject + public AppendApiVersionToMediaType(final AppendApiVersionToAbiquoMimeType versionAppender) { + super(); + this.versionAppender = versionAppender; + } - @Override - public HttpRequest filter(final HttpRequest request) throws HttpException - { - HttpRequest requestWithVersionInMediaTypes = appendVersionToNonPayloadHeaders(request); - return appendVersionToPayloadHeaders(requestWithVersionInMediaTypes); - } + @Override + public HttpRequest filter(final HttpRequest request) throws HttpException { + HttpRequest requestWithVersionInMediaTypes = appendVersionToNonPayloadHeaders(request); + return appendVersionToPayloadHeaders(requestWithVersionInMediaTypes); + } - @VisibleForTesting - HttpRequest appendVersionToNonPayloadHeaders(final HttpRequest request) - { - Collection accept = request.getHeaders().get(HttpHeaders.ACCEPT); - return accept.isEmpty() ? request : request + @VisibleForTesting + HttpRequest appendVersionToNonPayloadHeaders(final HttpRequest request) { + Collection accept = request.getHeaders().get(HttpHeaders.ACCEPT); + return accept.isEmpty() ? request : request .toBuilder() .replaceHeader(HttpHeaders.ACCEPT, - Iterables.toArray(Iterables.transform(accept, versionAppender), String.class)) - .build(); - } + Iterables.toArray(Iterables.transform(accept, versionAppender), String.class)).build(); + } - @VisibleForTesting - HttpRequest appendVersionToPayloadHeaders(final HttpRequest request) - { - if (request.getPayload() != null) - { - String contentTypeWithVersion = - versionAppender.apply(request.getPayload().getContentMetadata().getContentType()); - request.getPayload().getContentMetadata().setContentType(contentTypeWithVersion); - } + @VisibleForTesting + HttpRequest appendVersionToPayloadHeaders(final HttpRequest request) { + if (request.getPayload() != null) { + String contentTypeWithVersion = versionAppender.apply(request.getPayload().getContentMetadata() + .getContentType()); + request.getPayload().getContentMetadata().setContentType(contentTypeWithVersion); + } - return request; - } + return request; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java index 837bb84b3b..d04b2e33a0 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/AbiquoContextImpl.java @@ -44,82 +44,73 @@ import org.jclouds.rest.internal.RestContextImpl; import com.google.common.reflect.TypeToken; /** - * Abiquo {@link RestContextImpl} implementation to expose high level Abiquo functionalities. + * Abiquo {@link RestContextImpl} implementation to expose high level Abiquo + * functionalities. * * @author Ignasi Barrera */ @Singleton -public class AbiquoContextImpl extends ComputeServiceContextImpl implements AbiquoContext -{ - private final AdministrationService administrationService; +public class AbiquoContextImpl extends ComputeServiceContextImpl implements AbiquoContext { + private final AdministrationService administrationService; - private final CloudService cloudService; + private final CloudService cloudService; - private final SearchService searchService; + private final SearchService searchService; - private final MonitoringService monitoringService; + private final MonitoringService monitoringService; - private final EventService eventService; + private final EventService eventService; - private final PricingService pricingService; + private final PricingService pricingService; - @Inject - public AbiquoContextImpl(@Provider final Context wrapped, - @Provider final TypeToken< ? extends Context> wrappedType, - final ComputeService computeService, final Utils utils, - final RestContext providerSpecificContext, - final AdministrationService administrationService, final CloudService cloudService, - final SearchService searchService, final MonitoringService monitoringService, - final EventService eventService, final PricingService pricingService) - { - super(wrapped, wrappedType, computeService, utils); - this.administrationService = checkNotNull(administrationService, "administrationService"); - this.cloudService = checkNotNull(cloudService, "cloudService"); - this.searchService = checkNotNull(searchService, "searchService"); - this.monitoringService = checkNotNull(monitoringService, "monitoringService"); - this.eventService = checkNotNull(eventService, "eventService"); - this.pricingService = checkNotNull(pricingService, "pricingService"); - } + @Inject + public AbiquoContextImpl(@Provider final Context wrapped, @Provider final TypeToken wrappedType, + final ComputeService computeService, final Utils utils, + final RestContext providerSpecificContext, + final AdministrationService administrationService, final CloudService cloudService, + final SearchService searchService, final MonitoringService monitoringService, final EventService eventService, + final PricingService pricingService) { + super(wrapped, wrappedType, computeService, utils); + this.administrationService = checkNotNull(administrationService, "administrationService"); + this.cloudService = checkNotNull(cloudService, "cloudService"); + this.searchService = checkNotNull(searchService, "searchService"); + this.monitoringService = checkNotNull(monitoringService, "monitoringService"); + this.eventService = checkNotNull(eventService, "eventService"); + this.pricingService = checkNotNull(pricingService, "pricingService"); + } - @Override - public RestContext getApiContext() - { - return unwrap(); - } + @Override + public RestContext getApiContext() { + return unwrap(); + } - @Override - public AdministrationService getAdministrationService() - { - return administrationService; - } + @Override + public AdministrationService getAdministrationService() { + return administrationService; + } - @Override - public CloudService getCloudService() - { - return cloudService; - } + @Override + public CloudService getCloudService() { + return cloudService; + } - @Override - public SearchService getSearchService() - { - return searchService; - } + @Override + public SearchService getSearchService() { + return searchService; + } - @Override - public MonitoringService getMonitoringService() - { - return monitoringService; - } + @Override + public MonitoringService getMonitoringService() { + return monitoringService; + } - @Override - public EventService getEventService() - { - return eventService; - } + @Override + public EventService getEventService() { + return eventService; + } - @Override - public PricingService getPricingService() - { - return pricingService; - } + @Override + public PricingService getPricingService() { + return pricingService; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java index 144efa4e81..25aacb8f2a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseAdministrationService.java @@ -70,295 +70,254 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Singleton -public class BaseAdministrationService implements AdministrationService -{ - @VisibleForTesting - protected RestContext context; +public class BaseAdministrationService implements AdministrationService { + @VisibleForTesting + protected RestContext context; - @VisibleForTesting - protected final ListDatacenters listDatacenters; + @VisibleForTesting + protected final ListDatacenters listDatacenters; - @VisibleForTesting - protected final ListMachines listMachines; + @VisibleForTesting + protected final ListMachines listMachines; - @VisibleForTesting - protected final ListEnterprises listEnterprises; + @VisibleForTesting + protected final ListEnterprises listEnterprises; - @VisibleForTesting - protected final ListRoles listRoles; + @VisibleForTesting + protected final ListRoles listRoles; - @VisibleForTesting - protected final ListLicenses listLicenses; + @VisibleForTesting + protected final ListLicenses listLicenses; - @VisibleForTesting - protected final ListPrivileges listPrivileges; + @VisibleForTesting + protected final ListPrivileges listPrivileges; - @VisibleForTesting - protected final ListProperties listProperties; + @VisibleForTesting + protected final ListProperties listProperties; - @VisibleForTesting - protected final ListCategories listCategories; + @VisibleForTesting + protected final ListCategories listCategories; - @VisibleForTesting - protected final Supplier currentUser; + @VisibleForTesting + protected final Supplier currentUser; - @VisibleForTesting - protected final Supplier currentEnterprise; + @VisibleForTesting + protected final Supplier currentEnterprise; - @Inject - protected BaseAdministrationService(final RestContext context, - final ListDatacenters listDatacenters, final ListMachines listMachines, - final ListEnterprises listEnterprises, final ListRoles listRoles, - final ListLicenses listLicenses, final ListPrivileges listPrivileges, - final ListProperties listProperties, final ListCategories listCategories, - @Memoized final Supplier currentUser, - @Memoized final Supplier currentEnterprise) - { - this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); - this.listMachines = checkNotNull(listMachines, "listMachines"); - this.listEnterprises = checkNotNull(listEnterprises, "listEnterprises"); - this.listRoles = checkNotNull(listRoles, "listRoles"); - this.listLicenses = checkNotNull(listLicenses, "listLicenses"); - this.listPrivileges = checkNotNull(listPrivileges, "listPrivileges"); - this.listProperties = checkNotNull(listProperties, "listProperties"); - this.listCategories = checkNotNull(listCategories, "listCategories"); - this.currentUser = checkNotNull(currentUser, "currentUser"); - this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise"); - } + @Inject + protected BaseAdministrationService(final RestContext context, + final ListDatacenters listDatacenters, final ListMachines listMachines, final ListEnterprises listEnterprises, + final ListRoles listRoles, final ListLicenses listLicenses, final ListPrivileges listPrivileges, + final ListProperties listProperties, final ListCategories listCategories, + @Memoized final Supplier currentUser, @Memoized final Supplier currentEnterprise) { + this.context = checkNotNull(context, "context"); + this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); + this.listMachines = checkNotNull(listMachines, "listMachines"); + this.listEnterprises = checkNotNull(listEnterprises, "listEnterprises"); + this.listRoles = checkNotNull(listRoles, "listRoles"); + this.listLicenses = checkNotNull(listLicenses, "listLicenses"); + this.listPrivileges = checkNotNull(listPrivileges, "listPrivileges"); + this.listProperties = checkNotNull(listProperties, "listProperties"); + this.listCategories = checkNotNull(listCategories, "listCategories"); + this.currentUser = checkNotNull(currentUser, "currentUser"); + this.currentEnterprise = checkNotNull(currentEnterprise, "currentEnterprise"); + } - /*********************** Datacenter ********************** */ + /*********************** Datacenter ********************** */ - @Override - public Iterable listDatacenters() - { - return listDatacenters.execute(); - } + @Override + public Iterable listDatacenters() { + return listDatacenters.execute(); + } - @Override - public Iterable listDatacenters(final Predicate filter) - { - return listDatacenters.execute(filter); - } + @Override + public Iterable listDatacenters(final Predicate filter) { + return listDatacenters.execute(filter); + } - @Override - public Datacenter getDatacenter(final Integer datacenterId) - { - DatacenterDto datacenter = - context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - return wrap(context, Datacenter.class, datacenter); - } + @Override + public Datacenter getDatacenter(final Integer datacenterId) { + DatacenterDto datacenter = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); + return wrap(context, Datacenter.class, datacenter); + } - @Override - public Datacenter findDatacenter(final Predicate filter) - { - return Iterables.getFirst(listDatacenters(filter), null); - } + @Override + public Datacenter findDatacenter(final Predicate filter) { + return Iterables.getFirst(listDatacenters(filter), null); + } - @Override - public Iterable getDatacenters(final List datacenterIds) - { - return listDatacenters.execute(datacenterIds); - } + @Override + public Iterable getDatacenters(final List datacenterIds) { + return listDatacenters.execute(datacenterIds); + } - /*********************** Machine ***********************/ + /*********************** Machine ***********************/ - @Override - public Iterable listMachines() - { - return listMachines.execute(); - } + @Override + public Iterable listMachines() { + return listMachines.execute(); + } - @Override - public Iterable listMachines(final Predicate filter) - { - return listMachines.execute(filter); - } + @Override + public Iterable listMachines(final Predicate filter) { + return listMachines.execute(filter); + } - @Override - public Machine findMachine(final Predicate filter) - { - return Iterables.getFirst(listMachines(filter), null); - } + @Override + public Machine findMachine(final Predicate filter) { + return Iterables.getFirst(listMachines(filter), null); + } - /*********************** Enterprise ***********************/ + /*********************** Enterprise ***********************/ - @Override - public Iterable listEnterprises() - { - return listEnterprises.execute(); - } + @Override + public Iterable listEnterprises() { + return listEnterprises.execute(); + } - @Override - public Iterable listEnterprises(final Predicate filter) - { - return listEnterprises.execute(filter); - } + @Override + public Iterable listEnterprises(final Predicate filter) { + return listEnterprises.execute(filter); + } - @Override - public Enterprise findEnterprise(final Predicate filter) - { - return Iterables.getFirst(listEnterprises(filter), null); - } + @Override + public Enterprise findEnterprise(final Predicate filter) { + return Iterables.getFirst(listEnterprises(filter), null); + } - @Override - public Enterprise getEnterprise(final Integer enterpriseId) - { - EnterpriseDto enterprise = - context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); - return wrap(context, Enterprise.class, enterprise); - } + @Override + public Enterprise getEnterprise(final Integer enterpriseId) { + EnterpriseDto enterprise = context.getApi().getEnterpriseApi().getEnterprise(enterpriseId); + return wrap(context, Enterprise.class, enterprise); + } - /*********************** Enterprise Properties ***********************/ + /*********************** Enterprise Properties ***********************/ - @Override - public EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise) - { - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Enterprise.class); + @Override + public EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise) { + checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - EnterprisePropertiesDto properties = - context.getApi().getEnterpriseApi().getEnterpriseProperties(enterprise.unwrap()); - return wrap(context, EnterpriseProperties.class, properties); - } + EnterprisePropertiesDto properties = context.getApi().getEnterpriseApi() + .getEnterpriseProperties(enterprise.unwrap()); + return wrap(context, EnterpriseProperties.class, properties); + } - /*********************** Role ********************** */ + /*********************** Role ********************** */ - @Override - public Iterable listRoles() - { - return listRoles.execute(); - } + @Override + public Iterable listRoles() { + return listRoles.execute(); + } - @Override - public Iterable listRoles(final Predicate filter) - { - return listRoles.execute(filter); - } + @Override + public Iterable listRoles(final Predicate filter) { + return listRoles.execute(filter); + } - @Override - public Role findRole(final Predicate filter) - { - return Iterables.getFirst(listRoles(filter), null); - } + @Override + public Role findRole(final Predicate filter) { + return Iterables.getFirst(listRoles(filter), null); + } - @Override - public Role getRole(final Integer roleId) - { - RoleDto role = context.getApi().getAdminApi().getRole(roleId); - return wrap(context, Role.class, role); - } + @Override + public Role getRole(final Integer roleId) { + RoleDto role = context.getApi().getAdminApi().getRole(roleId); + return wrap(context, Role.class, role); + } - /*********************** Privilege ***********************/ + /*********************** Privilege ***********************/ - @Override - public Privilege findPrivilege(final Predicate filter) - { - return Iterables.getFirst(listPrivileges(filter), null); - } + @Override + public Privilege findPrivilege(final Predicate filter) { + return Iterables.getFirst(listPrivileges(filter), null); + } - @Override - public Iterable listPrivileges() - { - return listPrivileges.execute(); - } + @Override + public Iterable listPrivileges() { + return listPrivileges.execute(); + } - @Override - public Iterable listPrivileges(final Predicate filter) - { - return listPrivileges.execute(filter); - } + @Override + public Iterable listPrivileges(final Predicate filter) { + return listPrivileges.execute(filter); + } - /*********************** User ***********************/ + /*********************** User ***********************/ - @Override - public User getCurrentUser() - { - return currentUser.get(); - } + @Override + public User getCurrentUser() { + return currentUser.get(); + } - @Override - public Enterprise getCurrentEnterprise() - { - return currentEnterprise.get(); - } + @Override + public Enterprise getCurrentEnterprise() { + return currentEnterprise.get(); + } - /*********************** License ***********************/ + /*********************** License ***********************/ - @Override - public Iterable listLicenses() - { - return listLicenses.execute(); - } + @Override + public Iterable listLicenses() { + return listLicenses.execute(); + } - @Override - public Iterable listLicenses(final boolean active) - { - LicenseOptions options = LicenseOptions.builder().active(active).build(); - return listLicenses.execute(options); - } + @Override + public Iterable listLicenses(final boolean active) { + LicenseOptions options = LicenseOptions.builder().active(active).build(); + return listLicenses.execute(options); + } - @Override - public Iterable listLicenses(final Predicate filter) - { - return listLicenses.execute(filter); - } + @Override + public Iterable listLicenses(final Predicate filter) { + return listLicenses.execute(filter); + } - @Override - public License findLicense(final Predicate filter) - { - return Iterables.getFirst(listLicenses(filter), null); - } + @Override + public License findLicense(final Predicate filter) { + return Iterables.getFirst(listLicenses(filter), null); + } - /*********************** System Properties ***********************/ + /*********************** System Properties ***********************/ - @Override - public Iterable listSystemProperties() - { - return listProperties.execute(); - } + @Override + public Iterable listSystemProperties() { + return listProperties.execute(); + } - @Override - public Iterable listSystemProperties(final Predicate filter) - { - return listProperties.execute(filter); - } + @Override + public Iterable listSystemProperties(final Predicate filter) { + return listProperties.execute(filter); + } - @Override - public SystemProperty findSystemProperty(final Predicate filter) - { - return Iterables.getFirst(listSystemProperties(filter), null); - } + @Override + public SystemProperty findSystemProperty(final Predicate filter) { + return Iterables.getFirst(listSystemProperties(filter), null); + } - @Override - public SystemProperty getSystemProperty(final String name) - { - PropertyOptions options = PropertyOptions.builder().name(name).build(); - return Iterables.getFirst(listProperties.execute(options), null); - } + @Override + public SystemProperty getSystemProperty(final String name) { + PropertyOptions options = PropertyOptions.builder().name(name).build(); + return Iterables.getFirst(listProperties.execute(options), null); + } - @Override - public Iterable listSystemProperties(final String component) - { - PropertyOptions options = PropertyOptions.builder().component(component).build(); - return listProperties.execute(options); - } + @Override + public Iterable listSystemProperties(final String component) { + PropertyOptions options = PropertyOptions.builder().component(component).build(); + return listProperties.execute(options); + } - @Override - public Category findCategory(final Predicate filter) - { - return Iterables.getFirst(listCategories(filter), null); - } + @Override + public Category findCategory(final Predicate filter) { + return Iterables.getFirst(listCategories(filter), null); + } - @Override - public Iterable listCategories() - { - return listCategories.execute(); - } + @Override + public Iterable listCategories() { + return listCategories.execute(); + } - @Override - public Iterable listCategories(final Predicate filter) - { - return listCategories.execute(filter); - } + @Override + public Iterable listCategories(final Predicate filter) { + return listCategories.execute(filter); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java index b3ba3136b9..16d99cba16 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseCloudService.java @@ -53,119 +53,98 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Singleton -public class BaseCloudService implements CloudService -{ - @VisibleForTesting - protected RestContext context; +public class BaseCloudService implements CloudService { + @VisibleForTesting + protected RestContext context; - @VisibleForTesting - protected final ListVirtualDatacenters listVirtualDatacenters; + @VisibleForTesting + protected final ListVirtualDatacenters listVirtualDatacenters; - @VisibleForTesting - protected ListVirtualAppliances listVirtualAppliances; + @VisibleForTesting + protected ListVirtualAppliances listVirtualAppliances; - @VisibleForTesting - protected ListVirtualMachines listVirtualMachines; + @VisibleForTesting + protected ListVirtualMachines listVirtualMachines; - @Inject - protected BaseCloudService(final RestContext context, - final ListVirtualDatacenters listVirtualDatacenters, - final ListVirtualAppliances listVirtualAppliances, - final ListVirtualMachines listVirtualMachines) - { - this.context = checkNotNull(context, "context"); - this.listVirtualDatacenters = - checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); - this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); - this.listVirtualMachines = checkNotNull(listVirtualMachines, "listVirtualMachines"); - } + @Inject + protected BaseCloudService(final RestContext context, + final ListVirtualDatacenters listVirtualDatacenters, final ListVirtualAppliances listVirtualAppliances, + final ListVirtualMachines listVirtualMachines) { + this.context = checkNotNull(context, "context"); + this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); + this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); + this.listVirtualMachines = checkNotNull(listVirtualMachines, "listVirtualMachines"); + } - /*********************** Virtual Datacenter ********************** */ + /*********************** Virtual Datacenter ********************** */ - @Override - public Iterable listVirtualDatacenters() - { - return listVirtualDatacenters.execute(); - } + @Override + public Iterable listVirtualDatacenters() { + return listVirtualDatacenters.execute(); + } - @Override - public Iterable listVirtualDatacenters(final Enterprise enterprise) - { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " - + Enterprise.class); + @Override + public Iterable listVirtualDatacenters(final Enterprise enterprise) { + checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); + checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - VirtualDatacenterOptions options = - VirtualDatacenterOptions.builder().enterpriseId(enterprise.getId()).build(); + VirtualDatacenterOptions options = VirtualDatacenterOptions.builder().enterpriseId(enterprise.getId()).build(); - return listVirtualDatacenters.execute(options); - } + return listVirtualDatacenters.execute(options); + } - @Override - public Iterable listVirtualDatacenters( - final Predicate filter) - { - return listVirtualDatacenters.execute(filter); - } + @Override + public Iterable listVirtualDatacenters(final Predicate filter) { + return listVirtualDatacenters.execute(filter); + } - @Override - public VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId) - { - VirtualDatacenterDto virtualDatacenter = - context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); - return wrap(context, VirtualDatacenter.class, virtualDatacenter); - } + @Override + public VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId) { + VirtualDatacenterDto virtualDatacenter = context.getApi().getCloudApi().getVirtualDatacenter(virtualDatacenterId); + return wrap(context, VirtualDatacenter.class, virtualDatacenter); + } - @Override - public Iterable getVirtualDatacenters( - final List virtualDatacenterIds) - { - return listVirtualDatacenters.execute(virtualDatacenterIds); - } + @Override + public Iterable getVirtualDatacenters(final List virtualDatacenterIds) { + return listVirtualDatacenters.execute(virtualDatacenterIds); + } - @Override - public VirtualDatacenter findVirtualDatacenter(final Predicate filter) - { - return Iterables.getFirst(listVirtualDatacenters(filter), null); - } + @Override + public VirtualDatacenter findVirtualDatacenter(final Predicate filter) { + return Iterables.getFirst(listVirtualDatacenters(filter), null); + } - /*********************** Virtual Appliance ********************** */ + /*********************** Virtual Appliance ********************** */ - @Override - public Iterable listVirtualAppliances() - { - return listVirtualAppliances.execute(); - } + @Override + public Iterable listVirtualAppliances() { + return listVirtualAppliances.execute(); + } - @Override - public Iterable listVirtualAppliances(final Predicate filter) - { - return listVirtualAppliances.execute(filter); - } + @Override + public Iterable listVirtualAppliances(final Predicate filter) { + return listVirtualAppliances.execute(filter); + } - @Override - public VirtualAppliance findVirtualAppliance(final Predicate filter) - { - return Iterables.getFirst(listVirtualAppliances(filter), null); - } + @Override + public VirtualAppliance findVirtualAppliance(final Predicate filter) { + return Iterables.getFirst(listVirtualAppliances(filter), null); + } - /*********************** Virtual Machine ********************** */ + /*********************** Virtual Machine ********************** */ - @Override - public Iterable listVirtualMachines() - { - return listVirtualMachines.execute(); - } + @Override + public Iterable listVirtualMachines() { + return listVirtualMachines.execute(); + } - @Override - public Iterable listVirtualMachines(final Predicate filter) - { - return listVirtualMachines.execute(filter); - } + @Override + public Iterable listVirtualMachines(final Predicate filter) { + return listVirtualMachines.execute(filter); + } - @Override - public VirtualMachine findVirtualMachine(final Predicate filter) - { - return Iterables.getFirst(listVirtualMachines(filter), null); - } + @Override + public VirtualMachine findVirtualMachine(final Predicate filter) { + return Iterables.getFirst(listVirtualMachines(filter), null); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java index 2447cf5d65..960065d16a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseEventService.java @@ -41,31 +41,26 @@ import com.google.common.annotations.VisibleForTesting; * @author Vivien Mahé */ @Singleton -public class BaseEventService implements EventService -{ - @VisibleForTesting - protected RestContext context; +public class BaseEventService implements EventService { + @VisibleForTesting + protected RestContext context; - @VisibleForTesting - protected final ListEvents listEvents; + @VisibleForTesting + protected final ListEvents listEvents; - @Inject - protected BaseEventService(final RestContext context, - final ListEvents listEvents) - { - this.context = checkNotNull(context, "context"); - this.listEvents = checkNotNull(listEvents, "listEvents"); - } + @Inject + protected BaseEventService(final RestContext context, final ListEvents listEvents) { + this.context = checkNotNull(context, "context"); + this.listEvents = checkNotNull(listEvents, "listEvents"); + } - @Override - public Iterable listEvents() - { - return listEvents.execute(); - } + @Override + public Iterable listEvents() { + return listEvents.execute(); + } - @Override - public Iterable listEvents(final EventOptions options) - { - return listEvents.execute(options); - } + @Override + public Iterable listEvents(final EventOptions options) { + return listEvents.execute(options); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java index 8d850efb7e..e54f2d4d0e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseMonitoringService.java @@ -59,277 +59,240 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class BaseMonitoringService implements MonitoringService -{ - @VisibleForTesting - protected RestContext context; +public class BaseMonitoringService implements MonitoringService { + @VisibleForTesting + protected RestContext context; - /** The scheduler used to perform monitoring tasks. */ - @VisibleForTesting - protected ScheduledExecutorService scheduler; + /** The scheduler used to perform monitoring tasks. */ + @VisibleForTesting + protected ScheduledExecutorService scheduler; - @VisibleForTesting - protected Long pollingDelay; + @VisibleForTesting + protected Long pollingDelay; - /** - * The event bus used to dispatch monitoring events. - *

- * A sync bus is used by default, to prevent deadlocks when using the - * {@link BlockingEventHandler}. - */ - @VisibleForTesting - protected EventBus eventBus; + /** + * The event bus used to dispatch monitoring events. + *

+ * A sync bus is used by default, to prevent deadlocks when using the + * {@link BlockingEventHandler}. + */ + @VisibleForTesting + protected EventBus eventBus; - @Resource - private Logger logger = Logger.NULL; + @Resource + private Logger logger = Logger.NULL; - @Inject - public BaseMonitoringService(final RestContext context, - @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, - @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus) - { - this.context = checkNotNull(context, "context"); - this.scheduler = checkNotNull(scheduler, "scheduler"); - this.pollingDelay = checkNotNull(pollingDelay, "pollingDelay"); - this.eventBus = checkNotNull(eventBus, "eventBus"); - } + @Inject + public BaseMonitoringService(final RestContext context, + @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, + @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus) { + this.context = checkNotNull(context, "context"); + this.scheduler = checkNotNull(scheduler, "scheduler"); + this.pollingDelay = checkNotNull(pollingDelay, "pollingDelay"); + this.eventBus = checkNotNull(eventBus, "eventBus"); + } - /*************** Generic monitoring methods ***************/ + /*************** Generic monitoring methods ***************/ - @Override - public void awaitCompletion(final Function completeCondition, - final T... objects) - { - awaitCompletion(null, null, completeCondition, objects); - } + @Override + public void awaitCompletion(final Function completeCondition, final T... objects) { + awaitCompletion(null, null, completeCondition, objects); + } - @Override - public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final Function completeCondition, final T... objects) - { - checkNotNull(completeCondition, "completeCondition"); + @Override + public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, + final Function completeCondition, final T... objects) { + checkNotNull(completeCondition, "completeCondition"); - if (objects != null && objects.length > 0) - { - BlockingEventHandler blockingHandler = new BlockingEventHandler(logger, objects); - register(blockingHandler); + if (objects != null && objects.length > 0) { + BlockingEventHandler blockingHandler = new BlockingEventHandler(logger, objects); + register(blockingHandler); - monitor(maxWait, timeUnit, completeCondition, objects); - blockingHandler.lock(); + monitor(maxWait, timeUnit, completeCondition, objects); + blockingHandler.lock(); - unregister(blockingHandler); - } - } + unregister(blockingHandler); + } + } - @Override - public void monitor(final Function completeCondition, final T... objects) - { - monitor(null, null, completeCondition, objects); - } + @Override + public void monitor(final Function completeCondition, final T... objects) { + monitor(null, null, completeCondition, objects); + } - @Override - public void monitor(final Long maxWait, final TimeUnit timeUnit, - final Function completeCondition, final T... objects) - { - checkNotNull(completeCondition, "completeCondition"); - if (maxWait != null) - { - checkNotNull(timeUnit, "timeUnit"); - } + @Override + public void monitor(final Long maxWait, final TimeUnit timeUnit, + final Function completeCondition, final T... objects) { + checkNotNull(completeCondition, "completeCondition"); + if (maxWait != null) { + checkNotNull(timeUnit, "timeUnit"); + } - if (objects != null && objects.length > 0) - { - for (T object : objects) - { - AsyncMonitor monitor = new AsyncMonitor(object, completeCondition); - monitor.startMonitoring(maxWait); - } - } - } + if (objects != null && objects.length > 0) { + for (T object : objects) { + AsyncMonitor monitor = new AsyncMonitor(object, completeCondition); + monitor.startMonitoring(maxWait); + } + } + } - @Override - public > void register(final T handler) - { - logger.debug("registering event handler %s", handler); - eventBus.register(handler); - } + @Override + public > void register(final T handler) { + logger.debug("registering event handler %s", handler); + eventBus.register(handler); + } - @Override - public > void unregister(final T handler) - { - logger.debug("unregistering event handler %s", handler); - eventBus.unregister(handler); - } + @Override + public > void unregister(final T handler) { + logger.debug("unregistering event handler %s", handler); + eventBus.unregister(handler); + } - /*************** Delegating monitors ***************/ + /*************** Delegating monitors ***************/ - @Override - public VirtualMachineMonitor getVirtualMachineMonitor() - { - return checkNotNull( - context.getUtils().getInjector().getInstance(VirtualMachineMonitor.class), + @Override + public VirtualMachineMonitor getVirtualMachineMonitor() { + return checkNotNull(context.getUtils().getInjector().getInstance(VirtualMachineMonitor.class), "virtualMachineMonitor"); - } + } - @Override - public VirtualApplianceMonitor getVirtualApplianceMonitor() - { - return checkNotNull( - context.getUtils().getInjector().getInstance(VirtualApplianceMonitor.class), + @Override + public VirtualApplianceMonitor getVirtualApplianceMonitor() { + return checkNotNull(context.getUtils().getInjector().getInstance(VirtualApplianceMonitor.class), "virtualApplianceMonitor"); - } + } - @Override - public AsyncTaskMonitor getAsyncTaskMonitor() - { - return checkNotNull(context.getUtils().getInjector().getInstance(AsyncTaskMonitor.class), - "asyncTaskMonitor"); - } + @Override + public AsyncTaskMonitor getAsyncTaskMonitor() { + return checkNotNull(context.getUtils().getInjector().getInstance(AsyncTaskMonitor.class), "asyncTaskMonitor"); + } - @Override - public ConversionMonitor getConversionMonitor() - { - return checkNotNull(context.getUtils().getInjector().getInstance(ConversionMonitor.class), - "conversionMonitor"); - } + @Override + public ConversionMonitor getConversionMonitor() { + return checkNotNull(context.getUtils().getInjector().getInstance(ConversionMonitor.class), "conversionMonitor"); + } - /** - * Performs the periodical monitoring tasks. - * - * @author Ignasi Barrera - * @param The type of the object being monitored. - */ - @VisibleForTesting - class AsyncMonitor implements Runnable - { - /** The object being monitored. */ - private T monitoredObject; + /** + * Performs the periodical monitoring tasks. + * + * @author Ignasi Barrera + * @param + * The type of the object being monitored. + */ + @VisibleForTesting + class AsyncMonitor implements Runnable { + /** The object being monitored. */ + private T monitoredObject; - /** The function used to monitor the target object. */ - private Function completeCondition; + /** The function used to monitor the target object. */ + private Function completeCondition; - /** - * The future representing the monitoring job. Needed to be able to cancel it when monitor - * finishes. - */ - private Future< ? > future; + /** + * The future representing the monitoring job. Needed to be able to cancel + * it when monitor finishes. + */ + private Future future; - /** The timeout for this monitor. */ - private Long timeout; + /** The timeout for this monitor. */ + private Long timeout; - public AsyncMonitor(final T monitoredObject, - final Function completeCondition) - { - super(); - this.monitoredObject = checkNotNull(monitoredObject, "monitoredObject"); - this.completeCondition = checkNotNull(completeCondition, "completeCondition"); - } + public AsyncMonitor(final T monitoredObject, final Function completeCondition) { + super(); + this.monitoredObject = checkNotNull(monitoredObject, "monitoredObject"); + this.completeCondition = checkNotNull(completeCondition, "completeCondition"); + } - /** - * Starts the monitoring job with the given timeout. - * - * @param maxWait The timeout. - */ - public void startMonitoring(final Long maxWait) - { - future = - scheduler.scheduleWithFixedDelay(this, 0L, pollingDelay, TimeUnit.MILLISECONDS); - timeout = maxWait == null ? null : System.currentTimeMillis() + maxWait; - logger.debug("started monitor job for %s with %s timeout", monitoredObject, - timeout == null ? "no" : String.valueOf(timeout)); - } + /** + * Starts the monitoring job with the given timeout. + * + * @param maxWait + * The timeout. + */ + public void startMonitoring(final Long maxWait) { + future = scheduler.scheduleWithFixedDelay(this, 0L, pollingDelay, TimeUnit.MILLISECONDS); + timeout = maxWait == null ? null : System.currentTimeMillis() + maxWait; + logger.debug("started monitor job for %s with %s timeout", monitoredObject, + timeout == null ? "no" : String.valueOf(timeout)); + } - /** - * Stops the monitoring job, if running. - */ - public void stopMonitoring() - { - logger.debug("stopping monitor job for %s", monitoredObject); + /** + * Stops the monitoring job, if running. + */ + public void stopMonitoring() { + logger.debug("stopping monitor job for %s", monitoredObject); - try - { - if (future != null && !future.isCancelled() && !future.isDone()) - { - // Do not force future cancel. Let it finish gracefully - logger.debug("cancelling future"); - future.cancel(false); - } + try { + if (future != null && !future.isCancelled() && !future.isDone()) { + // Do not force future cancel. Let it finish gracefully + logger.debug("cancelling future"); + future.cancel(false); } - catch (Exception ex) - { - logger.warn(ex, "failed to stop monitor job for %s", monitoredObject); - } - } + } catch (Exception ex) { + logger.warn(ex, "failed to stop monitor job for %s", monitoredObject); + } + } - /** - * Checks if the monitor has timed out. - */ - public boolean isTimeout() - { - return timeout != null && timeout < System.currentTimeMillis(); - } + /** + * Checks if the monitor has timed out. + */ + public boolean isTimeout() { + return timeout != null && timeout < System.currentTimeMillis(); + } - @Override - public void run() - { - // Do not use Thread.interrupted() since it will clear the interrupted flag - // and subsequent calls to it may not return the appropriate value - if (Thread.currentThread().isInterrupted()) - { - // If the thread as already been interrupted, just stop monitoring the task and - // return - stopMonitoring(); - return; - } + @Override + public void run() { + // Do not use Thread.interrupted() since it will clear the interrupted + // flag + // and subsequent calls to it may not return the appropriate value + if (Thread.currentThread().isInterrupted()) { + // If the thread as already been interrupted, just stop monitoring + // the task and + // return + stopMonitoring(); + return; + } - MonitorStatus status = completeCondition.apply(monitoredObject); - logger.debug("monitored object %s status %s", monitoredObject, status.name()); + MonitorStatus status = completeCondition.apply(monitoredObject); + logger.debug("monitored object %s status %s", monitoredObject, status.name()); - switch (status) - { - case DONE: - stopMonitoring(); - logger.debug("publishing COMPLETED event"); - eventBus.post(new CompletedEvent(monitoredObject)); - break; - case FAILED: - stopMonitoring(); - logger.debug("publishing FAILED event"); - eventBus.post(new FailedEvent(monitoredObject)); - break; - case CONTINUE: - default: - if (isTimeout()) - { - logger.warn("monitor for object %s timed out. Shutting down monitor.", - monitoredObject); - stopMonitoring(); - logger.debug("publishing TIMEOUT event"); - eventBus.post(new TimeoutEvent(monitoredObject)); - } - break; - } - } + switch (status) { + case DONE: + stopMonitoring(); + logger.debug("publishing COMPLETED event"); + eventBus.post(new CompletedEvent(monitoredObject)); + break; + case FAILED: + stopMonitoring(); + logger.debug("publishing FAILED event"); + eventBus.post(new FailedEvent(monitoredObject)); + break; + case CONTINUE: + default: + if (isTimeout()) { + logger.warn("monitor for object %s timed out. Shutting down monitor.", monitoredObject); + stopMonitoring(); + logger.debug("publishing TIMEOUT event"); + eventBus.post(new TimeoutEvent(monitoredObject)); + } + break; + } + } - public T getMonitoredObject() - { - return monitoredObject; - } + public T getMonitoredObject() { + return monitoredObject; + } - public Function getCompleteCondition() - { - return completeCondition; - } + public Function getCompleteCondition() { + return completeCondition; + } - public Future< ? > getFuture() - { - return future; - } + public Future getFuture() { + return future; + } - public Long getTimeout() - { - return timeout; - } - } + public Long getTimeout() { + return timeout; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java index 0dc034be78..1fc2c9aebc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BasePricingService.java @@ -57,137 +57,114 @@ import com.google.common.collect.Iterables; * @author Susana Acedo */ @Singleton -public class BasePricingService implements PricingService -{ - @VisibleForTesting - protected RestContext context; +public class BasePricingService implements PricingService { + @VisibleForTesting + protected RestContext context; - @VisibleForTesting - protected final ListCurrencies listCurrencies; + @VisibleForTesting + protected final ListCurrencies listCurrencies; - @VisibleForTesting - protected final ListCostCodes listCostCodes; + @VisibleForTesting + protected final ListCostCodes listCostCodes; - @VisibleForTesting - protected final ListPricingTemplates listPricingTemplates; + @VisibleForTesting + protected final ListPricingTemplates listPricingTemplates; - @Inject - protected BasePricingService(final RestContext context, - final ListCurrencies listCurrencies, final ListCostCodes listCostCodes, - final ListPricingTemplates listPricingTemplates) - { - this.context = checkNotNull(context, "context"); - this.listCurrencies = checkNotNull(listCurrencies, "listCurrencies"); - this.listCostCodes = checkNotNull(listCostCodes, "listCostCodes"); - this.listPricingTemplates = checkNotNull(listPricingTemplates, "listPricingTemplates"); - } + @Inject + protected BasePricingService(final RestContext context, + final ListCurrencies listCurrencies, final ListCostCodes listCostCodes, + final ListPricingTemplates listPricingTemplates) { + this.context = checkNotNull(context, "context"); + this.listCurrencies = checkNotNull(listCurrencies, "listCurrencies"); + this.listCostCodes = checkNotNull(listCostCodes, "listCostCodes"); + this.listPricingTemplates = checkNotNull(listPricingTemplates, "listPricingTemplates"); + } - /*********************** Currency ********************** */ + /*********************** Currency ********************** */ - @Override - public Iterable listCurrencies() - { - return listCurrencies.execute(); - } + @Override + public Iterable listCurrencies() { + return listCurrencies.execute(); + } - @Override - public Iterable listCurrencies(final Predicate filter) - { - return listCurrencies.execute(filter); - } + @Override + public Iterable listCurrencies(final Predicate filter) { + return listCurrencies.execute(filter); + } - @Override - public Currency findCurrency(final Predicate filter) - { - return Iterables.getFirst(listCurrencies(filter), null); - } + @Override + public Currency findCurrency(final Predicate filter) { + return Iterables.getFirst(listCurrencies(filter), null); + } - /*********************** CostCode ********************** */ + /*********************** CostCode ********************** */ - @Override - public Iterable listCostCodes() - { - return listCostCodes.execute(); - } + @Override + public Iterable listCostCodes() { + return listCostCodes.execute(); + } - @Override - public Iterable listCostCodes(final Predicate filter) - { - return listCostCodes.execute(filter); - } + @Override + public Iterable listCostCodes(final Predicate filter) { + return listCostCodes.execute(filter); + } - @Override - public CostCode findCostCode(final Predicate filter) - { - return Iterables.getFirst(listCostCodes(filter), null); - } + @Override + public CostCode findCostCode(final Predicate filter) { + return Iterables.getFirst(listCostCodes(filter), null); + } - /*********************** PricingTemplate ********************** */ + /*********************** PricingTemplate ********************** */ - @Override - public Iterable listPricingTemplates() - { - return listPricingTemplates.execute(); - } + @Override + public Iterable listPricingTemplates() { + return listPricingTemplates.execute(); + } - @Override - public Iterable listPricingTemplates(final Predicate filter) - { - return listPricingTemplates.execute(filter); - } + @Override + public Iterable listPricingTemplates(final Predicate filter) { + return listPricingTemplates.execute(filter); + } - @Override - public PricingTemplate findPricingTemplate(final Predicate filter) - { - return Iterables.getFirst(listPricingTemplates(filter), null); - } + @Override + public PricingTemplate findPricingTemplate(final Predicate filter) { + return Iterables.getFirst(listPricingTemplates(filter), null); + } - /*********************** CostCodeCurrency ********************** */ + /*********************** CostCodeCurrency ********************** */ - @Override - public Iterable getCostCodeCurrencies(final Integer costcodeId, - final Integer currencyId) - { - CostCodeCurrenciesDto result = - context.getApi().getPricingApi().getCostCodeCurrencies(costcodeId, currencyId); - return wrap(context, CostCodeCurrency.class, result.getCollection()); - } + @Override + public Iterable getCostCodeCurrencies(final Integer costcodeId, final Integer currencyId) { + CostCodeCurrenciesDto result = context.getApi().getPricingApi().getCostCodeCurrencies(costcodeId, currencyId); + return wrap(context, CostCodeCurrency.class, result.getCollection()); + } - /*********************** Pricing Cost Code ********************** */ + /*********************** Pricing Cost Code ********************** */ - @Override - public Collection getPricingCostCodes(final Integer pricingTemplateId) - { - PricingCostCodesDto result = - context.getApi().getPricingApi().getPricingCostCodes(pricingTemplateId); - return wrap(context, PricingCostCode.class, result.getCollection()); - } + @Override + public Collection getPricingCostCodes(final Integer pricingTemplateId) { + PricingCostCodesDto result = context.getApi().getPricingApi().getPricingCostCodes(pricingTemplateId); + return wrap(context, PricingCostCode.class, result.getCollection()); + } - @Override - public PricingCostCode getPricingCostCode(final Integer pricingTemplateId, - final Integer pricingCostCodeId) - { - PricingCostCodeDto pricingcostcode = - context.getApi().getPricingApi() - .getPricingCostCode(pricingTemplateId, pricingCostCodeId); - return wrap(context, PricingCostCode.class, pricingcostcode); - } + @Override + public PricingCostCode getPricingCostCode(final Integer pricingTemplateId, final Integer pricingCostCodeId) { + PricingCostCodeDto pricingcostcode = context.getApi().getPricingApi() + .getPricingCostCode(pricingTemplateId, pricingCostCodeId); + return wrap(context, PricingCostCode.class, pricingcostcode); + } - /*********************** Pricing Tier********************** */ + /*********************** Pricing Tier********************** */ - @Override - public Collection getPricingTiers(final Integer pricingTemplateId) - { - PricingTiersDto result = - context.getApi().getPricingApi().getPricingTiers(pricingTemplateId); - return wrap(context, PricingTier.class, result.getCollection()); - } + @Override + public Collection getPricingTiers(final Integer pricingTemplateId) { + PricingTiersDto result = context.getApi().getPricingApi().getPricingTiers(pricingTemplateId); + return wrap(context, PricingTier.class, result.getCollection()); + } - @Override - public PricingTier getPricingTier(final Integer pricingTemplateId, final Integer pricingTierId) - { - PricingTierDto pricingtier = - context.getApi().getPricingApi().getPricingTier(pricingTemplateId, pricingTierId); - return wrap(context, PricingTier.class, pricingtier); - } + @Override + public PricingTier getPricingTier(final Integer pricingTemplateId, final Integer pricingTierId) { + PricingTierDto pricingtier = context.getApi().getPricingApi().getPricingTier(pricingTemplateId, pricingTierId); + return wrap(context, PricingTier.class, pricingtier); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java index 57d8c6694d..0326205ebb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/internal/BaseSearchService.java @@ -63,120 +63,94 @@ import com.google.common.annotations.VisibleForTesting; * @author Francesc Montserrat */ @Singleton -public class BaseSearchService implements SearchService -{ - @VisibleForTesting - protected RestContext context; +public class BaseSearchService implements SearchService { + @VisibleForTesting + protected RestContext context; - @Inject - protected BaseSearchService(final RestContext context) - { - this.context = checkNotNull(context, "context"); - } + @Inject + protected BaseSearchService(final RestContext context) { + this.context = checkNotNull(context, "context"); + } - /*********************** Enterprise ***********************/ + /*********************** Enterprise ***********************/ - @Override - public Iterable searchEnterprises(final EnterpriseOptions options) - { - List enterprises = - context.getApi().getEnterpriseApi().listEnterprises(options).getCollection(); + @Override + public Iterable searchEnterprises(final EnterpriseOptions options) { + List enterprises = context.getApi().getEnterpriseApi().listEnterprises(options).getCollection(); - return wrap(context, Enterprise.class, enterprises); - } + return wrap(context, Enterprise.class, enterprises); + } - @Override - public Iterable searchEnterprisesUsingDatacenter(final Datacenter datacenter, - final EnterpriseOptions options) - { - List enterprises = - context.getApi().getEnterpriseApi().listEnterprises(datacenter.unwrap(), options) - .getCollection(); + @Override + public Iterable searchEnterprisesUsingDatacenter(final Datacenter datacenter, + final EnterpriseOptions options) { + List enterprises = context.getApi().getEnterpriseApi() + .listEnterprises(datacenter.unwrap(), options).getCollection(); - return wrap(context, Enterprise.class, enterprises); - } + return wrap(context, Enterprise.class, enterprises); + } - /*********************** Volume ********************** */ + /*********************** Volume ********************** */ - @Override - public Iterable searchVolumes(final VirtualDatacenter virtualDatacenter, - final VolumeOptions options) - { - List volumes = - context.getApi().getCloudApi().listVolumes(virtualDatacenter.unwrap(), options) - .getCollection(); + @Override + public Iterable searchVolumes(final VirtualDatacenter virtualDatacenter, final VolumeOptions options) { + List volumes = context.getApi().getCloudApi() + .listVolumes(virtualDatacenter.unwrap(), options).getCollection(); - return wrap(context, Volume.class, volumes); - } + return wrap(context, Volume.class, volumes); + } - /*********************** Storage Pool ***********************/ + /*********************** Storage Pool ***********************/ - @Override - public List searchStoragePools(final StorageDevice device, - final StoragePoolOptions options) - { - List pools = - context.getApi().getInfrastructureApi().listStoragePools(device.unwrap(), options) - .getCollection(); + @Override + public List searchStoragePools(final StorageDevice device, final StoragePoolOptions options) { + List pools = context.getApi().getInfrastructureApi().listStoragePools(device.unwrap(), options) + .getCollection(); - return wrap(context, StoragePool.class, pools); - } + return wrap(context, StoragePool.class, pools); + } - /*********************** Private Network ***********************/ + /*********************** Private Network ***********************/ - @Override - public Iterable searchPrivateIps(final PrivateNetwork network, - final IpOptions options) - { - List ips = - context.getApi().getCloudApi().listPrivateNetworkIps(network.unwrap(), options) - .getCollection(); + @Override + public Iterable searchPrivateIps(final PrivateNetwork network, final IpOptions options) { + List ips = context.getApi().getCloudApi().listPrivateNetworkIps(network.unwrap(), options) + .getCollection(); - return wrap(context, PrivateIp.class, ips); - } + return wrap(context, PrivateIp.class, ips); + } - @Override - public Iterable searchPublicIpsToPurchase(final VirtualDatacenter virtualDatacenter, - final IpOptions options) - { - List ips = - context.getApi().getCloudApi() - .listAvailablePublicIps(virtualDatacenter.unwrap(), options).getCollection(); + @Override + public Iterable searchPublicIpsToPurchase(final VirtualDatacenter virtualDatacenter, + final IpOptions options) { + List ips = context.getApi().getCloudApi() + .listAvailablePublicIps(virtualDatacenter.unwrap(), options).getCollection(); - return wrap(context, PublicIp.class, ips); - } + return wrap(context, PublicIp.class, ips); + } - @Override - public Iterable searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, - final IpOptions options) - { - List ips = - context.getApi().getCloudApi() - .listPurchasedPublicIps(virtualDatacenter.unwrap(), options).getCollection(); + @Override + public Iterable searchPurchasedPublicIps(final VirtualDatacenter virtualDatacenter, final IpOptions options) { + List ips = context.getApi().getCloudApi() + .listPurchasedPublicIps(virtualDatacenter.unwrap(), options).getCollection(); - return wrap(context, PublicIp.class, ips); - } + return wrap(context, PublicIp.class, ips); + } - @Override - public Iterable searchServiceProfiles(final ManagedRack rack, - final FilterOptions options) - { - List profiles = - context.getApi().getInfrastructureApi().listServiceProfiles(rack.unwrap(), options) - .getCollection(); + @Override + public Iterable searchServiceProfiles(final ManagedRack rack, final FilterOptions options) { + List profiles = context.getApi().getInfrastructureApi() + .listServiceProfiles(rack.unwrap(), options).getCollection(); - return wrap(context, LogicServer.class, profiles); - } + return wrap(context, LogicServer.class, profiles); + } - @Override - public Iterable searchServiceProfileTemplates(final ManagedRack rack, - final FilterOptions options) - { - List profiles = - context.getApi().getInfrastructureApi() - .listServiceProfileTemplates(rack.unwrap(), options).getCollection(); + @Override + public Iterable searchServiceProfileTemplates(final ManagedRack rack, final FilterOptions options) { + List profiles = context.getApi().getInfrastructureApi() + .listServiceProfileTemplates(rack.unwrap(), options).getCollection(); - return wrap(context, LogicServer.class, profiles); - } + return wrap(context, LogicServer.class, profiles); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java index d9b7c7fcff..b698b0838d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/AsyncTaskMonitor.java @@ -33,37 +33,46 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(BaseAsyncTaskMonitor.class) -public interface AsyncTaskMonitor extends MonitoringService -{ - /** - * Monitor the given {@link AsyncTask}s and block until they finishe. - * - * @param tasks The {@link AsyncTask}s to monitor. - */ - void awaitCompletion(final AsyncTask... tasks); +public interface AsyncTaskMonitor extends MonitoringService { + /** + * Monitor the given {@link AsyncTask}s and block until they finishe. + * + * @param tasks + * The {@link AsyncTask}s to monitor. + */ + void awaitCompletion(final AsyncTask... tasks); - /** - * Monitor the given {@link AsyncTask}s and populate an event when they finish. - * - * @param tasks The {@link AsyncTask}s to monitor. - */ - public void monitor(final AsyncTask... tasks); + /** + * Monitor the given {@link AsyncTask}s and populate an event when they + * finish. + * + * @param tasks + * The {@link AsyncTask}s to monitor. + */ + public void monitor(final AsyncTask... tasks); - /** - * Monitor the given {@link AsyncTask}s and block until they finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param tasks The {@link AsyncTask}s to monitor. - */ - void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks); + /** + * Monitor the given {@link AsyncTask}s and block until they finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param tasks + * The {@link AsyncTask}s to monitor. + */ + void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks); - /** - * Monitor the given {@link AsyncTask}s and populate an event when they finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param tasks The {@link AsyncTask}s to monitor. - */ - public void monitor(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks); + /** + * Monitor the given {@link AsyncTask}s and populate an event when they + * finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param tasks + * The {@link AsyncTask}s to monitor. + */ + public void monitor(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/ConversionMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/ConversionMonitor.java index 5910cfe952..b293b380bb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/ConversionMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/ConversionMonitor.java @@ -33,39 +33,46 @@ import com.google.inject.ImplementedBy; * @author Sergi Castro */ @ImplementedBy(BaseConversionMonitor.class) -public interface ConversionMonitor extends MonitoringService -{ - /** - * Monitor the given {@link Conversion}s and block until they finishes. - * - * @param conversions The {@link Conversion}s to monitor. - */ - void awaitCompletion(final Conversion... conversions); +public interface ConversionMonitor extends MonitoringService { + /** + * Monitor the given {@link Conversion}s and block until they finishes. + * + * @param conversions + * The {@link Conversion}s to monitor. + */ + void awaitCompletion(final Conversion... conversions); - /** - * Monitor the given {@link Conversion}s and populate an event when they finish. - * - * @param conversions The {@link Conversion}s to monitor. - */ - public void monitor(final Conversion... conversions); + /** + * Monitor the given {@link Conversion}s and populate an event when they + * finish. + * + * @param conversions + * The {@link Conversion}s to monitor. + */ + public void monitor(final Conversion... conversions); - /** - * Monitor the given {@link Conversion}s and block until they finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param conversions The {@link Conversion}s to monitor. - */ - void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final Conversion... conversions); + /** + * Monitor the given {@link Conversion}s and block until they finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param conversions + * The {@link Conversion}s to monitor. + */ + void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final Conversion... conversions); - /** - * Monitor the given {@link Conversion}s and populate an event when they finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param conversions The {@link Conversion}s to monitor. - */ - public void monitor(final Long maxWait, final TimeUnit timeUnit, - final Conversion... conversions); + /** + * Monitor the given {@link Conversion}s and populate an event when they + * finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param conversions + * The {@link Conversion}s to monitor. + */ + public void monitor(final Long maxWait, final TimeUnit timeUnit, final Conversion... conversions); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/MonitorStatus.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/MonitorStatus.java index b5351648dd..1b744a2be8 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/MonitorStatus.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/MonitorStatus.java @@ -24,14 +24,13 @@ package org.jclouds.abiquo.monitor; * * @author Serafin Sedano */ -public enum MonitorStatus -{ - /** The monitoring job has finished. */ - DONE, +public enum MonitorStatus { + /** The monitoring job has finished. */ + DONE, - /** The monitoring job has finished and the result is not the expected one. */ - FAILED, + /** The monitoring job has finished and the result is not the expected one. */ + FAILED, - /** The monitoring job must continue. */ - CONTINUE + /** The monitoring job must continue. */ + CONTINUE } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualApplianceMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualApplianceMonitor.java index b6088af4cd..07766bc786 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualApplianceMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualApplianceMonitor.java @@ -33,75 +33,94 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(BaseVirtualApplianceMonitor.class) -public interface VirtualApplianceMonitor extends MonitoringService -{ - /** - * Monitor the given {@link VirtualAppliance}s and block until the deploy finishes. - * - * @param vapp The {@link VirtualAppliance}s to monitor. - */ - void awaitCompletionDeploy(final VirtualAppliance... vapp); +public interface VirtualApplianceMonitor extends MonitoringService { + /** + * Monitor the given {@link VirtualAppliance}s and block until the deploy + * finishes. + * + * @param vapp + * The {@link VirtualAppliance}s to monitor. + */ + void awaitCompletionDeploy(final VirtualAppliance... vapp); - /** - * Monitor the given {@link VirtualAppliance}s and populate an event when the deploy finishes. - * - * @param VirtualAppliance The {@link VirtualAppliance}s to monitor. - */ - public void monitorDeploy(final VirtualAppliance... vapps); + /** + * Monitor the given {@link VirtualAppliance}s and populate an event when the + * deploy finishes. + * + * @param VirtualAppliance + * The {@link VirtualAppliance}s to monitor. + */ + public void monitorDeploy(final VirtualAppliance... vapps); - /** - * Monitor the given {@link VirtualAppliance}s and block until the deploy finishes. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vapp The {@link VirtualAppliance}s to monitor. - */ - void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapp); + /** + * Monitor the given {@link VirtualAppliance}s and block until the deploy + * finishes. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vapp + * The {@link VirtualAppliance}s to monitor. + */ + void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapp); - /** - * Monitor the given {@link VirtualAppliance}s and populate an event when deploy finishes. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vapps The {@link VirtualAppliance}s to monitor. - */ - public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps); + /** + * Monitor the given {@link VirtualAppliance}s and populate an event when + * deploy finishes. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vapps + * The {@link VirtualAppliance}s to monitor. + */ + public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps); - /** - * Monitor the given {@link VirtualAppliance}s and block until the undeploy finishes. - * - * @param vapp The {@link VirtualAppliance}s to monitor. - */ - void awaitCompletionUndeploy(final VirtualAppliance... vapp); + /** + * Monitor the given {@link VirtualAppliance}s and block until the undeploy + * finishes. + * + * @param vapp + * The {@link VirtualAppliance}s to monitor. + */ + void awaitCompletionUndeploy(final VirtualAppliance... vapp); - /** - * Monitor the given {@link VirtualAppliance}s and call populate an event when undeploy - * finishes. - * - * @param vapps The {@link VirtualAppliance}s to monitor. - */ - public void monitorUndeploy(final VirtualAppliance... vapps); + /** + * Monitor the given {@link VirtualAppliance}s and call populate an event + * when undeploy finishes. + * + * @param vapps + * The {@link VirtualAppliance}s to monitor. + */ + public void monitorUndeploy(final VirtualAppliance... vapps); - /** - * Monitor the given {@link VirtualAppliance}s and blocks until the undeploy finishes. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vapp The {@link VirtualAppliance}s to monitor. - */ - void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapp); + /** + * Monitor the given {@link VirtualAppliance}s and blocks until the undeploy + * finishes. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vapp + * The {@link VirtualAppliance}s to monitor. + */ + void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapp); - /** - * Monitor the given {@link VirtualAppliance}s and populate an event when undeploy finishes. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param callback The callback. - * @param vapps The {@link VirtualAppliance}s to monitor. - */ - public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps); + /** + * Monitor the given {@link VirtualAppliance}s and populate an event when + * undeploy finishes. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param callback + * The callback. + * @param vapps + * The {@link VirtualAppliance}s to monitor. + */ + public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualMachineMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualMachineMonitor.java index 74d488e051..f42bceb0d6 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualMachineMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/VirtualMachineMonitor.java @@ -34,111 +34,141 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(BaseVirtualMachineMonitor.class) -public interface VirtualMachineMonitor extends MonitoringService -{ - /** - * Monitor the given {@link VirtualMachine}s and block until all deploys finish. - * - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitCompletionDeploy(final VirtualMachine... vm); +public interface VirtualMachineMonitor extends MonitoringService { + /** + * Monitor the given {@link VirtualMachine}s and block until all deploys + * finish. + * + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitCompletionDeploy(final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when all deploys finish. - * - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorDeploy(final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when all + * deploys finish. + * + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorDeploy(final VirtualMachine... vms); - /** - * Monitor the given {@link VirtualMachine}s and block until all deploys finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vm); + /** + * Monitor the given {@link VirtualMachine}s and block until all deploys + * finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when all deploys finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when all + * deploys finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms); - /** - * Monitor the given {@link VirtualMachine}s and block until all undeploys finish. - * - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitCompletionUndeploy(final VirtualMachine... vm); + /** + * Monitor the given {@link VirtualMachine}s and block until all undeploys + * finish. + * + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitCompletionUndeploy(final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when all undeploys finish. - * - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorUndeploy(final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when all + * undeploys finish. + * + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorUndeploy(final VirtualMachine... vms); - /** - * Monitor the given {@link VirtualMachine}s and blocks until all undeploys finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vm); + /** + * Monitor the given {@link VirtualMachine}s and blocks until all undeploys + * finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when all undeploys finish. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param callback The callback. - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when all + * undeploys finish. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param callback + * The callback. + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms); - /** - * Monitor the given {@link VirtualMachine}s and block until it is in the given state. - * - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitState(VirtualMachineState state, final VirtualMachine... vm); + /** + * Monitor the given {@link VirtualMachine}s and block until it is in the + * given state. + * + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitState(VirtualMachineState state, final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when it is in the given - * state. - * - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorState(VirtualMachineState state, final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when it is + * in the given state. + * + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorState(VirtualMachineState state, final VirtualMachine... vms); - /** - * Monitor the given {@link VirtualMachine}s and block until it is in the given state. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param vm The {@link VirtualMachine}s to monitor. - */ - void awaitState(final Long maxWait, final TimeUnit timeUnit, VirtualMachineState state, - final VirtualMachine... vm); + /** + * Monitor the given {@link VirtualMachine}s and block until it is in the + * given state. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param vm + * The {@link VirtualMachine}s to monitor. + */ + void awaitState(final Long maxWait, final TimeUnit timeUnit, VirtualMachineState state, final VirtualMachine... vm); - /** - * Monitor the given {@link VirtualMachine}s and populate an event when it is in the given - * state. - * - * @param maxWait The maximum time to wait. - * @param timeUnit The time unit for the maxWait parameter. - * @param callback The callback. - * @param vms The {@link VirtualMachine}s to monitor. - */ - public void monitorState(final Long maxWait, final TimeUnit timeUnit, - VirtualMachineState state, final VirtualMachine... vms); + /** + * Monitor the given {@link VirtualMachine}s and populate an event when it is + * in the given state. + * + * @param maxWait + * The maximum time to wait. + * @param timeUnit + * The time unit for the maxWait parameter. + * @param callback + * The callback. + * @param vms + * The {@link VirtualMachine}s to monitor. + */ + public void monitorState(final Long maxWait, final TimeUnit timeUnit, VirtualMachineState state, + final VirtualMachine... vms); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitor.java index 5e18eb2d94..433df10f86 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitor.java @@ -36,40 +36,34 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Singleton -public class AsyncTaskStatusMonitor implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class AsyncTaskStatusMonitor implements Function { + @Resource + protected Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final AsyncTask asyncTask) - { - checkNotNull(asyncTask, "asyncTask"); + @Override + public MonitorStatus apply(final AsyncTask asyncTask) { + checkNotNull(asyncTask, "asyncTask"); - try - { - asyncTask.refresh(); + try { + asyncTask.refresh(); - switch (asyncTask.getState()) - { - case ABORTED: - case FINISHED_UNSUCCESSFULLY: - return MonitorStatus.FAILED; - case FINISHED_SUCCESSFULLY: - return MonitorStatus.DONE; - case STARTED: - case PENDING: - return MonitorStatus.CONTINUE; - default: - throw new IllegalStateException("Unsupported task status"); - } - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - asyncTask, getClass().getName()); + switch (asyncTask.getState()) { + case ABORTED: + case FINISHED_UNSUCCESSFULLY: + return MonitorStatus.FAILED; + case FINISHED_SUCCESSFULLY: + return MonitorStatus.DONE; + case STARTED: + case PENDING: + return MonitorStatus.CONTINUE; + default: + throw new IllegalStateException("Unsupported task status"); + } + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", asyncTask, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitor.java index a97e38ecb5..357e0e53f0 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitor.java @@ -36,38 +36,32 @@ import com.google.common.base.Function; * @author Sergi Castro */ @Singleton -public class ConversionStatusMonitor implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class ConversionStatusMonitor implements Function { + @Resource + protected Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final Conversion conversion) - { - checkNotNull(conversion, "conversion"); + @Override + public MonitorStatus apply(final Conversion conversion) { + checkNotNull(conversion, "conversion"); - try - { - conversion.refresh(); + try { + conversion.refresh(); - switch (conversion.getState()) - { - case ENQUEUED: - return MonitorStatus.CONTINUE; - case FAILED: - return MonitorStatus.FAILED; - case FINISHED: - return MonitorStatus.DONE; - default: - throw new IllegalStateException("Unsupported conversion status"); - } - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - conversion, getClass().getName()); + switch (conversion.getState()) { + case ENQUEUED: + return MonitorStatus.CONTINUE; + case FAILED: + return MonitorStatus.FAILED; + case FINISHED: + return MonitorStatus.DONE; + default: + throw new IllegalStateException("Unsupported conversion status"); + } + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", conversion, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitor.java index d02f925948..7a77141a2d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitor.java @@ -32,44 +32,39 @@ import com.abiquo.server.core.cloud.VirtualApplianceState; import com.google.common.base.Function; /** - * This class takes care of monitoring the a deploy of a {@link VirtualAppliance}. + * This class takes care of monitoring the a deploy of a + * {@link VirtualAppliance}. * * @author Serafin Sedano */ @Singleton -public class VirtualApplianceDeployMonitor implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class VirtualApplianceDeployMonitor implements Function { + @Resource + protected Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final VirtualAppliance virtualAppliance) - { - checkNotNull(virtualAppliance, "virtualAppliance"); + @Override + public MonitorStatus apply(final VirtualAppliance virtualAppliance) { + checkNotNull(virtualAppliance, "virtualAppliance"); - try - { - VirtualApplianceState state = virtualAppliance.getState(); + try { + VirtualApplianceState state = virtualAppliance.getState(); - switch (state) - { - case UNKNOWN: - case NEEDS_SYNC: - case NOT_DEPLOYED: - return MonitorStatus.FAILED; - case DEPLOYED: - return MonitorStatus.DONE; - case LOCKED: - default: - return MonitorStatus.CONTINUE; - } - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - virtualAppliance, getClass().getName()); + switch (state) { + case UNKNOWN: + case NEEDS_SYNC: + case NOT_DEPLOYED: + return MonitorStatus.FAILED; + case DEPLOYED: + return MonitorStatus.DONE; + case LOCKED: + default: + return MonitorStatus.CONTINUE; + } + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", virtualAppliance, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitor.java index 4951a4fa6f..ccc0e5e69c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitor.java @@ -33,50 +33,43 @@ import com.abiquo.server.core.cloud.VirtualApplianceState; import com.google.common.base.Function; /** - * This class takes care of monitoring the a undeploy of a {@link VirtualAppliance}. + * This class takes care of monitoring the a undeploy of a + * {@link VirtualAppliance}. * * @author Serafin Sedano */ @Singleton -public class VirtualApplianceUndeployMonitor implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class VirtualApplianceUndeployMonitor implements Function { + @Resource + protected Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final VirtualAppliance virtualAppliance) - { - checkNotNull(virtualAppliance, "virtualAppliance"); + @Override + public MonitorStatus apply(final VirtualAppliance virtualAppliance) { + checkNotNull(virtualAppliance, "virtualAppliance"); - try - { - VirtualApplianceState state = virtualAppliance.getState(); + try { + VirtualApplianceState state = virtualAppliance.getState(); - switch (state) - { - case DEPLOYED: - case UNKNOWN: - case NEEDS_SYNC: - return MonitorStatus.FAILED; - case NOT_DEPLOYED: - return MonitorStatus.DONE; - case LOCKED: - default: - return MonitorStatus.CONTINUE; - } - } - catch (ResourceNotFoundException nfe) - { - logger.warn("virtual appliance %s not found, assuming it was undeployed successfully, " - + "stop monitor with DONE", virtualAppliance); - return MonitorStatus.DONE; - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - virtualAppliance, getClass().getName()); + switch (state) { + case DEPLOYED: + case UNKNOWN: + case NEEDS_SYNC: + return MonitorStatus.FAILED; + case NOT_DEPLOYED: + return MonitorStatus.DONE; + case LOCKED: + default: + return MonitorStatus.CONTINUE; + } + } catch (ResourceNotFoundException nfe) { + logger.warn("virtual appliance %s not found, assuming it was undeployed successfully, " + + "stop monitor with DONE", virtualAppliance); + return MonitorStatus.DONE; + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", virtualAppliance, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitor.java index 0befb07d30..13da1dfb7e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitor.java @@ -38,37 +38,31 @@ import com.google.inject.Singleton; * @see MonitoringService */ @Singleton -public class VirtualMachineDeployMonitor implements Function -{ - @Resource - private Logger logger = Logger.NULL; +public class VirtualMachineDeployMonitor implements Function { + @Resource + private Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final VirtualMachine virtualMachine) - { - checkNotNull(virtualMachine, "virtualMachine"); + @Override + public MonitorStatus apply(final VirtualMachine virtualMachine) { + checkNotNull(virtualMachine, "virtualMachine"); - try - { - VirtualMachineState state = virtualMachine.getState(); + try { + VirtualMachineState state = virtualMachine.getState(); - switch (state) - { - case NOT_ALLOCATED: - case UNKNOWN: - return MonitorStatus.FAILED; - case ON: - return MonitorStatus.DONE; - default: - return MonitorStatus.CONTINUE; - } - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - virtualMachine, getClass().getName()); + switch (state) { + case NOT_ALLOCATED: + case UNKNOWN: + return MonitorStatus.FAILED; + case ON: + return MonitorStatus.DONE; + default: + return MonitorStatus.CONTINUE; + } + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", virtualMachine, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitor.java index 869b959afb..00f3bd3b87 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitor.java @@ -36,36 +36,30 @@ import com.google.common.base.Function; * @author Ignasi Barrera * @see MonitoringService */ -public class VirtualMachineStateMonitor implements Function -{ - @Resource - private Logger logger = Logger.NULL; +public class VirtualMachineStateMonitor implements Function { + @Resource + private Logger logger = Logger.NULL; - private VirtualMachineState expectedState; + private VirtualMachineState expectedState; - public VirtualMachineStateMonitor(final VirtualMachineState expectedState) - { - super(); - this.expectedState = checkNotNull(expectedState, "expectedState"); - } + public VirtualMachineStateMonitor(final VirtualMachineState expectedState) { + super(); + this.expectedState = checkNotNull(expectedState, "expectedState"); + } - @Override - public MonitorStatus apply(final VirtualMachine virtualMachine) - { - checkNotNull(virtualMachine, "virtualMachine"); + @Override + public MonitorStatus apply(final VirtualMachine virtualMachine) { + checkNotNull(virtualMachine, "virtualMachine"); - try - { - VirtualMachineState state = virtualMachine.getState(); - return state == expectedState ? MonitorStatus.DONE : MonitorStatus.CONTINUE; - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - virtualMachine, getClass().getName()); + try { + VirtualMachineState state = virtualMachine.getState(); + return state == expectedState ? MonitorStatus.DONE : MonitorStatus.CONTINUE; + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", virtualMachine, getClass() + .getName()); - return MonitorStatus.CONTINUE; + return MonitorStatus.CONTINUE; - } - } + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitor.java index b82006cecb..f1f9fb69c9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitor.java @@ -33,53 +33,46 @@ import com.abiquo.server.core.cloud.VirtualMachineState; import com.google.common.base.Function; /** - * This class takes care of monitoring the a undeploy of a {@link VirtualMachine}. + * This class takes care of monitoring the a undeploy of a + * {@link VirtualMachine}. * * @author Serafin Sedano */ @Singleton -public class VirtualMachineUndeployMonitor implements Function -{ - @Resource - protected Logger logger = Logger.NULL; +public class VirtualMachineUndeployMonitor implements Function { + @Resource + protected Logger logger = Logger.NULL; - @Override - public MonitorStatus apply(final VirtualMachine virtualMachine) - { - checkNotNull(virtualMachine, "virtualMachine"); + @Override + public MonitorStatus apply(final VirtualMachine virtualMachine) { + checkNotNull(virtualMachine, "virtualMachine"); - try - { - VirtualMachineState state = virtualMachine.getState(); + try { + VirtualMachineState state = virtualMachine.getState(); - // This state may be reached if the undeploy process fails and a rollback is done - if (state.existsInHypervisor()) - { - return MonitorStatus.FAILED; - } + // This state may be reached if the undeploy process fails and a + // rollback is done + if (state.existsInHypervisor()) { + return MonitorStatus.FAILED; + } - switch (state) - { - case UNKNOWN: - return MonitorStatus.FAILED; - case NOT_ALLOCATED: - return MonitorStatus.DONE; - default: - return MonitorStatus.CONTINUE; - } - } - catch (ResourceNotFoundException nfe) - { - logger.warn("virtual machine %s not found, assuming it was undeployed successfully, " - + "stop monitor with DONE", virtualMachine); - return MonitorStatus.DONE; - } - catch (Exception ex) - { - logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", - virtualMachine, getClass().getName()); + switch (state) { + case UNKNOWN: + return MonitorStatus.FAILED; + case NOT_ALLOCATED: + return MonitorStatus.DONE; + default: + return MonitorStatus.CONTINUE; + } + } catch (ResourceNotFoundException nfe) { + logger.warn("virtual machine %s not found, assuming it was undeployed successfully, " + + "stop monitor with DONE", virtualMachine); + return MonitorStatus.DONE; + } catch (Exception ex) { + logger.warn(ex, "exception thrown while monitoring %s on %s, returning CONTINUE", virtualMachine, getClass() + .getName()); - return MonitorStatus.CONTINUE; - } - } + return MonitorStatus.CONTINUE; + } + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitor.java index f6e88c00e9..7d98f97fbb 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitor.java @@ -47,45 +47,38 @@ import com.google.common.eventbus.EventBus; * @author Ignasi Barrera */ @Singleton -public class BaseAsyncTaskMonitor extends BaseMonitoringService implements AsyncTaskMonitor -{ +public class BaseAsyncTaskMonitor extends BaseMonitoringService implements AsyncTaskMonitor { - @VisibleForTesting - protected AsyncTaskStatusMonitor taskMonitor; + @VisibleForTesting + protected AsyncTaskStatusMonitor taskMonitor; - @Inject - public BaseAsyncTaskMonitor(final RestContext context, - @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, - @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, - final AsyncTaskStatusMonitor monitor) - { - super(context, scheduler, pollingDelay, eventBus); - this.taskMonitor = checkNotNull(monitor, "monitor"); - } + @Inject + public BaseAsyncTaskMonitor(final RestContext context, + @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, + @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, + final AsyncTaskStatusMonitor monitor) { + super(context, scheduler, pollingDelay, eventBus); + this.taskMonitor = checkNotNull(monitor, "monitor"); + } - @Override - public void awaitCompletion(final AsyncTask... tasks) - { - awaitCompletion(taskMonitor, tasks); - } + @Override + public void awaitCompletion(final AsyncTask... tasks) { + awaitCompletion(taskMonitor, tasks); + } - @Override - public void monitor(final AsyncTask... tasks) - { - monitor(taskMonitor, tasks); - } + @Override + public void monitor(final AsyncTask... tasks) { + monitor(taskMonitor, tasks); + } - @Override - public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final AsyncTask... tasks) - { - awaitCompletion(maxWait, timeUnit, taskMonitor, tasks); - } + @Override + public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks) { + awaitCompletion(maxWait, timeUnit, taskMonitor, tasks); + } - @Override - public void monitor(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks) - { - monitor(maxWait, timeUnit, taskMonitor, tasks); - } + @Override + public void monitor(final Long maxWait, final TimeUnit timeUnit, final AsyncTask... tasks) { + monitor(maxWait, timeUnit, taskMonitor, tasks); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseConversionMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseConversionMonitor.java index b30be3a666..a7cff8e1b7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseConversionMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseConversionMonitor.java @@ -47,46 +47,38 @@ import com.google.common.eventbus.EventBus; * @author Sergi Castro */ @Singleton -public class BaseConversionMonitor extends BaseMonitoringService implements ConversionMonitor -{ +public class BaseConversionMonitor extends BaseMonitoringService implements ConversionMonitor { - @VisibleForTesting - protected ConversionStatusMonitor conversionMonitor; + @VisibleForTesting + protected ConversionStatusMonitor conversionMonitor; - @Inject - public BaseConversionMonitor(final RestContext context, - @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, - @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, - final ConversionStatusMonitor monitor) - { - super(context, scheduler, pollingDelay, eventBus); - this.conversionMonitor = checkNotNull(monitor, "monitor"); - } + @Inject + public BaseConversionMonitor(final RestContext context, + @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, + @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, + final ConversionStatusMonitor monitor) { + super(context, scheduler, pollingDelay, eventBus); + this.conversionMonitor = checkNotNull(monitor, "monitor"); + } - @Override - public void awaitCompletion(final Conversion... conversions) - { - awaitCompletion(conversionMonitor, conversions); - } + @Override + public void awaitCompletion(final Conversion... conversions) { + awaitCompletion(conversionMonitor, conversions); + } - @Override - public void monitor(final Conversion... conversions) - { - monitor(conversionMonitor, conversions); - } + @Override + public void monitor(final Conversion... conversions) { + monitor(conversionMonitor, conversions); + } - @Override - public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final Conversion... conversions) - { - awaitCompletion(maxWait, timeUnit, conversionMonitor, conversions); - } + @Override + public void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, final Conversion... conversions) { + awaitCompletion(maxWait, timeUnit, conversionMonitor, conversions); + } - @Override - public void monitor(final Long maxWait, final TimeUnit timeUnit, - final Conversion... conversions) - { - monitor(maxWait, timeUnit, conversionMonitor, conversions); - } + @Override + public void monitor(final Long maxWait, final TimeUnit timeUnit, final Conversion... conversions) { + monitor(maxWait, timeUnit, conversionMonitor, conversions); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitor.java index a1948dc7dc..f2cd05b27e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitor.java @@ -48,76 +48,60 @@ import com.google.common.eventbus.EventBus; * @author Ignasi Barrera */ @Singleton -public class BaseVirtualApplianceMonitor extends BaseMonitoringService implements - VirtualApplianceMonitor -{ - @VisibleForTesting - protected VirtualApplianceDeployMonitor deployMonitor; +public class BaseVirtualApplianceMonitor extends BaseMonitoringService implements VirtualApplianceMonitor { + @VisibleForTesting + protected VirtualApplianceDeployMonitor deployMonitor; - @VisibleForTesting - protected VirtualApplianceUndeployMonitor undeployMonitor; + @VisibleForTesting + protected VirtualApplianceUndeployMonitor undeployMonitor; - @Inject - public BaseVirtualApplianceMonitor(final RestContext context, - @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, - @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, - final VirtualApplianceDeployMonitor deployMonitor, - final VirtualApplianceUndeployMonitor undeployMonitor) - { - super(context, scheduler, pollingDelay, eventBus); - this.deployMonitor = checkNotNull(deployMonitor, "deployMonitor"); - this.undeployMonitor = checkNotNull(undeployMonitor, "undeployMonitor"); - } + @Inject + public BaseVirtualApplianceMonitor(final RestContext context, + @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, + @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, + final VirtualApplianceDeployMonitor deployMonitor, final VirtualApplianceUndeployMonitor undeployMonitor) { + super(context, scheduler, pollingDelay, eventBus); + this.deployMonitor = checkNotNull(deployMonitor, "deployMonitor"); + this.undeployMonitor = checkNotNull(undeployMonitor, "undeployMonitor"); + } - @Override - public void awaitCompletionDeploy(final VirtualAppliance... vapps) - { - awaitCompletion(deployMonitor, vapps); - } + @Override + public void awaitCompletionDeploy(final VirtualAppliance... vapps) { + awaitCompletion(deployMonitor, vapps); + } - @Override - public void monitorDeploy(final VirtualAppliance... vapps) - { - monitor(deployMonitor, vapps); - } + @Override + public void monitorDeploy(final VirtualAppliance... vapps) { + monitor(deployMonitor, vapps); + } - @Override - public void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps) - { - awaitCompletion(maxWait, timeUnit, deployMonitor, vapps); - } + @Override + public void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps) { + awaitCompletion(maxWait, timeUnit, deployMonitor, vapps); + } - @Override - public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps) - { - monitor(maxWait, timeUnit, deployMonitor, vapps); - } + @Override + public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps) { + monitor(maxWait, timeUnit, deployMonitor, vapps); + } - @Override - public void awaitCompletionUndeploy(final VirtualAppliance... vapps) - { - awaitCompletion(undeployMonitor, vapps); - } + @Override + public void awaitCompletionUndeploy(final VirtualAppliance... vapps) { + awaitCompletion(undeployMonitor, vapps); + } - @Override - public void monitorUndeploy(final VirtualAppliance... vapps) - { - monitor(undeployMonitor, vapps); - } + @Override + public void monitorUndeploy(final VirtualAppliance... vapps) { + monitor(undeployMonitor, vapps); + } - @Override - public void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps) - { - awaitCompletion(maxWait, timeUnit, undeployMonitor, vapps); - } + @Override + public void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps) { + awaitCompletion(maxWait, timeUnit, undeployMonitor, vapps); + } - @Override - public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualAppliance... vapps) - { - monitor(maxWait, timeUnit, undeployMonitor, vapps); - } + @Override + public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualAppliance... vapps) { + monitor(maxWait, timeUnit, undeployMonitor, vapps); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitor.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitor.java index aa7df1820f..e1bf8f41db 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitor.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitor.java @@ -50,102 +50,82 @@ import com.google.common.eventbus.EventBus; * @author Ignasi Barrera */ @Singleton -public class BaseVirtualMachineMonitor extends BaseMonitoringService implements - VirtualMachineMonitor -{ - @VisibleForTesting - protected VirtualMachineDeployMonitor deployMonitor; +public class BaseVirtualMachineMonitor extends BaseMonitoringService implements VirtualMachineMonitor { + @VisibleForTesting + protected VirtualMachineDeployMonitor deployMonitor; - @VisibleForTesting - protected VirtualMachineUndeployMonitor undeployMonitor; + @VisibleForTesting + protected VirtualMachineUndeployMonitor undeployMonitor; - @Inject - public BaseVirtualMachineMonitor(final RestContext context, - @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, - @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, - final VirtualMachineDeployMonitor deployMonitor, - final VirtualMachineUndeployMonitor undeployMonitor) - { - super(context, scheduler, pollingDelay, eventBus); - this.deployMonitor = checkNotNull(deployMonitor, "deployMonitor"); - this.undeployMonitor = checkNotNull(undeployMonitor, "undeployMonitor"); - } + @Inject + public BaseVirtualMachineMonitor(final RestContext context, + @Named(PROPERTY_SCHEDULER_THREADS) final ScheduledExecutorService scheduler, + @Named(ASYNC_TASK_MONITOR_DELAY) final Long pollingDelay, final EventBus eventBus, + final VirtualMachineDeployMonitor deployMonitor, final VirtualMachineUndeployMonitor undeployMonitor) { + super(context, scheduler, pollingDelay, eventBus); + this.deployMonitor = checkNotNull(deployMonitor, "deployMonitor"); + this.undeployMonitor = checkNotNull(undeployMonitor, "undeployMonitor"); + } - @Override - public void awaitCompletionDeploy(final VirtualMachine... vms) - { - awaitCompletion(deployMonitor, vms); - } + @Override + public void awaitCompletionDeploy(final VirtualMachine... vms) { + awaitCompletion(deployMonitor, vms); + } - @Override - public void monitorDeploy(final VirtualMachine... vms) - { - monitor(deployMonitor, vms); - } + @Override + public void monitorDeploy(final VirtualMachine... vms) { + monitor(deployMonitor, vms); + } - @Override - public void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms) - { - awaitCompletion(maxWait, timeUnit, deployMonitor, vms); - } + @Override + public void awaitCompletionDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms) { + awaitCompletion(maxWait, timeUnit, deployMonitor, vms); + } - @Override - public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms) - { - monitor(maxWait, timeUnit, deployMonitor, vms); - } + @Override + public void monitorDeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms) { + monitor(maxWait, timeUnit, deployMonitor, vms); + } - @Override - public void awaitCompletionUndeploy(final VirtualMachine... vms) - { - awaitCompletion(undeployMonitor, vms); - } + @Override + public void awaitCompletionUndeploy(final VirtualMachine... vms) { + awaitCompletion(undeployMonitor, vms); + } - @Override - public void monitorUndeploy(final VirtualMachine... vms) - { - monitor(undeployMonitor, vms); - } + @Override + public void monitorUndeploy(final VirtualMachine... vms) { + monitor(undeployMonitor, vms); + } - @Override - public void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms) - { - awaitCompletion(maxWait, timeUnit, undeployMonitor, vms); - } + @Override + public void awaitCompletionUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms) { + awaitCompletion(maxWait, timeUnit, undeployMonitor, vms); + } - @Override - public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachine... vms) - { - monitor(maxWait, timeUnit, undeployMonitor, vms); - } + @Override + public void monitorUndeploy(final Long maxWait, final TimeUnit timeUnit, final VirtualMachine... vms) { + monitor(maxWait, timeUnit, undeployMonitor, vms); + } - @Override - public void awaitState(final VirtualMachineState state, final VirtualMachine... vms) - { - awaitCompletion(new VirtualMachineStateMonitor(state), vms); - } + @Override + public void awaitState(final VirtualMachineState state, final VirtualMachine... vms) { + awaitCompletion(new VirtualMachineStateMonitor(state), vms); + } - @Override - public void monitorState(final VirtualMachineState state, final VirtualMachine... vms) - { - monitor(new VirtualMachineStateMonitor(state), vms); - } + @Override + public void monitorState(final VirtualMachineState state, final VirtualMachine... vms) { + monitor(new VirtualMachineStateMonitor(state), vms); + } - @Override - public void awaitState(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachineState state, final VirtualMachine... vms) - { - awaitCompletion(maxWait, timeUnit, new VirtualMachineStateMonitor(state), vms); - } + @Override + public void awaitState(final Long maxWait, final TimeUnit timeUnit, final VirtualMachineState state, + final VirtualMachine... vms) { + awaitCompletion(maxWait, timeUnit, new VirtualMachineStateMonitor(state), vms); + } - @Override - public void monitorState(final Long maxWait, final TimeUnit timeUnit, - final VirtualMachineState state, final VirtualMachine... vms) - { - monitor(maxWait, timeUnit, new VirtualMachineStateMonitor(state), vms); - } + @Override + public void monitorState(final Long maxWait, final TimeUnit timeUnit, final VirtualMachineState state, + final VirtualMachine... vms) { + monitor(maxWait, timeUnit, new VirtualMachineStateMonitor(state), vms); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java index 33000480bd..2a5f2c427b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/ErrorPredicates.java @@ -31,19 +31,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class ErrorPredicates -{ - public static Predicate code(final String... codes) - { - checkNotNull(codes, "codes must be defined"); +public class ErrorPredicates { + public static Predicate code(final String... codes) { + checkNotNull(codes, "codes must be defined"); - return new Predicate() - { - @Override - public boolean apply(final ErrorDto error) - { - return Arrays.asList(codes).contains(error.getCode()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final ErrorDto error) { + return Arrays.asList(codes).contains(error.getCode()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java index e10be2952b..bd512284ae 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java @@ -31,31 +31,24 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class LinkPredicates -{ - public static Predicate rel(final String... rels) - { - checkNotNull(rels, "rels must be defined"); +public class LinkPredicates { + public static Predicate rel(final String... rels) { + checkNotNull(rels, "rels must be defined"); - return new Predicate() - { - @Override - public boolean apply(final RESTLink link) - { - return Arrays.asList(rels).contains(link.getRel()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final RESTLink link) { + return Arrays.asList(rels).contains(link.getRel()); + } + }; + } - public static Predicate isNic() - { - return new Predicate() - { - @Override - public boolean apply(final RESTLink link) - { - return link.getRel().matches("^nic[0-9]+$"); - } - }; - } + public static Predicate isNic() { + return new Predicate() { + @Override + public boolean apply(final RESTLink link) { + return link.getRel().matches("^nic[0-9]+$"); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java index 69594942ee..14379d9cd7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/ConversionPredicates.java @@ -36,63 +36,50 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class ConversionPredicates -{ +public class ConversionPredicates { - public static Predicate sourceFormat(final DiskFormatType... formats) - { - checkNotNull(formats, "formats must be defined"); + public static Predicate sourceFormat(final DiskFormatType... formats) { + checkNotNull(formats, "formats must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Conversion conversion) - { - return Arrays.asList(formats).contains(conversion.getSourceFormat()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Conversion conversion) { + return Arrays.asList(formats).contains(conversion.getSourceFormat()); + } + }; + } - public static Predicate targetFormat(final DiskFormatType... formats) - { - checkNotNull(formats, "formats must be defined"); + public static Predicate targetFormat(final DiskFormatType... formats) { + checkNotNull(formats, "formats must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Conversion conversion) - { - return Arrays.asList(formats).contains(conversion.getTargetFormat()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Conversion conversion) { + return Arrays.asList(formats).contains(conversion.getTargetFormat()); + } + }; + } - public static Predicate state(final ConversionState... states) - { - checkNotNull(states, "states must be defined"); + public static Predicate state(final ConversionState... states) { + checkNotNull(states, "states must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Conversion conversion) - { - return Arrays.asList(states).contains(conversion.getState()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Conversion conversion) { + return Arrays.asList(states).contains(conversion.getState()); + } + }; + } - public static Predicate compatible(final HypervisorType type) - { - checkNotNull(type, "type must be defined"); + public static Predicate compatible(final HypervisorType type) { + checkNotNull(type, "type must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Conversion conversion) - { - return type.isCompatible(conversion.getTargetFormat()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Conversion conversion) { + return type.isCompatible(conversion.getTargetFormat()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java index 22b2f53d7c..35b5cba0b6 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualAppliancePredicates.java @@ -33,33 +33,26 @@ import com.google.common.base.Predicate; * * @author Serafín Sedano */ -public class VirtualAppliancePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class VirtualAppliancePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualAppliance virtualAppliance) - { - return Arrays.asList(names).contains(virtualAppliance.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualAppliance virtualAppliance) { + return Arrays.asList(names).contains(virtualAppliance.getName()); + } + }; + } - public static Predicate state(final VirtualApplianceState... states) - { - checkNotNull(states, "states must be defined"); + public static Predicate state(final VirtualApplianceState... states) { + checkNotNull(states, "states must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualAppliance virtualAppliance) - { - return Arrays.asList(states).contains(virtualAppliance.getState()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualAppliance virtualAppliance) { + return Arrays.asList(states).contains(virtualAppliance.getState()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java index 5cb2aacd94..81f3b4956a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualDatacenterPredicates.java @@ -43,94 +43,75 @@ import com.google.common.collect.Lists; * * @author Ignasi Barrera */ -public class VirtualDatacenterPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class VirtualDatacenterPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualDatacenter virtualDatacenter) - { - return Arrays.asList(names).contains(virtualDatacenter.getName()); + return new Predicate() { + @Override + public boolean apply(final VirtualDatacenter virtualDatacenter) { + return Arrays.asList(names).contains(virtualDatacenter.getName()); + } + }; + } + + public static Predicate type(final HypervisorType... types) { + checkNotNull(types, "types must be defined"); + + return new Predicate() { + @Override + public boolean apply(final VirtualDatacenter virtualDatacenter) { + return Arrays.asList(types).contains(virtualDatacenter.getHypervisorType()); + } + }; + } + + public static Predicate datacenter(final Datacenter... datacenters) { + checkNotNull(datacenters, "datacenters must be defined"); + + final List ids = Lists.newArrayList(transform(Arrays.asList(datacenters), + new Function() { + @Override + public Integer apply(final Datacenter input) { + return input.getId(); + } + })); + + return new Predicate() { + @Override + public boolean apply(final VirtualDatacenter virtualDatacenter) { + // Avoid using the getDatacenter() method since it will generate an + // unnecessary API + // call. We can get the ID from the datacenter link. + Integer datacenterId = checkNotNull(virtualDatacenter.unwrap().getIdFromLink(ParentLinkName.DATACENTER), + ValidationErrors.MISSING_REQUIRED_LINK); + + return ids.contains(datacenterId); + } + }; + } + + /** + * Check if the given template type is compatible with the given virtual + * datacenter type taking into account the conversions of the template. + * + * @param template + * The template to check. + * @return Predicate to check if the template or its conversions are + * compatibles with the given virtual datacenter. + */ + public static Predicate compatibleWithTemplateOrConversions(final VirtualMachineTemplate template) { + return new Predicate() { + @Override + public boolean apply(final VirtualDatacenter vdc) { + HypervisorType type = vdc.getHypervisorType(); + boolean compatible = type.isCompatible(template.getDiskFormatType()); + if (!compatible) { + List compatibleConversions = template.listConversions(type, ConversionState.FINISHED); + compatible = compatibleConversions != null && !compatibleConversions.isEmpty(); } - }; - } - - public static Predicate type(final HypervisorType... types) - { - checkNotNull(types, "types must be defined"); - - return new Predicate() - { - @Override - public boolean apply(final VirtualDatacenter virtualDatacenter) - { - return Arrays.asList(types).contains(virtualDatacenter.getHypervisorType()); - } - }; - } - - public static Predicate datacenter(final Datacenter... datacenters) - { - checkNotNull(datacenters, "datacenters must be defined"); - - final List ids = - Lists.newArrayList(transform(Arrays.asList(datacenters), - new Function() - { - @Override - public Integer apply(final Datacenter input) - { - return input.getId(); - } - })); - - return new Predicate() - { - @Override - public boolean apply(final VirtualDatacenter virtualDatacenter) - { - // Avoid using the getDatacenter() method since it will generate an unnecessary API - // call. We can get the ID from the datacenter link. - Integer datacenterId = - checkNotNull(virtualDatacenter.unwrap() - .getIdFromLink(ParentLinkName.DATACENTER), - ValidationErrors.MISSING_REQUIRED_LINK); - - return ids.contains(datacenterId); - } - }; - } - - /** - * Check if the given template type is compatible with the given virtual datacenter type taking - * into account the conversions of the template. - * - * @param template The template to check. - * @return Predicate to check if the template or its conversions are compatibles with the given - * virtual datacenter. - */ - public static Predicate compatibleWithTemplateOrConversions( - final VirtualMachineTemplate template) - { - return new Predicate() - { - @Override - public boolean apply(final VirtualDatacenter vdc) - { - HypervisorType type = vdc.getHypervisorType(); - boolean compatible = type.isCompatible(template.getDiskFormatType()); - if (!compatible) - { - List compatibleConversions = - template.listConversions(type, ConversionState.FINISHED); - compatible = compatibleConversions != null && !compatibleConversions.isEmpty(); - } - return compatible; - } - }; - } + return compatible; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java index 34ae673fd4..bc2c95e17e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachinePredicates.java @@ -33,48 +33,38 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class VirtualMachinePredicates -{ - public static Predicate internalName(final String... internalName) - { - checkNotNull(internalName, "names must be defined"); +public class VirtualMachinePredicates { + public static Predicate internalName(final String... internalName) { + checkNotNull(internalName, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachine virtualMachine) - { - return Arrays.asList(internalName).contains(virtualMachine.getInternalName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachine virtualMachine) { + return Arrays.asList(internalName).contains(virtualMachine.getInternalName()); + } + }; + } - public static Predicate nameLabel(final String... nameLabels) - { - checkNotNull(nameLabels, "names must be defined"); + public static Predicate nameLabel(final String... nameLabels) { + checkNotNull(nameLabels, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachine virtualMachine) - { - return Arrays.asList(nameLabels).contains(virtualMachine.getNameLabel()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachine virtualMachine) { + return Arrays.asList(nameLabels).contains(virtualMachine.getNameLabel()); + } + }; + } - public static Predicate state(final VirtualMachineState... states) - { - checkNotNull(states, "states must be defined"); + public static Predicate state(final VirtualMachineState... states) { + checkNotNull(states, "states must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachine virtualMachine) - { - // The getState() method will generate an API call - return Arrays.asList(states).contains(virtualMachine.getState()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachine virtualMachine) { + // The getState() method will generate an API call + return Arrays.asList(states).contains(virtualMachine.getState()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java index be3c372a0d..c3277da44b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VirtualMachineTemplatePredicates.java @@ -34,85 +34,66 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class VirtualMachineTemplatePredicates -{ - public static Predicate id(final Integer... ids) - { - checkNotNull(ids, "ids must be defined"); +public class VirtualMachineTemplatePredicates { + public static Predicate id(final Integer... ids) { + checkNotNull(ids, "ids must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate template) - { - return Arrays.asList(ids).contains(template.getId()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate template) { + return Arrays.asList(ids).contains(template.getId()); + } + }; + } - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate template) - { - return Arrays.asList(names).contains(template.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate template) { + return Arrays.asList(names).contains(template.getName()); + } + }; + } - public static Predicate diskFormat(final DiskFormatType... formats) - { - checkNotNull(formats, "formats must be defined"); + public static Predicate diskFormat(final DiskFormatType... formats) { + checkNotNull(formats, "formats must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate template) - { - return Arrays.asList(formats).contains(template.getDiskFormatType()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate template) { + return Arrays.asList(formats).contains(template.getDiskFormatType()); + } + }; + } - public static Predicate compatible(final HypervisorType type) - { - checkNotNull(type, "type must be defined"); + public static Predicate compatible(final HypervisorType type) { + checkNotNull(type, "type must be defined"); - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate template) - { - return type.isCompatible(template.getDiskFormatType()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate template) { + return type.isCompatible(template.getDiskFormatType()); + } + }; + } - public static Predicate isShared() - { - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate input) - { - return input.unwrap().isShared(); - } - }; - } + public static Predicate isShared() { + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate input) { + return input.unwrap().isShared(); + } + }; + } - public static Predicate isInstance() - { - return new Predicate() - { - @Override - public boolean apply(final VirtualMachineTemplate input) - { - return input.unwrap().searchLink("master") != null; - } - }; - } + public static Predicate isInstance() { + return new Predicate() { + @Override + public boolean apply(final VirtualMachineTemplate input) { + return input.unwrap().searchLink("master") != null; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java index afebcb6004..0b012a664b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/cloud/VolumePredicates.java @@ -34,71 +34,56 @@ import com.google.common.base.Predicates; * * @author Ignasi Barrera */ -public class VolumePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class VolumePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Volume volume) - { - return Arrays.asList(names).contains(volume.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Volume volume) { + return Arrays.asList(names).contains(volume.getName()); + } + }; + } - public static Predicate greaterThan(final long sizeInMb) - { - checkNotNull(sizeInMb, "sizeInMb must be defined"); + public static Predicate greaterThan(final long sizeInMb) { + checkNotNull(sizeInMb, "sizeInMb must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Volume volume) - { - return volume.getSizeInMB() > sizeInMb; - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Volume volume) { + return volume.getSizeInMB() > sizeInMb; + } + }; + } - public static Predicate greaterThanOrEqual(final long sizeInMb) - { - checkNotNull(sizeInMb, "sizeInMb must be defined"); + public static Predicate greaterThanOrEqual(final long sizeInMb) { + checkNotNull(sizeInMb, "sizeInMb must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Volume volume) - { - return volume.getSizeInMB() >= sizeInMb; - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Volume volume) { + return volume.getSizeInMB() >= sizeInMb; + } + }; + } - public static Predicate lesserThan(final long sizeInMb) - { - return Predicates.not(greaterThanOrEqual(sizeInMb)); - } + public static Predicate lesserThan(final long sizeInMb) { + return Predicates.not(greaterThanOrEqual(sizeInMb)); + } - public static Predicate lesserThanOrEquals(final long sizeInMb) - { - return Predicates.not(greaterThan(sizeInMb)); - } + public static Predicate lesserThanOrEquals(final long sizeInMb) { + return Predicates.not(greaterThan(sizeInMb)); + } - public static Predicate state(final VolumeState... states) - { - checkNotNull(states, "states must be defined"); + public static Predicate state(final VolumeState... states) { + checkNotNull(states, "states must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Volume volume) - { - return Arrays.asList(states).contains(VolumeState.valueOf(volume.getState())); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Volume volume) { + return Arrays.asList(states).contains(VolumeState.valueOf(volume.getState())); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java index 04bed94d9c..0d172a4970 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/CategoryPredicates.java @@ -33,20 +33,16 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class CategoryPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class CategoryPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Category category) - { - return Arrays.asList(names).contains(category.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Category category) { + return Arrays.asList(names).contains(category.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java index d99705f8a6..a845cc26be 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/LicensePredicates.java @@ -32,33 +32,26 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class LicensePredicates -{ - public static Predicate customer(final String... customerIds) - { - checkNotNull(customerIds, "customers must be defined"); +public class LicensePredicates { + public static Predicate customer(final String... customerIds) { + checkNotNull(customerIds, "customers must be defined"); - return new Predicate() - { - @Override - public boolean apply(final License license) - { - return Arrays.asList(customerIds).contains(license.getCustomerId()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final License license) { + return Arrays.asList(customerIds).contains(license.getCustomerId()); + } + }; + } - public static Predicate code(final String... codes) - { - checkNotNull(codes, "customers must be defined"); + public static Predicate code(final String... codes) { + checkNotNull(codes, "customers must be defined"); - return new Predicate() - { - @Override - public boolean apply(final License license) - { - return Arrays.asList(codes).contains(license.getCode()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final License license) { + return Arrays.asList(codes).contains(license.getCode()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java index 29b2a78807..cbeda4c360 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PricingPredicates.java @@ -35,47 +35,37 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Susana Acedo */ -public class PricingPredicates -{ - public static Predicate currency(final String... names) - { - checkNotNull(names, "names must be defined"); +public class PricingPredicates { + public static Predicate currency(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Currency currency) - { - return Arrays.asList(names).contains(currency.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Currency currency) { + return Arrays.asList(names).contains(currency.getName()); + } + }; + } - public static Predicate costCode(final String... names) - { - checkNotNull(names, "names must be defined"); + public static Predicate costCode(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final CostCode costcode) - { - return Arrays.asList(names).contains(costcode.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final CostCode costcode) { + return Arrays.asList(names).contains(costcode.getName()); + } + }; + } - public static Predicate pricingTemplate(final String... names) - { - checkNotNull(names, "names must be defined"); + public static Predicate pricingTemplate(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final PricingTemplate pricingTemplate) - { - return Arrays.asList(names).contains(pricingTemplate.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final PricingTemplate pricingTemplate) { + return Arrays.asList(names).contains(pricingTemplate.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java index 20f9ca846b..93e4510915 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/PrivilegePredicates.java @@ -32,20 +32,16 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class PrivilegePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class PrivilegePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Privilege privilege) - { - return Arrays.asList(names).contains(privilege.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Privilege privilege) { + return Arrays.asList(names).contains(privilege.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java index b5fc62de2a..b0b04aaa5d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/config/SystemPropertyPredicates.java @@ -33,20 +33,16 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class SystemPropertyPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class SystemPropertyPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final SystemProperty property) - { - return Arrays.asList(names).contains(property.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final SystemProperty property) { + return Arrays.asList(names).contains(property.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java index c411e82ec3..b7eaf33234 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/EnterprisePredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class EnterprisePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class EnterprisePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Enterprise enterprise) - { - return Arrays.asList(names).contains(enterprise.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Enterprise enterprise) { + return Arrays.asList(names).contains(enterprise.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java index 1cd895c255..0226f12263 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/RolePredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class RolePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class RolePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Role role) - { - return Arrays.asList(names).contains(role.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Role role) { + return Arrays.asList(names).contains(role.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java index 1039d893c5..5cd228a3c2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/TemplateDefinitionListPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class TemplateDefinitionListPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class TemplateDefinitionListPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final TemplateDefinitionList templateList) - { - return Arrays.asList(names).contains(templateList.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final TemplateDefinitionList templateList) { + return Arrays.asList(names).contains(templateList.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java index 8a3823f1db..d910d345c0 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/enterprise/UserPredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class UserPredicates -{ - public static Predicate nick(final String... nicks) - { - checkNotNull(nicks, "nicks must be defined"); +public class UserPredicates { + public static Predicate nick(final String... nicks) { + checkNotNull(nicks, "nicks must be defined"); - return new Predicate() - { - @Override - public boolean apply(final User user) - { - return Arrays.asList(nicks).contains(user.getNick()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final User user) { + return Arrays.asList(nicks).contains(user.getNick()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java index 304ed26931..5e857b2f5a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/BladePredicates.java @@ -33,38 +33,30 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class BladePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "name must be defined"); +public class BladePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "name must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Blade machine) - { - return Arrays.asList(names).contains(machine.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Blade machine) { + return Arrays.asList(names).contains(machine.getName()); + } + }; + } - public static Predicate ip(final String ip) - { - return ips(checkNotNull(ip, "ip must be defined")); - } + public static Predicate ip(final String ip) { + return ips(checkNotNull(ip, "ip must be defined")); + } - public static Predicate ips(final String... ips) - { - checkNotNull(ips, "ips must be defined"); + public static Predicate ips(final String... ips) { + checkNotNull(ips, "ips must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Blade machine) - { - return Arrays.asList(ips).contains(machine.getIp()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Blade machine) { + return Arrays.asList(ips).contains(machine.getIp()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java index d3febc3a74..f68b40d325 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatacenterPredicates.java @@ -32,47 +32,37 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class DatacenterPredicates -{ - public static Predicate id(final Integer... ids) - { - checkNotNull(ids, "ids must be defined"); +public class DatacenterPredicates { + public static Predicate id(final Integer... ids) { + checkNotNull(ids, "ids must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Datacenter datacenter) - { - return Arrays.asList(ids).contains(datacenter.getId()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Datacenter datacenter) { + return Arrays.asList(ids).contains(datacenter.getId()); + } + }; + } - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Datacenter datacenter) - { - return Arrays.asList(names).contains(datacenter.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Datacenter datacenter) { + return Arrays.asList(names).contains(datacenter.getName()); + } + }; + } - public static Predicate location(final String... locations) - { - checkNotNull(locations, "locations must be defined"); + public static Predicate location(final String... locations) { + checkNotNull(locations, "locations must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Datacenter datacenter) - { - return Arrays.asList(locations).contains(datacenter.getLocation()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Datacenter datacenter) { + return Arrays.asList(locations).contains(datacenter.getLocation()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java index d094594ce4..ff135d7494 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/DatastorePredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class DatastorePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class DatastorePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Datastore datastore) - { - return Arrays.asList(names).contains(datastore.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Datastore datastore) { + return Arrays.asList(names).contains(datastore.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java index 09ad31fe6f..07cbca22fc 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/HypervisorPredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class HypervisorPredicates -{ - public static Predicate type(final HypervisorType... types) - { - checkNotNull(types, "types must be defined"); +public class HypervisorPredicates { + public static Predicate type(final HypervisorType... types) { + checkNotNull(types, "types must be defined"); - return new Predicate() - { - @Override - public boolean apply(final HypervisorType type) - { - return Arrays.asList(types).contains(type); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final HypervisorType type) { + return Arrays.asList(types).contains(type); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java index 4ec5bc253e..d185b08283 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/LogicServerPredicates.java @@ -32,19 +32,15 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class LogicServerPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class LogicServerPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final LogicServer logicServer) - { - return Arrays.asList(names).contains(logicServer.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final LogicServer logicServer) { + return Arrays.asList(names).contains(logicServer.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java index 8857f8ad03..f7bfb3add7 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/MachinePredicates.java @@ -33,38 +33,30 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class MachinePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "name must be defined"); +public class MachinePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "name must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Machine machine) - { - return Arrays.asList(names).contains(machine.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Machine machine) { + return Arrays.asList(names).contains(machine.getName()); + } + }; + } - public static Predicate ip(final String ip) - { - return ips(checkNotNull(ip, "ip must be defined")); - } + public static Predicate ip(final String ip) { + return ips(checkNotNull(ip, "ip must be defined")); + } - public static Predicate ips(final String... ips) - { - checkNotNull(ips, "ips must be defined"); + public static Predicate ips(final String... ips) { + checkNotNull(ips, "ips must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Machine machine) - { - return Arrays.asList(ips).contains(machine.getIp()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Machine machine) { + return Arrays.asList(ips).contains(machine.getIp()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java index fcd5401bb7..51b6771cb2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/ManagedRackPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class ManagedRackPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class ManagedRackPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final ManagedRack rack) - { - return Arrays.asList(names).contains(rack.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final ManagedRack rack) { + return Arrays.asList(names).contains(rack.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java index d2ed7de199..9b418632bf 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RackPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class RackPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class RackPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Rack rack) - { - return Arrays.asList(names).contains(rack.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Rack rack) { + return Arrays.asList(names).contains(rack.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java index 64b7c403f5..8b7cf7daaa 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/RemoteServicePredicates.java @@ -34,19 +34,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class RemoteServicePredicates -{ - public static Predicate type(final RemoteServiceType... types) - { - checkNotNull(types, "types must be defined"); +public class RemoteServicePredicates { + public static Predicate type(final RemoteServiceType... types) { + checkNotNull(types, "types must be defined"); - return new Predicate() - { - @Override - public boolean apply(final RemoteService remoteService) - { - return Arrays.asList(types).contains(remoteService.getType()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final RemoteService remoteService) { + return Arrays.asList(types).contains(remoteService.getType()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java index e4971f095a..52ce2106e4 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDeviceMetadataPredicates.java @@ -32,20 +32,16 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class StorageDeviceMetadataPredicates -{ +public class StorageDeviceMetadataPredicates { - public static Predicate type(final String... types) - { - checkNotNull(types, "types must be defined"); + public static Predicate type(final String... types) { + checkNotNull(types, "types must be defined"); - return new Predicate() - { - @Override - public boolean apply(final StorageDeviceMetadata metadata) - { - return Arrays.asList(types).contains(metadata.getType()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final StorageDeviceMetadata metadata) { + return Arrays.asList(types).contains(metadata.getType()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java index 1a0e6a2ea8..e957057205 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StorageDevicePredicates.java @@ -33,47 +33,37 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class StorageDevicePredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class StorageDevicePredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final StorageDevice storageDevice) - { - return Arrays.asList(names).contains(storageDevice.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final StorageDevice storageDevice) { + return Arrays.asList(names).contains(storageDevice.getName()); + } + }; + } - public static Predicate managementIp(final String... ips) - { - checkNotNull(ips, "managementIps must be defined"); + public static Predicate managementIp(final String... ips) { + checkNotNull(ips, "managementIps must be defined"); - return new Predicate() - { - @Override - public boolean apply(final StorageDevice storageDevice) - { - return Arrays.asList(ips).contains(storageDevice.getManagementIp()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final StorageDevice storageDevice) { + return Arrays.asList(ips).contains(storageDevice.getManagementIp()); + } + }; + } - public static Predicate type(final String... types) - { - checkNotNull(types, "types must be defined"); + public static Predicate type(final String... types) { + checkNotNull(types, "types must be defined"); - return new Predicate() - { - @Override - public boolean apply(final StorageDevice storageDevice) - { - return Arrays.asList(types).contains(storageDevice.getType()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final StorageDevice storageDevice) { + return Arrays.asList(types).contains(storageDevice.getType()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java index 5363664a09..7cfc033c5e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/StoragePoolPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class StoragePoolPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class StoragePoolPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final StoragePool storagePool) - { - return Arrays.asList(names).contains(storagePool.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final StoragePool storagePool) { + return Arrays.asList(names).contains(storagePool.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java index 66414ce759..7ae1047b47 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/infrastructure/TierPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class TierPredicates -{ - public static Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class TierPredicates { + public static Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Tier tier) - { - return Arrays.asList(names).contains(tier.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Tier tier) { + return Arrays.asList(names).contains(tier.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java index b05947c24f..38aa9f2393 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/IpPredicates.java @@ -34,57 +34,44 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class IpPredicates -{ - public static > Predicate name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class IpPredicates { + public static > Predicate name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate() - { - @Override - public boolean apply(final T address) - { - return Arrays.asList(names).contains(address.getName()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final T address) { + return Arrays.asList(names).contains(address.getName()); + } + }; + } - public static > Predicate address(final String... addresses) - { - checkNotNull(addresses, "addresses must be defined"); + public static > Predicate address(final String... addresses) { + checkNotNull(addresses, "addresses must be defined"); - return new Predicate() - { - @Override - public boolean apply(final T address) - { - return Arrays.asList(addresses).contains(address.getIp()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final T address) { + return Arrays.asList(addresses).contains(address.getIp()); + } + }; + } - public static > Predicate available() - { - return new Predicate() - { - @Override - public boolean apply(final T address) - { - return address.isAvailable(); - } - }; - } + public static > Predicate available() { + return new Predicate() { + @Override + public boolean apply(final T address) { + return address.isAvailable(); + } + }; + } - public static > Predicate notUsed() - { - return new Predicate() - { - @Override - public boolean apply(final T address) - { - return address.unwrap().searchLink("virtualmachine") == null; - } - }; - } + public static > Predicate notUsed() { + return new Predicate() { + @Override + public boolean apply(final T address) { + return address.unwrap().searchLink("virtualmachine") == null; + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java index eb22fdba77..440d829c73 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NetworkPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class NetworkPredicates -{ - public static > Predicate> name(final String... names) - { - checkNotNull(names, "names must be defined"); +public class NetworkPredicates { + public static > Predicate> name(final String... names) { + checkNotNull(names, "names must be defined"); - return new Predicate>() - { - @Override - public boolean apply(final Network network) - { - return Arrays.asList(names).contains(network.getName()); - } - }; - } + return new Predicate>() { + @Override + public boolean apply(final Network network) { + return Arrays.asList(names).contains(network.getName()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java index 6df89c4c28..35477fb91f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/network/NicPredicates.java @@ -32,33 +32,26 @@ import com.google.common.base.Predicate; * * @author Francesc Montserrat */ -public class NicPredicates -{ - public static Predicate ip(final String... ips) - { - checkNotNull(ips, "ips must be defined"); +public class NicPredicates { + public static Predicate ip(final String... ips) { + checkNotNull(ips, "ips must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Nic nic) - { - return Arrays.asList(ips).contains(nic.getIp()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Nic nic) { + return Arrays.asList(ips).contains(nic.getIp()); + } + }; + } - public static Predicate mac(final String... macs) - { - checkNotNull(macs, "macs must be defined"); + public static Predicate mac(final String... macs) { + checkNotNull(macs, "macs must be defined"); - return new Predicate() - { - @Override - public boolean apply(final Nic nic) - { - return Arrays.asList(macs).contains(nic.getMac()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final Nic nic) { + return Arrays.asList(macs).contains(nic.getMac()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java index 7f0f685007..73c74f0711 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/predicates/task/AsyncTaskPredicates.java @@ -33,19 +33,15 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public class AsyncTaskPredicates -{ - public static Predicate state(final TaskState... states) - { - checkNotNull(states, "states must be defined"); +public class AsyncTaskPredicates { + public static Predicate state(final TaskState... states) { + checkNotNull(states, "states must be defined"); - return new Predicate() - { - @Override - public boolean apply(final AsyncTask task) - { - return Arrays.asList(states).contains(task.getState()); - } - }; - } + return new Predicate() { + @Override + public boolean apply(final AsyncTask task) { + return Arrays.asList(states).contains(task.getState()); + } + }; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/ValidationErrors.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/ValidationErrors.java index 1f3ce1cdf2..7b04c84a25 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/ValidationErrors.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/ValidationErrors.java @@ -24,14 +24,13 @@ package org.jclouds.abiquo.reference; * * @author Francesc Montserrat */ -public class ValidationErrors -{ - public static final String NULL_RESOURCE = "The resource should be assigned to a "; +public class ValidationErrors { + public static final String NULL_RESOURCE = "The resource should be assigned to a "; - public static final String MISSING_REQUIRED_FIELD = "Missing required field "; + public static final String MISSING_REQUIRED_FIELD = "Missing required field "; - public static final String MISSING_REQUIRED_LINK = "Missing required link "; + public static final String MISSING_REQUIRED_LINK = "Missing required link "; - public static final String INVALID_NETWORK_TYPE = "Invalid network type "; + public static final String INVALID_NETWORK_TYPE = "Invalid network type "; } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/annotations/EnterpriseEdition.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/annotations/EnterpriseEdition.java index 9862629444..4513c0ffd2 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/annotations/EnterpriseEdition.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/annotations/EnterpriseEdition.java @@ -23,13 +23,12 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** - * Indicates that the annotated element will access Abiquo Enterprise Edition functionallity. If the - * target Abiquo Cloud platform is a Community Edition version, the invocation of the method may - * have unexpected results. + * Indicates that the annotated element will access Abiquo Enterprise Edition + * functionallity. If the target Abiquo Cloud platform is a Community Edition + * version, the invocation of the method may have unexpected results. * * @author Ignasi Barrera */ @Retention(RetentionPolicy.RUNTIME) -public @interface EnterpriseEdition -{ +public @interface EnterpriseEdition { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java index 9db695adcf..416b6d690f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/reference/rest/ParentLinkName.java @@ -24,43 +24,42 @@ package org.jclouds.abiquo.reference.rest; * * @author Francesc Montserrat */ -public class ParentLinkName -{ - public final static String RACK = "rack"; +public class ParentLinkName { + public final static String RACK = "rack"; - public final static String DATACENTER = "datacenter"; + public final static String DATACENTER = "datacenter"; - public final static String ENTERPRISE = "enterprise"; + public final static String ENTERPRISE = "enterprise"; - public final static String ROLE = "role"; + public final static String ROLE = "role"; - public final static String TIER = "tier"; + public final static String TIER = "tier"; - public final static String STORAGE_DEVICE = "device"; + public final static String STORAGE_DEVICE = "device"; - public final static String VIRTUAL_DATACENTER = "virtualdatacenter"; + public final static String VIRTUAL_DATACENTER = "virtualdatacenter"; - public final static String VIRTUAL_APPLIANCE = "virtualappliance"; + public final static String VIRTUAL_APPLIANCE = "virtualappliance"; - public final static String VIRTUAL_MACHINE_TEMPLATE = "virtualmachinetemplate"; + public final static String VIRTUAL_MACHINE_TEMPLATE = "virtualmachinetemplate"; - public final static String DATACENTER_REPOSITORY = "datacenterrepository"; + public final static String DATACENTER_REPOSITORY = "datacenterrepository"; - public final static String COST_CODE = "costcode"; + public final static String COST_CODE = "costcode"; - public final static String CATEGORY = "category"; + public final static String CATEGORY = "category"; - public final static String ICON = "icon"; + public final static String ICON = "icon"; - public final static String PRIVATE_NETWORK = "privatenetwork"; + public final static String PRIVATE_NETWORK = "privatenetwork"; - public final static String PUBLIC_NETWORK = "publicnetwork"; + public final static String PUBLIC_NETWORK = "publicnetwork"; - public final static String EXTERNAL_NETWORK = "externalnetwork"; + public final static String EXTERNAL_NETWORK = "externalnetwork"; - public final static String UNMANAGED_NETWORK = "unmanagednetwork"; + public final static String UNMANAGED_NETWORK = "unmanagednetwork"; - public final static String NETWORK_CONFIGURATIONS = "configurations"; + public final static String NETWORK_CONFIGURATIONS = "configurations"; - public final static String NETWORK_GATEWAY = "network_configuration"; + public final static String NETWORK_GATEWAY = "network_configuration"; } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/annotations/EndpointLink.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/annotations/EndpointLink.java index f32d6b0f26..d87b2315da 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/annotations/EndpointLink.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/annotations/EndpointLink.java @@ -29,13 +29,12 @@ import java.lang.annotation.Target; * * @author Ignasi Barrera */ -@Target({ElementType.PARAMETER}) +@Target({ ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME) -public @interface EndpointLink -{ +public @interface EndpointLink { - /** - * The name of the link that will be used to generate the request endpoint. - */ - String value(); + /** + * The name of the link that will be used to generate the request endpoint. + */ + String value(); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClient.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClient.java index 6ffd12a01c..16da2e5f4b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClient.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClient.java @@ -38,14 +38,12 @@ import com.google.common.util.concurrent.ListenableFuture; * * @author Ignasi Barrera */ -@RequestFilters({AbiquoAuthentication.class, AppendApiVersionToMediaType.class}) -public interface AbiquoHttpAsyncClient -{ - /** - * @see AbiquoHttpClient#get(RESTLink) - */ - @GET - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - public ListenableFuture get( - @BinderParam(BindLinkToPathAndAcceptHeader.class) final RESTLink link); +@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) +public interface AbiquoHttpAsyncClient { + /** + * @see AbiquoHttpClient#get(RESTLink) + */ + @GET + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + public ListenableFuture get(@BinderParam(BindLinkToPathAndAcceptHeader.class) final RESTLink link); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpClient.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpClient.java index 1e51824460..9b42778976 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpClient.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/AbiquoHttpClient.java @@ -32,13 +32,13 @@ import com.abiquo.model.rest.RESTLink; * @author Ignasi Barrera */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface AbiquoHttpClient -{ - /** - * Perform a GET request to the given link. - * - * @param link The link to get. - * @return The response. - */ - public HttpResponse get(final RESTLink link); +public interface AbiquoHttpClient { + /** + * Perform a GET request to the given link. + * + * @param link + * The link to get. + * @return The response. + */ + public HttpResponse get(final RESTLink link); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/ExtendedUtils.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/ExtendedUtils.java index 13b95511d4..6dc4bff595 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/ExtendedUtils.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/rest/internal/ExtendedUtils.java @@ -49,36 +49,30 @@ import com.google.inject.Singleton; * @author Ignasi Barrera */ @Singleton -public class ExtendedUtils extends UtilsImpl implements Utils -{ - private AbiquoHttpClient abiquoHttpClient; +public class ExtendedUtils extends UtilsImpl implements Utils { + private AbiquoHttpClient abiquoHttpClient; - private AbiquoHttpAsyncClient abiquoHttpAsyncApi; + private AbiquoHttpAsyncClient abiquoHttpAsyncApi; - @Inject - public ExtendedUtils(final Injector injector, final Json json, final XMLParser xml, - final HttpClient simpleApi, final HttpAsyncClient simpleAsyncApi, final Crypto encryption, - final DateService date, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userThreads, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) final ExecutorService ioThreads, - final EventBus eventBus, final Map credentialStore, - final LoggerFactory loggerFactory, final AbiquoHttpClient abiquoHttpClient, - final AbiquoHttpAsyncClient abiquoHttpAsyncApi) - { - super(injector, json, xml, simpleApi, simpleAsyncApi, encryption, date, userThreads, - ioThreads, eventBus, credentialStore, loggerFactory); - this.abiquoHttpClient = checkNotNull(abiquoHttpClient, "abiquoHttpClient"); - this.abiquoHttpAsyncApi = checkNotNull(abiquoHttpAsyncApi, "abiquoHttpAsyncApi"); - } + @Inject + public ExtendedUtils(final Injector injector, final Json json, final XMLParser xml, final HttpClient simpleApi, + final HttpAsyncClient simpleAsyncApi, final Crypto encryption, final DateService date, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userThreads, + @Named(Constants.PROPERTY_IO_WORKER_THREADS) final ExecutorService ioThreads, final EventBus eventBus, + final Map credentialStore, final LoggerFactory loggerFactory, + final AbiquoHttpClient abiquoHttpClient, final AbiquoHttpAsyncClient abiquoHttpAsyncApi) { + super(injector, json, xml, simpleApi, simpleAsyncApi, encryption, date, userThreads, ioThreads, eventBus, + credentialStore, loggerFactory); + this.abiquoHttpClient = checkNotNull(abiquoHttpClient, "abiquoHttpClient"); + this.abiquoHttpAsyncApi = checkNotNull(abiquoHttpAsyncApi, "abiquoHttpAsyncApi"); + } - public AbiquoHttpClient getAbiquoHttpClient() - { - return abiquoHttpClient; - } + public AbiquoHttpClient getAbiquoHttpClient() { + return abiquoHttpClient; + } - public AbiquoHttpAsyncClient getAbiquoHttpAsyncClient() - { - return abiquoHttpAsyncApi; - } + public AbiquoHttpAsyncClient getAbiquoHttpAsyncClient() { + return abiquoHttpAsyncApi; + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java index 16febd257f..2606517d02 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListEntities.java @@ -28,9 +28,8 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public interface ListEntities, P extends DomainWrapper< ? >> -{ - Iterable execute(P parent); +public interface ListEntities, P extends DomainWrapper> { + Iterable execute(P parent); - Iterable execute(P parent, Predicate selector); + Iterable execute(P parent, Predicate selector); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java index 5d05902c9b..255eb2f08d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/ListRootEntities.java @@ -28,9 +28,8 @@ import com.google.common.base.Predicate; * * @author Ignasi Barrera */ -public interface ListRootEntities> -{ - Iterable execute(); +public interface ListRootEntities> { + Iterable execute(); - Iterable execute(Predicate selector); + Iterable execute(Predicate selector); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java index f6922deb58..3ff98c1c7a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/ListRoles.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListRolesImpl.class) -public interface ListRoles extends ListRootEntities -{ +public interface ListRoles extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java index 81113484dd..0e6d5f0bf4 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListRolesImpl implements ListRoles -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListRolesImpl implements ListRoles { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListRolesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListRolesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - RolesDto result = context.getApi().getAdminApi().listRoles(); - return wrap(context, Role.class, result.getCollection()); - } + @Override + public Iterable execute() { + RolesDto result = context.getApi().getAdminApi().listRoles(); + return wrap(context, Role.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java index 97e751ba48..81e7aa4d95 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListAttachedNics.java @@ -32,7 +32,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListAttachedNicsImpl.class) -public interface ListAttachedNics extends ListEntities, VirtualMachine> -{ +public interface ListAttachedNics extends ListEntities, VirtualMachine> { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java index 10a9c5acc0..7d286175df 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualAppliances.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListVirtualAppliancesImpl.class) -public interface ListVirtualAppliances extends ListRootEntities -{ +public interface ListVirtualAppliances extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java index 7f2b7b0d32..88596af86b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualDatacenters.java @@ -35,13 +35,12 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListVirtualDatacentersImpl.class) -public interface ListVirtualDatacenters extends ListRootEntities -{ - Iterable execute(VirtualDatacenterOptions virtualDatacenterOptions); +public interface ListVirtualDatacenters extends ListRootEntities { + Iterable execute(VirtualDatacenterOptions virtualDatacenterOptions); - Iterable execute(List virtualDatacenterIds); + Iterable execute(List virtualDatacenterIds); - Iterable execute(Predicate selector, - VirtualDatacenterOptions virtualDatacenterOptions); + Iterable execute(Predicate selector, + VirtualDatacenterOptions virtualDatacenterOptions); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java index ba6f3864cb..9cdea47224 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/ListVirtualMachines.java @@ -32,7 +32,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListVirtualMachinesImpl.class) -public interface ListVirtualMachines extends ListRootEntities -{ - Iterable execute(VirtualMachineOptions options); +public interface ListVirtualMachines extends ListRootEntities { + Iterable execute(VirtualMachineOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java index cf3c16c62a..b577339fd8 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImpl.java @@ -57,82 +57,60 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Singleton -public class ListAttachedNicsImpl implements ListAttachedNics -{ - protected final RestContext context; +public class ListAttachedNicsImpl implements ListAttachedNics { + protected final RestContext context; - protected final ExtendedUtils extendedUtils; + protected final ExtendedUtils extendedUtils; - @Inject - public ListAttachedNicsImpl(final RestContext context, - final ExtendedUtils extendedUtils) - { - this.context = checkNotNull(context, "context"); - this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils"); - } + @Inject + public ListAttachedNicsImpl(final RestContext context, final ExtendedUtils extendedUtils) { + this.context = checkNotNull(context, "context"); + this.extendedUtils = checkNotNull(extendedUtils, "extendedUtils"); + } - @Override - public Iterable> execute(final VirtualMachine parent) - { - parent.refresh(); - Iterable nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks()); - return listIps(nicLinks); - } + @Override + public Iterable> execute(final VirtualMachine parent) { + parent.refresh(); + Iterable nicLinks = LinkUtils.filterNicLinks(parent.unwrap().getLinks()); + return listIps(nicLinks); + } - @Override - public Iterable> execute(final VirtualMachine parent, - final Predicate> selector) - { - return filter(execute(parent), selector); - } + @Override + public Iterable> execute(final VirtualMachine parent, final Predicate> selector) { + return filter(execute(parent), selector); + } - private Iterable> listIps(final Iterable nicLinks) - { - return transform(nicLinks, new Function>() - { - @Override - public Ip< ? , ? > apply(final RESTLink input) - { - HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input); + private Iterable> listIps(final Iterable nicLinks) { + return transform(nicLinks, new Function>() { + @Override + public Ip apply(final RESTLink input) { + HttpResponse response = extendedUtils.getAbiquoHttpClient().get(input); - if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) - { - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(extendedUtils.getXml(), TypeLiteral - .get(PrivateIpDto.class)); + if (input.getType().equals(PrivateIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(PrivateIpDto.class)); - return wrap(context, PrivateIp.class, parser.apply(response)); - } - else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) - { - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(extendedUtils.getXml(), TypeLiteral - .get(PublicIpDto.class)); + return wrap(context, PrivateIp.class, parser.apply(response)); + } else if (input.getType().equals(PublicIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(PublicIpDto.class)); - return wrap(context, PublicIp.class, parser.apply(response)); - } - else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) - { - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(extendedUtils.getXml(), TypeLiteral - .get(ExternalIpDto.class)); + return wrap(context, PublicIp.class, parser.apply(response)); + } else if (input.getType().equals(ExternalIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(ExternalIpDto.class)); - return wrap(context, ExternalIp.class, parser.apply(response)); - } - else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) - { - ParseXMLWithJAXB parser = - new ParseXMLWithJAXB(extendedUtils.getXml(), TypeLiteral - .get(UnmanagedIpDto.class)); + return wrap(context, ExternalIp.class, parser.apply(response)); + } else if (input.getType().equals(UnmanagedIpDto.BASE_MEDIA_TYPE)) { + ParseXMLWithJAXB parser = new ParseXMLWithJAXB(extendedUtils.getXml(), + TypeLiteral.get(UnmanagedIpDto.class)); - return wrap(context, UnmanagedIp.class, parser.apply(response)); - } - else - { - throw new IllegalArgumentException("Unsupported media type: " + input.getType()); - } + return wrap(context, UnmanagedIp.class, parser.apply(response)); + } else { + throw new IllegalArgumentException("Unsupported media type: " + input.getType()); } - }); - } + } + }); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java index 7c70d3a402..1d6025ed7f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImpl.java @@ -54,64 +54,53 @@ import com.google.inject.Inject; * @author Ignasi Barrera */ @Singleton -public class ListVirtualAppliancesImpl implements ListVirtualAppliances -{ - protected final RestContext context; +public class ListVirtualAppliancesImpl implements ListVirtualAppliances { + protected final RestContext context; - protected final ListVirtualDatacenters listVirtualDatacenters; + protected final ListVirtualDatacenters listVirtualDatacenters; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListVirtualAppliancesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListVirtualDatacenters listVirtualDatacenters) - { - this.context = checkNotNull(context, "context"); - this.listVirtualDatacenters = - checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListVirtualAppliancesImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, + final ListVirtualDatacenters listVirtualDatacenters) { + this.context = checkNotNull(context, "context"); + this.listVirtualDatacenters = checkNotNull(listVirtualDatacenters, "listVirtualDatacenters"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute() - { - // Find virtual appliances in concurrent requests - Iterable vdcs = listVirtualDatacenters.execute(); - Iterable vapps = listConcurrentVirtualAppliances(vdcs); + @Override + public Iterable execute() { + // Find virtual appliances in concurrent requests + Iterable vdcs = listVirtualDatacenters.execute(); + Iterable vapps = listConcurrentVirtualAppliances(vdcs); - return wrap(context, VirtualAppliance.class, vapps); - } + return wrap(context, VirtualAppliance.class, vapps); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - private Iterable listConcurrentVirtualAppliances( - final Iterable vdcs) - { - Iterable vapps = - transformParallel(vdcs, - new Function>() - { - @Override - public Future apply(final VirtualDatacenter input) - { - return context.getAsyncApi().getCloudApi() - .listVirtualAppliances(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting virtual appliances"); + private Iterable listConcurrentVirtualAppliances(final Iterable vdcs) { + Iterable vapps = transformParallel(vdcs, + new Function>() { + @Override + public Future apply(final VirtualDatacenter input) { + return context.getAsyncApi().getCloudApi().listVirtualAppliances(input.unwrap()); + } + }, userExecutor, maxTime, logger, "getting virtual appliances"); - return DomainWrapper.join(vapps); - } + return DomainWrapper.join(vapps); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java index d73e3b4c4a..50f775c337 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImpl.java @@ -56,77 +56,64 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListVirtualDatacentersImpl implements ListVirtualDatacenters -{ - protected final RestContext context; +public class ListVirtualDatacentersImpl implements ListVirtualDatacenters { + protected final RestContext context; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListVirtualDatacentersImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) - { - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListVirtualDatacentersImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + this.context = checkNotNull(context, "context"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute() - { - VirtualDatacenterOptions virtualDatacenterOptions = - VirtualDatacenterOptions.builder().build(); + @Override + public Iterable execute() { + VirtualDatacenterOptions virtualDatacenterOptions = VirtualDatacenterOptions.builder().build(); - return execute(virtualDatacenterOptions); - } + return execute(virtualDatacenterOptions); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - @Override - public Iterable execute( - final VirtualDatacenterOptions virtualDatacenterOptions) - { - VirtualDatacentersDto result = - context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions); - return wrap(context, VirtualDatacenter.class, result.getCollection()); - } + @Override + public Iterable execute(final VirtualDatacenterOptions virtualDatacenterOptions) { + VirtualDatacentersDto result = context.getApi().getCloudApi().listVirtualDatacenters(virtualDatacenterOptions); + return wrap(context, VirtualDatacenter.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector, - final VirtualDatacenterOptions virtualDatacenterOptions) - { - return filter(execute(virtualDatacenterOptions), selector); - } + @Override + public Iterable execute(final Predicate selector, + final VirtualDatacenterOptions virtualDatacenterOptions) { + return filter(execute(virtualDatacenterOptions), selector); + } - @Override - public Iterable execute(final List virtualDatacenterIds) - { - // Find virtual datacenters in concurrent requests - return listConcurrentVirtualDatacenters(virtualDatacenterIds); - } + @Override + public Iterable execute(final List virtualDatacenterIds) { + // Find virtual datacenters in concurrent requests + return listConcurrentVirtualDatacenters(virtualDatacenterIds); + } - private Iterable listConcurrentVirtualDatacenters(final List ids) - { - Iterable vdcs = - transformParallel(ids, new Function>() - { - @Override - public Future apply(final Integer input) - { - return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input); - } + private Iterable listConcurrentVirtualDatacenters(final List ids) { + Iterable vdcs = transformParallel(ids, + new Function>() { + @Override + public Future apply(final Integer input) { + return context.getAsyncApi().getCloudApi().getVirtualDatacenter(input); + } }, userExecutor, maxTime, logger, "getting virtual datacenters"); - return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs)); - } + return DomainWrapper.wrap(context, VirtualDatacenter.class, Lists.newArrayList(vdcs)); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java index 6f0a7c815f..d094fb9545 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImpl.java @@ -55,73 +55,60 @@ import com.google.inject.Inject; * @author Ignasi Barrera */ @Singleton -public class ListVirtualMachinesImpl implements ListVirtualMachines -{ - protected final RestContext context; +public class ListVirtualMachinesImpl implements ListVirtualMachines { + protected final RestContext context; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - protected final ListVirtualAppliances listVirtualAppliances; + protected final ListVirtualAppliances listVirtualAppliances; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListVirtualMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListVirtualAppliances listVirtualAppliances) - { - super(); - this.context = checkNotNull(context, "context"); - this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListVirtualMachinesImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, + final ListVirtualAppliances listVirtualAppliances) { + super(); + this.context = checkNotNull(context, "context"); + this.listVirtualAppliances = checkNotNull(listVirtualAppliances, "listVirtualAppliances"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute() - { - return execute(VirtualMachineOptions.builder().disablePagination().build()); - } + @Override + public Iterable execute() { + return execute(VirtualMachineOptions.builder().disablePagination().build()); + } - @Override - public Iterable execute(final VirtualMachineOptions options) - { - // Find virtual machines in concurrent requests - Iterable vapps = listVirtualAppliances.execute(); - Iterable vms = - listConcurrentVirtualMachines(vapps, options); + @Override + public Iterable execute(final VirtualMachineOptions options) { + // Find virtual machines in concurrent requests + Iterable vapps = listVirtualAppliances.execute(); + Iterable vms = listConcurrentVirtualMachines(vapps, options); - return wrap(context, VirtualMachine.class, vms); - } + return wrap(context, VirtualMachine.class, vms); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - private Iterable listConcurrentVirtualMachines( - final Iterable vapps, final VirtualMachineOptions options) - { - Iterable vms = - transformParallel( - vapps, - new Function>() - { - @Override - public Future apply( - final VirtualAppliance input) - { - return context.getAsyncApi().getCloudApi() - .listVirtualMachines(input.unwrap(), options); - } - }, userExecutor, maxTime, logger, "getting virtual machines"); + private Iterable listConcurrentVirtualMachines( + final Iterable vapps, final VirtualMachineOptions options) { + Iterable vms = transformParallel(vapps, + new Function>() { + @Override + public Future apply(final VirtualAppliance input) { + return context.getAsyncApi().getCloudApi().listVirtualMachines(input.unwrap(), options); + } + }, userExecutor, maxTime, logger, "getting virtual machines"); - return DomainWrapper.join(vms); - } + return DomainWrapper.join(vms); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java index 69e6a40ed0..61314cdbba 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCategories.java @@ -31,6 +31,5 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListCategoriesImpl.class) -public interface ListCategories extends ListRootEntities -{ +public interface ListCategories extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java index e1f83c5243..8a4ff4aa8a 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCostCodes.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Susana Acedo */ @ImplementedBy(ListCostCodesImpl.class) -public interface ListCostCodes extends ListRootEntities -{ +public interface ListCostCodes extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java index 168762e0cf..2b4ce779ab 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListCurrencies.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Susana Acedo */ @ImplementedBy(ListCurrenciesImpl.class) -public interface ListCurrencies extends ListRootEntities -{ +public interface ListCurrencies extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java index 8eccf96644..027e2e788c 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListLicenses.java @@ -32,7 +32,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListLicensesImpl.class) -public interface ListLicenses extends ListRootEntities -{ - public Iterable execute(LicenseOptions options); +public interface ListLicenses extends ListRootEntities { + public Iterable execute(LicenseOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java index 8415bda36f..87c0eb4f36 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPricingTemplates.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Susana Acedo */ @ImplementedBy(ListPricingTemplatesImpl.class) -public interface ListPricingTemplates extends ListRootEntities -{ +public interface ListPricingTemplates extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java index 287dc08bd2..874d860c98 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListPrivileges.java @@ -31,6 +31,5 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListPrivilegesImpl.class) -public interface ListPrivileges extends ListRootEntities -{ +public interface ListPrivileges extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java index 1f7f543c23..fa54a9deb9 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/ListProperties.java @@ -32,7 +32,6 @@ import com.google.inject.ImplementedBy; * @author Francesc Montserrat */ @ImplementedBy(ListPropertiesImpl.class) -public interface ListProperties extends ListRootEntities -{ - public Iterable execute(PropertyOptions options); +public interface ListProperties extends ListRootEntities { + public Iterable execute(PropertyOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java index cefe8119ef..8fc5ed3bed 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListCategoriesImpl implements ListCategories -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListCategoriesImpl implements ListCategories { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListCategoriesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListCategoriesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - CategoriesDto result = context.getApi().getConfigApi().listCategories(); - return wrap(context, Category.class, result.getCollection()); - } + @Override + public Iterable execute() { + CategoriesDto result = context.getApi().getConfigApi().listCategories(); + return wrap(context, Category.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java index 1a5a1c14b7..2187ce1838 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCostCodesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Susana Acedo */ @Singleton -public class ListCostCodesImpl implements ListCostCodes -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListCostCodesImpl implements ListCostCodes { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListCostCodesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListCostCodesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); - return wrap(context, CostCode.class, result.getCollection()); - } + @Override + public Iterable execute() { + CostCodesDto result = context.getApi().getPricingApi().listCostCodes(); + return wrap(context, CostCode.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java index d5d9ea85ff..9ac1380f57 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListCurrenciesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Susana Acedo */ @Singleton -public class ListCurrenciesImpl implements ListCurrencies -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListCurrenciesImpl implements ListCurrencies { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListCurrenciesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListCurrenciesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); - return wrap(context, Currency.class, result.getCollection()); - } + @Override + public Iterable execute() { + CurrenciesDto result = context.getApi().getPricingApi().listCurrencies(); + return wrap(context, Currency.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java index 15e0c91051..ab28472b06 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImpl.java @@ -42,37 +42,33 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListLicensesImpl implements ListLicenses -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListLicensesImpl implements ListLicenses { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListLicensesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListLicensesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - LicensesDto result = context.getApi().getConfigApi().listLicenses(); - return wrap(context, License.class, result.getCollection()); - } + @Override + public Iterable execute() { + LicensesDto result = context.getApi().getConfigApi().listLicenses(); + return wrap(context, License.class, result.getCollection()); + } - @Override - public Iterable execute(final LicenseOptions options) - { - LicensesDto result = context.getApi().getConfigApi().listLicenses(options); - return wrap(context, License.class, result.getCollection()); - } + @Override + public Iterable execute(final LicenseOptions options) { + LicensesDto result = context.getApi().getConfigApi().listLicenses(options); + return wrap(context, License.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java index 6f5b33032c..8d9ac4045e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPricingTemplatesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Susana Acedo */ @Singleton -public class ListPricingTemplatesImpl implements ListPricingTemplates -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListPricingTemplatesImpl implements ListPricingTemplates { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListPricingTemplatesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListPricingTemplatesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); - return wrap(context, PricingTemplate.class, result.getCollection()); - } + @Override + public Iterable execute() { + PricingTemplatesDto result = context.getApi().getPricingApi().listPricingTemplates(); + return wrap(context, PricingTemplate.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java index a91c933c3d..6a16511abf 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListPrivilegesImpl implements ListPrivileges -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListPrivilegesImpl implements ListPrivileges { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListPrivilegesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListPrivilegesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); - return wrap(context, Privilege.class, result.getCollection()); - } + @Override + public Iterable execute() { + PrivilegesDto result = context.getApi().getConfigApi().listPrivileges(); + return wrap(context, Privilege.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java index 8eeae43a40..07eaab416b 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImpl.java @@ -42,37 +42,32 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListPropertiesImpl implements ListProperties -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListPropertiesImpl implements ListProperties { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListPropertiesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListPropertiesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); - return wrap(context, SystemProperty.class, result.getCollection()); - } + @Override + public Iterable execute() { + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(); + return wrap(context, SystemProperty.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - @Override - public Iterable execute(final PropertyOptions options) - { - SystemPropertiesDto result = - context.getApi().getConfigApi().listSystemProperties(options); - return wrap(context, SystemProperty.class, result.getCollection()); - } + @Override + public Iterable execute(final PropertyOptions options) { + SystemPropertiesDto result = context.getApi().getConfigApi().listSystemProperties(options); + return wrap(context, SystemProperty.class, result.getCollection()); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java index 48fcb8038e..1e0ba94eb6 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListEnterprises.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListEnterprisesImpl.class) -public interface ListEnterprises extends ListRootEntities -{ +public interface ListEnterprises extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java index e92034f1e3..29136bf778 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/ListVirtualMachineTemplates.java @@ -32,8 +32,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListVirtualMachineTemplatesImpl.class) -public interface ListVirtualMachineTemplates extends - ListEntities -{ +public interface ListVirtualMachineTemplates extends ListEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java index 76d9cc2607..ee401b4e0e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImpl.java @@ -41,30 +41,27 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListEnterprisesImpl implements ListEnterprises -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListEnterprisesImpl implements ListEnterprises { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListEnterprisesImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListEnterprisesImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); - return wrap(context, Enterprise.class, result.getCollection()); - } + @Override + public Iterable execute() { + EnterprisesDto result = context.getApi().getEnterpriseApi().listEnterprises(); + return wrap(context, Enterprise.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java index b9d95f0a79..29209ad5c5 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImpl.java @@ -54,61 +54,53 @@ import com.google.inject.Inject; * @author Ignasi Barrera */ @Singleton -public class ListVirtualMachineTemplatesImpl implements ListVirtualMachineTemplates -{ - protected final RestContext context; +public class ListVirtualMachineTemplatesImpl implements ListVirtualMachineTemplates { + protected final RestContext context; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListVirtualMachineTemplatesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) - { - super(); - this.context = checkNotNull(context, "context"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListVirtualMachineTemplatesImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + super(); + this.context = checkNotNull(context, "context"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute(final Enterprise parent) - { - // Find virtual machine templates in concurrent requests - Iterable dcs = parent.listAllowedDatacenters(); - Iterable templates = listConcurrentTemplates(parent, dcs); + @Override + public Iterable execute(final Enterprise parent) { + // Find virtual machine templates in concurrent requests + Iterable dcs = parent.listAllowedDatacenters(); + Iterable templates = listConcurrentTemplates(parent, dcs); - return wrap(context, VirtualMachineTemplate.class, templates); - } + return wrap(context, VirtualMachineTemplate.class, templates); + } - @Override - public Iterable execute(final Enterprise parent, - final Predicate selector) - { - return filter(execute(parent), selector); - } + @Override + public Iterable execute(final Enterprise parent, + final Predicate selector) { + return filter(execute(parent), selector); + } - private Iterable listConcurrentTemplates(final Enterprise parent, - final Iterable dcs) - { - Iterable templates = - transformParallel(dcs, - new Function>() - { - @Override - public Future apply(final Datacenter input) - { - return context.getAsyncApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(parent.getId(), input.getId()); - } - }, userExecutor, maxTime, logger, "getting virtual machine templates"); + private Iterable listConcurrentTemplates(final Enterprise parent, + final Iterable dcs) { + Iterable templates = transformParallel(dcs, + new Function>() { + @Override + public Future apply(final Datacenter input) { + return context.getAsyncApi().getVirtualMachineTemplateApi() + .listVirtualMachineTemplates(parent.getId(), input.getId()); + } + }, userExecutor, maxTime, logger, "getting virtual machine templates"); - return DomainWrapper.join(templates); - } + return DomainWrapper.join(templates); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java index a8680d8154..083991599d 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/ListEvents.java @@ -32,7 +32,6 @@ import com.google.inject.ImplementedBy; * @author Vivien Mahé */ @ImplementedBy(ListEventsImpl.class) -public interface ListEvents extends ListRootEntities -{ - Iterable execute(EventOptions options); +public interface ListEvents extends ListRootEntities { + Iterable execute(EventOptions options); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java index 42ca29c927..ed1da35236 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/event/internal/ListEventsImpl.java @@ -33,37 +33,33 @@ import com.abiquo.server.core.event.EventsDto; import com.google.common.base.Predicate; import com.google.inject.Inject; -public class ListEventsImpl implements ListEvents -{ - // This strategy does not have still an Executor instance because the current methods call - // single api methods +public class ListEventsImpl implements ListEvents { + // This strategy does not have still an Executor instance because the current + // methods call + // single api methods - protected final RestContext context; + protected final RestContext context; - @Inject - ListEventsImpl(final RestContext context) - { - this.context = context; - } + @Inject + ListEventsImpl(final RestContext context) { + this.context = context; + } - @Override - public Iterable execute() - { - EventsDto result = context.getApi().getEventApi().listEvents(); - return wrap(context, Event.class, result.getCollection()); - } + @Override + public Iterable execute() { + EventsDto result = context.getApi().getEventApi().listEvents(); + return wrap(context, Event.class, result.getCollection()); + } - @Override - public Iterable execute(final EventOptions options) - { - EventsDto result = context.getApi().getEventApi().listEvents(options); - return wrap(context, Event.class, result.getCollection()); - } + @Override + public Iterable execute(final EventOptions options) { + EventsDto result = context.getApi().getEventApi().listEvents(options); + return wrap(context, Event.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java index c92869db46..99a67bfaaa 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListDatacenters.java @@ -33,7 +33,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListDatacentersImpl.class) -public interface ListDatacenters extends ListRootEntities -{ - Iterable execute(List datacenterIds); +public interface ListDatacenters extends ListRootEntities { + Iterable execute(List datacenterIds); } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java index 4fec2b90a6..d14d3c613e 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/ListMachines.java @@ -31,7 +31,6 @@ import com.google.inject.ImplementedBy; * @author Ignasi Barrera */ @ImplementedBy(ListMachinesImpl.class) -public interface ListMachines extends ListRootEntities -{ +public interface ListMachines extends ListRootEntities { } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java index 0ba7056e1c..fad587620f 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImpl.java @@ -55,61 +55,52 @@ import com.google.inject.Inject; * @author Francesc Montserrat */ @Singleton -public class ListDatacentersImpl implements ListDatacenters -{ +public class ListDatacentersImpl implements ListDatacenters { - protected final RestContext context; + protected final RestContext context; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListDatacentersImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) - { - this.context = context; - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListDatacentersImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor) { + this.context = context; + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute() - { - DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); - return wrap(context, Datacenter.class, result.getCollection()); - } + @Override + public Iterable execute() { + DatacentersDto result = context.getApi().getInfrastructureApi().listDatacenters(); + return wrap(context, Datacenter.class, result.getCollection()); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - @Override - public Iterable execute(final List datacenterIds) - { - // Find virtual datacenters in concurrent requests - return listConcurrentDatacenters(datacenterIds); - } + @Override + public Iterable execute(final List datacenterIds) { + // Find virtual datacenters in concurrent requests + return listConcurrentDatacenters(datacenterIds); + } - private Iterable listConcurrentDatacenters(final List ids) - { - Iterable dcs = - transformParallel(ids, new Function>() - { - @Override - public Future apply(final Integer input) - { - return context.getAsyncApi().getInfrastructureApi().getDatacenter(input); - } - }, userExecutor, maxTime, logger, "getting datacenters"); + private Iterable listConcurrentDatacenters(final List ids) { + Iterable dcs = transformParallel(ids, new Function>() { + @Override + public Future apply(final Integer input) { + return context.getAsyncApi().getInfrastructureApi().getDatacenter(input); + } + }, userExecutor, maxTime, logger, "getting datacenters"); - return DomainWrapper.wrap(context, Datacenter.class, Lists.newArrayList(dcs)); - } + return DomainWrapper.wrap(context, Datacenter.class, Lists.newArrayList(dcs)); + } } diff --git a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java index 362d25c861..326d5febb4 100644 --- a/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java +++ b/labs/abiquo/src/main/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImpl.java @@ -56,78 +56,65 @@ import com.google.inject.Inject; * @author Ignasi Barrera */ @Singleton -public class ListMachinesImpl implements ListMachines -{ - protected RestContext context; +public class ListMachinesImpl implements ListMachines { + protected RestContext context; - protected ListDatacenters listDatacenters; + protected ListDatacenters listDatacenters; - protected final ExecutorService userExecutor; + protected final ExecutorService userExecutor; - @Resource - protected Logger logger = Logger.NULL; + @Resource + protected Logger logger = Logger.NULL; - @Inject(optional = true) - @Named(Constants.PROPERTY_REQUEST_TIMEOUT) - protected Long maxTime; + @Inject(optional = true) + @Named(Constants.PROPERTY_REQUEST_TIMEOUT) + protected Long maxTime; - @Inject - ListMachinesImpl(final RestContext context, - @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, - final ListDatacenters listDatacenters) - { - super(); - this.context = checkNotNull(context, "context"); - this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - } + @Inject + ListMachinesImpl(final RestContext context, + @Named(Constants.PROPERTY_USER_THREADS) final ExecutorService userExecutor, + final ListDatacenters listDatacenters) { + super(); + this.context = checkNotNull(context, "context"); + this.listDatacenters = checkNotNull(listDatacenters, "listDatacenters"); + this.userExecutor = checkNotNull(userExecutor, "userExecutor"); + } - @Override - public Iterable execute() - { - // Find machines in concurrent requests - Iterable datacenters = listDatacenters.execute(); - Iterable racks = listConcurrentRacks(datacenters); - Iterable machines = listConcurrentMachines(racks); + @Override + public Iterable execute() { + // Find machines in concurrent requests + Iterable datacenters = listDatacenters.execute(); + Iterable racks = listConcurrentRacks(datacenters); + Iterable machines = listConcurrentMachines(racks); - return wrap(context, Machine.class, machines); - } + return wrap(context, Machine.class, machines); + } - @Override - public Iterable execute(final Predicate selector) - { - return filter(execute(), selector); - } + @Override + public Iterable execute(final Predicate selector) { + return filter(execute(), selector); + } - private Iterable listConcurrentRacks(final Iterable datacenters) - { - Iterable racks = - transformParallel(datacenters, new Function>() - { - @Override - public Future apply(final Datacenter input) - { - return context.getAsyncApi().getInfrastructureApi() - .listRacks(input.unwrap()); - } - }, userExecutor, maxTime, logger, "getting racks"); + private Iterable listConcurrentRacks(final Iterable datacenters) { + Iterable racks = transformParallel(datacenters, new Function>() { + @Override + public Future apply(final Datacenter input) { + return context.getAsyncApi().getInfrastructureApi().listRacks(input.unwrap()); + } + }, userExecutor, maxTime, logger, "getting racks"); - return DomainWrapper.join(racks); - } + return DomainWrapper.join(racks); + } - private Iterable listConcurrentMachines(final Iterable racks) - { - Iterable machines = - transformParallel(racks, new Function>() - { - @Override - public Future apply(final RackDto input) - { - return context.getAsyncApi().getInfrastructureApi().listMachines(input); - } - }, userExecutor, maxTime, logger, "getting machines"); + private Iterable listConcurrentMachines(final Iterable racks) { + Iterable machines = transformParallel(racks, new Function>() { + @Override + public Future apply(final RackDto input) { + return context.getAsyncApi().getInfrastructureApi().listMachines(input); + } + }, userExecutor, maxTime, logger, "getting machines"); - return DomainWrapper.join(machines); - } + return DomainWrapper.join(machines); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java index 2e6486dc1e..018575b9c4 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoApiMetadataTest.java @@ -34,21 +34,18 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AbiquoApiMetadataTest") -public class AbiquoApiMetadataTest extends BaseComputeServiceApiMetadataTest -{ +public class AbiquoApiMetadataTest extends BaseComputeServiceApiMetadataTest { - public AbiquoApiMetadataTest() - { - super(new AbiquoApiMetadata()); - } + public AbiquoApiMetadataTest() { + super(new AbiquoApiMetadata()); + } - public void testAbiquoApiRegistered() - { - ApiMetadata api = Apis.withId("abiquo"); + public void testAbiquoApiRegistered() { + ApiMetadata api = Apis.withId("abiquo"); - assertNotNull(api); - assertTrue(api instanceof AbiquoApiMetadata); - assertEquals(api.getId(), "abiquo"); - } + assertNotNull(api); + assertTrue(api instanceof AbiquoApiMetadata); + assertEquals(api.getId(), "abiquo"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java index 8f99cba17b..50098a1773 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/AbiquoDelegateApiTest.java @@ -38,58 +38,49 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AbiquoDelegateApiTest") -public class AbiquoDelegateApiTest extends BaseAbiquoAsyncApiTest -{ - private AbiquoAsyncApi asyncApi; +public class AbiquoDelegateApiTest extends BaseAbiquoAsyncApiTest { + private AbiquoAsyncApi asyncApi; - private AbiquoApi syncApi; + private AbiquoApi syncApi; - @BeforeClass - @Override - protected void setupFactory() throws IOException - { - super.setupFactory(); - asyncApi = injector.getInstance(AbiquoAsyncApi.class); - syncApi = injector.getInstance(AbiquoApi.class); - } + @BeforeClass + @Override + protected void setupFactory() throws IOException { + super.setupFactory(); + asyncApi = injector.getInstance(AbiquoAsyncApi.class); + syncApi = injector.getInstance(AbiquoApi.class); + } - public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, - ExecutionException - { - assertNotNull(syncApi.getAdminApi()); - assertNotNull(syncApi.getConfigApi()); - assertNotNull(syncApi.getInfrastructureApi()); - assertNotNull(syncApi.getEnterpriseApi()); - assertNotNull(syncApi.getCloudApi()); - assertNotNull(syncApi.getVirtualMachineTemplateApi()); - assertNotNull(syncApi.getTaskApi()); - assertNotNull(syncApi.getPricingApi()); - } + public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assertNotNull(syncApi.getAdminApi()); + assertNotNull(syncApi.getConfigApi()); + assertNotNull(syncApi.getInfrastructureApi()); + assertNotNull(syncApi.getEnterpriseApi()); + assertNotNull(syncApi.getCloudApi()); + assertNotNull(syncApi.getVirtualMachineTemplateApi()); + assertNotNull(syncApi.getTaskApi()); + assertNotNull(syncApi.getPricingApi()); + } - public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, - ExecutionException - { - assertNotNull(asyncApi.getAdminApi()); - assertNotNull(asyncApi.getConfigApi()); - assertNotNull(asyncApi.getInfrastructureApi()); - assertNotNull(asyncApi.getEnterpriseApi()); - assertNotNull(asyncApi.getCloudApi()); - assertNotNull(asyncApi.getVirtualMachineTemplateApi()); - assertNotNull(asyncApi.getTaskApi()); - assertNotNull(asyncApi.getPricingApi()); - } + public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assertNotNull(asyncApi.getAdminApi()); + assertNotNull(asyncApi.getConfigApi()); + assertNotNull(asyncApi.getInfrastructureApi()); + assertNotNull(asyncApi.getEnterpriseApi()); + assertNotNull(asyncApi.getCloudApi()); + assertNotNull(asyncApi.getVirtualMachineTemplateApi()); + assertNotNull(asyncApi.getTaskApi()); + assertNotNull(asyncApi.getPricingApi()); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } - @Override - protected void checkFilters(final HttpRequest request) - { + @Override + protected void checkFilters(final HttpRequest request) { - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/AppendToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/AppendToPathTest.java index 960076a572..19ec5e2a10 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/AppendToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/AppendToPathTest.java @@ -32,32 +32,25 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AppendToPathTest") -public class AppendToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - AppendToPath binder = new AppendToPath(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } +public class AppendToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + AppendToPath binder = new AppendToPath(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - public void testBindString() - { - AppendToPath binder = new AppendToPath(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - HttpRequest newRequest = binder.bindToRequest(request, "expanded/path"); - assertEquals(newRequest.getRequestLine(), "GET http://localhost/expanded/path HTTP/1.1"); - } + public void testBindString() { + AppendToPath binder = new AppendToPath(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + HttpRequest newRequest = binder.bindToRequest(request, "expanded/path"); + assertEquals(newRequest.getRequestLine(), "GET http://localhost/expanded/path HTTP/1.1"); + } - public void testBindNumber() - { - AppendToPath binder = new AppendToPath(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - HttpRequest newRequest = binder.bindToRequest(request, 57); - assertEquals(newRequest.getRequestLine(), "GET http://localhost/57 HTTP/1.1"); - } + public void testBindNumber() { + AppendToPath binder = new AppendToPath(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + HttpRequest newRequest = binder.bindToRequest(request, 57); + assertEquals(newRequest.getRequestLine(), "GET http://localhost/57 HTTP/1.1"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeaderTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeaderTest.java index 5ef0effe49..426ff9a0af 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeaderTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeaderTest.java @@ -35,27 +35,23 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindLinkToPathAndAcceptHeaderTest") -public class BindLinkToPathAndAcceptHeaderTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindLinkToPathAndAcceptHeader binder = new BindLinkToPathAndAcceptHeader(); - binder.addHeader(null, HttpHeaders.ACCEPT, null); - } +public class BindLinkToPathAndAcceptHeaderTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindLinkToPathAndAcceptHeader binder = new BindLinkToPathAndAcceptHeader(); + binder.addHeader(null, HttpHeaders.ACCEPT, null); + } - public void testAddHeader() - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + public void testAddHeader() { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - BindLinkToPathAndAcceptHeader binder = new BindLinkToPathAndAcceptHeader(); - HttpRequest updatedRequest = - binder.addHeader(request, HttpHeaders.ACCEPT, "application/vnd.abiquo.datacenters+xml"); + BindLinkToPathAndAcceptHeader binder = new BindLinkToPathAndAcceptHeader(); + HttpRequest updatedRequest = binder.addHeader(request, HttpHeaders.ACCEPT, + "application/vnd.abiquo.datacenters+xml"); - String accept = updatedRequest.getFirstHeaderOrNull(HttpHeaders.ACCEPT); + String accept = updatedRequest.getFirstHeaderOrNull(HttpHeaders.ACCEPT); - assertNotNull(accept); - assertEquals(accept, "application/vnd.abiquo.datacenters+xml"); - } + assertNotNull(accept); + assertEquals(accept, "application/vnd.abiquo.datacenters+xml"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathTest.java index 55e684053f..b266696625 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindLinkToPathTest.java @@ -31,26 +31,21 @@ import com.abiquo.model.rest.RESTLink; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindLinkToPathTest") -public class BindLinkToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testGetNewEnpointNullInput() - { - BindLinkToPath binder = new BindLinkToPath(); - binder.getNewEndpoint(null, null); - } +public class BindLinkToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testGetNewEnpointNullInput() { + BindLinkToPath binder = new BindLinkToPath(); + binder.getNewEndpoint(null, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetNewEnpointInvalidInput() - { - BindLinkToPath binder = new BindLinkToPath(); - binder.getNewEndpoint(null, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetNewEnpointInvalidInput() { + BindLinkToPath binder = new BindLinkToPath(); + binder.getNewEndpoint(null, new Object()); + } - public void testGetNewEnpoint() - { - BindLinkToPath binder = new BindLinkToPath(); - assertEquals(binder.getNewEndpoint(null, new RESTLink("edit", "http://foo/bar")), - "http://foo/bar"); - } + public void testGetNewEnpoint() { + BindLinkToPath binder = new BindLinkToPath(); + assertEquals(binder.getNewEndpoint(null, new RESTLink("edit", "http://foo/bar")), "http://foo/bar"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java index 066d38e083..e1e5ba36ac 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java @@ -44,161 +44,127 @@ import com.google.common.collect.ImmutableList; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindToPathTest") -public class BindToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullRequest() throws SecurityException, NoSuchMethodException - { - BindToPath binder = new BindToPath(); - binder.bindToRequest(null, new Object()); - } +public class BindToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullRequest() throws SecurityException, NoSuchMethodException { + BindToPath binder = new BindToPath(); + binder.bindToRequest(null, new Object()); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidRequestType() throws SecurityException, NoSuchMethodException - { - BindToPath binder = new BindToPath(); - binder.bindToRequest( - HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidRequestType() throws SecurityException, NoSuchMethodException { + BindToPath binder = new BindToPath(); + binder.bindToRequest(HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() throws SecurityException, NoSuchMethodException - { - Method withEndpointLink = - TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(new TestDto())) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost")).build(); + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { + Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(new TestDto())).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, null); - } + BindToPath binder = new BindToPath(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() throws SecurityException, NoSuchMethodException - { - Method withEndpointLink = - TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(new TestDto())) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost")).build(); + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() throws SecurityException, NoSuchMethodException { + Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(new TestDto())).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, new Object()); - } + BindToPath binder = new BindToPath(); + binder.bindToRequest(request, new Object()); + } - @Test(expectedExceptions = BindException.class) - public void testAnnotationNotPresent() throws SecurityException, NoSuchMethodException - { - TestDto dto = new TestDto(); - Method withoutEndpointLink = - TestEndpointLink.class.getMethod("withoutEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withoutEndpointLink).args(ImmutableList. of(dto)) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost")).build(); + @Test(expectedExceptions = BindException.class) + public void testAnnotationNotPresent() throws SecurityException, NoSuchMethodException { + TestDto dto = new TestDto(); + Method withoutEndpointLink = TestEndpointLink.class.getMethod("withoutEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withoutEndpointLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, dto); - } + BindToPath binder = new BindToPath(); + binder.bindToRequest(request, dto); + } - @Test(expectedExceptions = NullPointerException.class) - public void testLinkNotPresent() throws SecurityException, NoSuchMethodException - { - TestDto dto = new TestDto(); - Method withUnexistingLink = - TestEndpointLink.class.getMethod("withUnexistingLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withUnexistingLink).args(ImmutableList. of(dto)) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost")).build(); + @Test(expectedExceptions = NullPointerException.class) + public void testLinkNotPresent() throws SecurityException, NoSuchMethodException { + TestDto dto = new TestDto(); + Method withUnexistingLink = TestEndpointLink.class.getMethod("withUnexistingLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withUnexistingLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindToPath binder = new BindToPath(); - binder.bindToRequest(request, dto); - } + BindToPath binder = new BindToPath(); + binder.bindToRequest(request, dto); + } - public void testBindWithoutParameters() throws SecurityException, NoSuchMethodException - { - TestDto dto = new TestDto(); - Method withEndpointLink = - TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(dto)) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost")).build(); + public void testBindWithoutParameters() throws SecurityException, NoSuchMethodException { + TestDto dto = new TestDto(); + Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindToPath binder = new BindToPath(); - GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), "GET http://linkuri HTTP/1.1"); - } + BindToPath binder = new BindToPath(); + GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); + assertEquals(newRequest.getRequestLine(), "GET http://linkuri HTTP/1.1"); + } - public void testBindWithQueryParameters() throws SecurityException, NoSuchMethodException - { - TestDto dto = new TestDto(); - Method withEndpointLink = - TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(dto)) - .method(HttpMethod.GET).endpoint(URI.create("http://localhost?param=value")) - .build(); + public void testBindWithQueryParameters() throws SecurityException, NoSuchMethodException { + TestDto dto = new TestDto(); + Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost?param=value")).build(); - BindToPath binder = new BindToPath(); - GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), "GET http://linkuri?param=value HTTP/1.1"); - } + BindToPath binder = new BindToPath(); + GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); + assertEquals(newRequest.getRequestLine(), "GET http://linkuri?param=value HTTP/1.1"); + } - public void testBindWithQueryAndMatrixParameters() throws SecurityException, - NoSuchMethodException - { - TestDto dto = new TestDto(); - Method withEndpointLink = - TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(dto)) - .method(HttpMethod.GET) - .endpoint(URI.create("http://localhost?param=value;matrix=value2")).build(); + public void testBindWithQueryAndMatrixParameters() throws SecurityException, NoSuchMethodException { + TestDto dto = new TestDto(); + Method withEndpointLink = TestEndpointLink.class.getMethod("withEndpointLink", TestDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestEndpointLink.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(dto)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost?param=value;matrix=value2")).build(); - BindToPath binder = new BindToPath(); - GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), - "GET http://linkuri?param=value;matrix=value2 HTTP/1.1"); - } + BindToPath binder = new BindToPath(); + GeneratedHttpRequest newRequest = binder.bindToRequest(request, dto); + assertEquals(newRequest.getRequestLine(), "GET http://linkuri?param=value;matrix=value2 HTTP/1.1"); + } - static interface TestEndpointLink - { - @GET - void withEndpointLink(@EndpointLink("edit") TestDto dto); + static interface TestEndpointLink { + @GET + void withEndpointLink(@EndpointLink("edit") TestDto dto); - @GET - void withUnexistingLink(@EndpointLink("unexisting") TestDto dto); + @GET + void withUnexistingLink(@EndpointLink("unexisting") TestDto dto); - @GET - void withoutEndpointLink(TestDto dto); - } + @GET + void withoutEndpointLink(TestDto dto); + } - static class TestDto extends SingleResourceTransportDto - { - private static final long serialVersionUID = 1L; + static class TestDto extends SingleResourceTransportDto { + private static final long serialVersionUID = 1L; - public TestDto() - { - addLink(new RESTLink("edit", "http://linkuri")); - } + public TestDto() { + addLink(new RESTLink("edit", "http://linkuri")); + } - @Override - public String getMediaType() - { - return MediaType.APPLICATION_XML; - } + @Override + public String getMediaType() { + return MediaType.APPLICATION_XML; + } - @Override - public String getBaseMediaType() - { - return MediaType.APPLICATION_XML; - } - } + @Override + public String getBaseMediaType() { + return MediaType.APPLICATION_XML; + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayloadTest.java index 9ed0433492..220fa363ba 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayloadTest.java @@ -39,57 +39,44 @@ import com.abiquo.server.core.infrastructure.storage.DiskManagementDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindHardDiskRefsToPayloadTest") -public class BindHardDiskRefsToPayloadTest -{ +public class BindHardDiskRefsToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindEmptyArray() throws IOException - { - BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new DiskManagementDto[] {}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindEmptyArray() throws IOException { + BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new DiskManagementDto[] {}); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindSingleHardDisk() throws IOException - { - DiskManagementDto hardDisk = CloudResources.hardDiskPut(); - BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new DiskManagementDto[] {hardDisk}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindSingleHardDisk() throws IOException { + DiskManagementDto hardDisk = CloudResources.hardDiskPut(); + BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new DiskManagementDto[] { hardDisk }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindMultipleHardDisks() throws IOException - { - DiskManagementDto hardDisk = CloudResources.hardDiskPut(); - BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new DiskManagementDto[] {hardDisk, hardDisk}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindMultipleHardDisks() throws IOException { + DiskManagementDto hardDisk = CloudResources.hardDiskPut(); + BindHardDiskRefsToPayload binder = new BindHardDiskRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new DiskManagementDto[] { hardDisk, hardDisk }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayloadTest.java index 30b22dfe93..b8649e106f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayloadTest.java @@ -40,39 +40,30 @@ import com.abiquo.server.core.infrastructure.network.PrivateIpDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindIpRefToPayloadTest") -public class BindIpRefToPayloadTest -{ +public class BindIpRefToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindIpRef() throws IOException - { - PrivateIpDto ip = NetworkResources.privateIpPut(); - RESTLink selfLink = ip.searchLink("self"); - BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, ip); - assertPayloadEquals( - request.getPayload(), - withHeader(""), LinksDto.class); + public void testBindIpRef() throws IOException { + PrivateIpDto ip = NetworkResources.privateIpPut(); + RESTLink selfLink = ip.searchLink("self"); + BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, ip); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayloadTest.java index 55d3016afa..dd907b043a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayloadTest.java @@ -40,57 +40,44 @@ import com.abiquo.server.core.infrastructure.network.PrivateIpDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindIpRefsToPayloadTest") -public class BindIpRefsToPayloadTest -{ +public class BindIpRefsToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindEmptyArray() throws IOException - { - BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new AbstractIpDto[] {}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindEmptyArray() throws IOException { + BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new AbstractIpDto[] {}); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindSingleIp() throws IOException - { - PrivateIpDto ip = NetworkResources.privateIpPut(); - BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new AbstractIpDto[] {ip}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindSingleIp() throws IOException { + PrivateIpDto ip = NetworkResources.privateIpPut(); + BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new AbstractIpDto[] { ip }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindMultipleIps() throws IOException - { - PrivateIpDto ip = NetworkResources.privateIpPut(); - BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new AbstractIpDto[] {ip, ip}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindMultipleIps() throws IOException { + PrivateIpDto ip = NetworkResources.privateIpPut(); + BindIpRefsToPayload binder = new BindIpRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new AbstractIpDto[] { ip, ip }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java index aba9fec2d1..c90b5ed504 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java @@ -41,44 +41,30 @@ import com.google.common.collect.ImmutableList; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindMoveVolumeToPathTest") -public class BindMoveVolumeToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() throws SecurityException, NoSuchMethodException - { - BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); - binder.getNewEndpoint(generatedHttpRequest(), null); - } +public class BindMoveVolumeToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { + BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); + binder.getNewEndpoint(generatedHttpRequest(), null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() throws SecurityException, NoSuchMethodException - { - BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); - binder.getNewEndpoint(generatedHttpRequest(), new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() throws SecurityException, NoSuchMethodException { + BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); + binder.getNewEndpoint(generatedHttpRequest(), new Object()); + } - public void testGetNewEndpoint() throws SecurityException, NoSuchMethodException - { - BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); - String newEndpoint = - binder.getNewEndpoint(generatedHttpRequest(), CloudResources.volumePut()); - assertEquals(newEndpoint, - "http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/move"); - } + public void testGetNewEndpoint() throws SecurityException, NoSuchMethodException { + BindMoveVolumeToPath binder = new BindMoveVolumeToPath(); + String newEndpoint = binder.getNewEndpoint(generatedHttpRequest(), CloudResources.volumePut()); + assertEquals(newEndpoint, "http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/move"); + } - private static GeneratedHttpRequest generatedHttpRequest() throws SecurityException, - NoSuchMethodException - { - Method withEndpointLink = - CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class, - VirtualDatacenterDto.class); - return GeneratedHttpRequest - .builder() - .declaring(CloudAsyncApi.class) - .javaMethod(withEndpointLink) - .args( - ImmutableList. of(CloudResources.volumePut(), - CloudResources.virtualDatacenterPut())).method(HttpMethod.POST) - .endpoint(URI.create("http://localhost")).build(); - } + private static GeneratedHttpRequest generatedHttpRequest() throws SecurityException, NoSuchMethodException { + Method withEndpointLink = CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class, + VirtualDatacenterDto.class); + return GeneratedHttpRequest.builder().declaring(CloudAsyncApi.class).javaMethod(withEndpointLink) + .args(ImmutableList. of(CloudResources.volumePut(), CloudResources.virtualDatacenterPut())) + .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java index 15718cda1a..de436fa817 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java @@ -48,111 +48,83 @@ import com.google.common.collect.ImmutableList; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindNetworkConfigurationRefToPayloadTest") -public class BindNetworkConfigurationRefToPayloadTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullRequest() throws SecurityException, NoSuchMethodException - { - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - binder.bindToRequest(null, new Object()); - } +public class BindNetworkConfigurationRefToPayloadTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullRequest() throws SecurityException, NoSuchMethodException { + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + binder.bindToRequest(null, new Object()); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidRequestType() throws SecurityException, NoSuchMethodException - { - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidRequestType() throws SecurityException, NoSuchMethodException { + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - binder.bindToRequest( - HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object()); - } + binder.bindToRequest(HttpRequest.builder().method("m").endpoint("http://localhost").build(), new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() throws SecurityException, NoSuchMethodException - { - VirtualMachineDto vm = CloudResources.virtualMachinePut(); + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() throws SecurityException, NoSuchMethodException { + VirtualMachineDto vm = CloudResources.virtualMachinePut(); - Method method = - TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class).javaMethod(method) - .args(ImmutableList. of(vm, null)).method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); + Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class) + .javaMethod(method).args(ImmutableList. of(vm, null)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - binder.bindToRequest(request, null); - } + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() throws SecurityException, NoSuchMethodException - { - VirtualMachineDto vm = CloudResources.virtualMachinePut(); - Object network = new Object(); + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() throws SecurityException, NoSuchMethodException { + VirtualMachineDto vm = CloudResources.virtualMachinePut(); + Object network = new Object(); - Method method = - TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class).javaMethod(method) - .args(ImmutableList. of(vm, network)).method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); + Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class) + .javaMethod(method).args(ImmutableList. of(vm, network)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - binder.bindToRequest(request, network); - } + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + binder.bindToRequest(request, network); + } - @Test(expectedExceptions = NoSuchElementException.class) - public void testBindNetworkConfigurationRefWithoutVirtualMachine() throws SecurityException, - NoSuchMethodException - { - VLANNetworkDto network = NetworkResources.privateNetworkPut(); + @Test(expectedExceptions = NoSuchElementException.class) + public void testBindNetworkConfigurationRefWithoutVirtualMachine() throws SecurityException, NoSuchMethodException { + VLANNetworkDto network = NetworkResources.privateNetworkPut(); - Method method = - TestNetworkConfig.class.getMethod("withoutVirtualMachine", VLANNetworkDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class).javaMethod(method) - .args(ImmutableList. of(network)).method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); + Method method = TestNetworkConfig.class.getMethod("withoutVirtualMachine", VLANNetworkDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class) + .javaMethod(method).args(ImmutableList. of(network)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - binder.bindToRequest(request, network); - } + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + binder.bindToRequest(request, network); + } - public void testBindNetworkConfigurationRef() throws SecurityException, NoSuchMethodException, - IOException - { - VirtualMachineDto vm = CloudResources.virtualMachinePut(); - VLANNetworkDto network = NetworkResources.privateNetworkPut(); + public void testBindNetworkConfigurationRef() throws SecurityException, NoSuchMethodException, IOException { + VirtualMachineDto vm = CloudResources.virtualMachinePut(); + VLANNetworkDto network = NetworkResources.privateNetworkPut(); - Method method = - TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class).javaMethod(method) - .args(ImmutableList. of(vm, network)).method(HttpMethod.GET) - .endpoint(URI.create("http://localhost")).build(); + Method method = TestNetworkConfig.class.getMethod("withAll", VirtualMachineDto.class, VLANNetworkDto.class); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(TestNetworkConfig.class) + .javaMethod(method).args(ImmutableList. of(vm, network)).method(HttpMethod.GET) + .endpoint(URI.create("http://localhost")).build(); - BindNetworkConfigurationRefToPayload binder = - new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); + BindNetworkConfigurationRefToPayload binder = new BindNetworkConfigurationRefToPayload(new JAXBParser("false")); - String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId(); + String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId(); - GeneratedHttpRequest newRequest = binder.bindToRequest(request, network); - assertPayloadEquals(newRequest.getPayload(), withHeader(""), LinksDto.class); - } + } - static interface TestNetworkConfig - { - @GET - void withoutVirtualMachine(VLANNetworkDto network); + static interface TestNetworkConfig { + @GET + void withoutVirtualMachine(VLANNetworkDto network); - @GET - void withAll(VirtualMachineDto virtualMachine, VLANNetworkDto network); - } + @GET + void withAll(VirtualMachineDto virtualMachine, VLANNetworkDto network); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayloadTest.java index d4d896ff1e..94af9f24ca 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayloadTest.java @@ -39,36 +39,28 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindNetworkRefToPayloadTest") -public class BindNetworkRefToPayloadTest -{ +public class BindNetworkRefToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindNetworkRef() throws IOException - { - VLANNetworkDto network = NetworkResources.privateNetworkPut(); - BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, network); - assertPayloadEquals(request.getPayload(), withHeader(""), - LinksDto.class); - } + public void testBindNetworkRef() throws IOException { + VLANNetworkDto network = NetworkResources.privateNetworkPut(); + BindNetworkRefToPayload binder = new BindNetworkRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, network); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayloadTest.java index 208b33d2a4..f29a5d4a83 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayloadTest.java @@ -40,40 +40,29 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindUnmanagedIpRefToPayloadTest") -public class BindUnmanagedIpRefToPayloadTest -{ +public class BindUnmanagedIpRefToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindUnmanagedIpRefToPayload binder = - new BindUnmanagedIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindUnmanagedIpRefToPayload binder = new BindUnmanagedIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindUnmanagedIpRefToPayload binder = - new BindUnmanagedIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindUnmanagedIpRefToPayload binder = new BindUnmanagedIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindUnmanagedNetworkIpRef() throws IOException - { - VLANNetworkDto network = NetworkResources.unmanagedNetworkPut(); - RESTLink ipsLink = network.searchLink("ips"); - BindUnmanagedIpRefToPayload binder = - new BindUnmanagedIpRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, network); - assertPayloadEquals(request.getPayload(), - withHeader(""), LinksDto.class); - } + public void testBindUnmanagedNetworkIpRef() throws IOException { + VLANNetworkDto network = NetworkResources.unmanagedNetworkPut(); + RESTLink ipsLink = network.searchLink("ips"); + BindUnmanagedIpRefToPayload binder = new BindUnmanagedIpRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, network); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayloadTest.java index 12204d4a6f..ff66ae3e42 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayloadTest.java @@ -39,39 +39,28 @@ import com.abiquo.server.core.cloud.VirtualDatacenterDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindVirtualDatacenterRefToPayloadTest") -public class BindVirtualDatacenterRefToPayloadTest -{ +public class BindVirtualDatacenterRefToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindVirtualDatacenterRefToPayload binder = - new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindVirtualDatacenterRefToPayload binder = - new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindSingleVolume() throws IOException - { - VirtualDatacenterDto vdc = CloudResources.virtualDatacenterPut(); - BindVirtualDatacenterRefToPayload binder = - new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, vdc); - assertPayloadEquals(request.getPayload(), withHeader(""), - LinksDto.class); - } + public void testBindSingleVolume() throws IOException { + VirtualDatacenterDto vdc = CloudResources.virtualDatacenterPut(); + BindVirtualDatacenterRefToPayload binder = new BindVirtualDatacenterRefToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, vdc); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayloadTest.java index 8aef3a3464..67dfc0e5cf 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayloadTest.java @@ -39,57 +39,44 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindVolumeRefsToPayloadTest") -public class BindVolumeRefsToPayloadTest -{ +public class BindVolumeRefsToPayloadTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - public void testBindEmptyArray() throws IOException - { - BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new VolumeManagementDto[] {}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindEmptyArray() throws IOException { + BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new VolumeManagementDto[] {}); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindSingleVolume() throws IOException - { - VolumeManagementDto volume = CloudResources.volumePut(); - BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new VolumeManagementDto[] {volume}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindSingleVolume() throws IOException { + VolumeManagementDto volume = CloudResources.volumePut(); + BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new VolumeManagementDto[] { volume }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } - public void testBindMultipleVolumes() throws IOException - { - VolumeManagementDto volume = CloudResources.volumePut(); - BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - request = binder.bindToRequest(request, new VolumeManagementDto[] {volume, volume}); - assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); - } + public void testBindMultipleVolumes() throws IOException { + VolumeManagementDto volume = CloudResources.volumePut(); + BindVolumeRefsToPayload binder = new BindVolumeRefsToPayload(new JAXBParser("false")); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + request = binder.bindToRequest(request, new VolumeManagementDto[] { volume, volume }); + assertPayloadEquals(request.getPayload(), withHeader(""), LinksDto.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPathTest.java index e8ba7e0e3f..8a85c3c032 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendMachineIdToPathTest.java @@ -35,34 +35,27 @@ import com.abiquo.server.core.infrastructure.MachineDto; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AppendMachineIdToPathTest") -public class AppendMachineIdToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testGetValueWithNullInput() - { - AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.getValue(request, null); - } +public class AppendMachineIdToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testGetValueWithNullInput() { + AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.getValue(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetValueWithInvalidInput() - { - AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.getValue(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueWithInvalidInput() { + AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.getValue(request, new Object()); + } - public void testGetValue() - { - AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + public void testGetValue() { + AppendMachineIdToPath binder = new AppendMachineIdToPath(new ParseMachineId()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - MachineDto machine = new MachineDto(); - machine.setId(5); - assertEquals(binder.getValue(request, machine), "5"); - } + MachineDto machine = new MachineDto(); + machine.setId(5); + assertEquals(binder.getValue(request, machine), "5"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPathTest.java index 50f20fac30..a0b1f52d65 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/AppendRemoteServiceTypeToPathTest.java @@ -35,36 +35,25 @@ import com.abiquo.model.enumerator.RemoteServiceType; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AppendRemoteServiceTypeToPathTest") -public class AppendRemoteServiceTypeToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testGetValueWithNullInput() - { - AppendRemoteServiceTypeToPath binder = - new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.getValue(request, null); - } +public class AppendRemoteServiceTypeToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testGetValueWithNullInput() { + AppendRemoteServiceTypeToPath binder = new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.getValue(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetValueWithInvalidInput() - { - AppendRemoteServiceTypeToPath binder = - new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.getValue(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueWithInvalidInput() { + AppendRemoteServiceTypeToPath binder = new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.getValue(request, new Object()); + } - public void testGetValue() - { - AppendRemoteServiceTypeToPath binder = - new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + public void testGetValue() { + AppendRemoteServiceTypeToPath binder = new AppendRemoteServiceTypeToPath(new ParseRemoteServiceType()); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - assertEquals(binder.getValue(request, RemoteServiceType.VIRTUAL_SYSTEM_MONITOR), - "virtualsystemmonitor"); - } + assertEquals(binder.getValue(request, RemoteServiceType.VIRTUAL_SYSTEM_MONITOR), "virtualsystemmonitor"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java index 47358b6aa9..204b34e20d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java @@ -40,57 +40,48 @@ import com.google.common.collect.ImmutableList; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BindSupportedDevicesLinkToPathTest") -public class BindSupportedDevicesLinkToPathTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testGetNewEnpointNullInput() - { - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - binder.getNewEndpoint(null, null); - } +public class BindSupportedDevicesLinkToPathTest { + @Test(expectedExceptions = NullPointerException.class) + public void testGetNewEnpointNullInput() { + BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); + binder.getNewEndpoint(null, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testGetNewEnpointInvalidInput() - { - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - binder.getNewEndpoint(null, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetNewEnpointInvalidInput() { + BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); + binder.getNewEndpoint(null, new Object()); + } - public void testGetNewEnpoint() throws Exception - { - DatacenterDto datacenter = new DatacenterDto(); - datacenter.addLink(new RESTLink("devices", "http://foo/bar")); + public void testGetNewEnpoint() throws Exception { + DatacenterDto datacenter = new DatacenterDto(); + datacenter.addLink(new RESTLink("devices", "http://foo/bar")); - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); + BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - Method withEndpointLink = - InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", - DatacenterDto.class); + Method withEndpointLink = InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", + DatacenterDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(datacenter)) - .method(HttpMethod.GET).endpoint(URI.create("http://foo/bar")).build(); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(datacenter)).method(HttpMethod.GET) + .endpoint(URI.create("http://foo/bar")).build(); - assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported"); - } + assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported"); + } - @Test(expectedExceptions = NullPointerException.class) - public void testGetNewEnpointWithoutLink() throws Exception - { - DatacenterDto datacenter = new DatacenterDto(); + @Test(expectedExceptions = NullPointerException.class) + public void testGetNewEnpointWithoutLink() throws Exception { + DatacenterDto datacenter = new DatacenterDto(); - BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); + BindSupportedDevicesLinkToPath binder = new BindSupportedDevicesLinkToPath(); - Method withEndpointLink = - InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", - DatacenterDto.class); + Method withEndpointLink = InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", + DatacenterDto.class); - GeneratedHttpRequest request = - GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class) - .javaMethod(withEndpointLink).args(ImmutableList. of(datacenter)) - .method(HttpMethod.GET).endpoint(URI.create("http://foo/bar")).build(); + GeneratedHttpRequest request = GeneratedHttpRequest.builder().declaring(InfrastructureAsyncApi.class) + .javaMethod(withEndpointLink).args(ImmutableList. of(datacenter)).method(HttpMethod.GET) + .endpoint(URI.create("http://foo/bar")).build(); - assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported"); - } + assertEquals(binder.getNewEndpoint(request, datacenter), "http://foo/bar/action/supported"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java index 16920db191..0ef5089bbc 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindLogicServerParametersTest.java @@ -34,44 +34,35 @@ import com.abiquo.server.core.infrastructure.LogicServerDto; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "BindLogicServerParametersTest") -public class BindLogicServerParametersTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindLogicServerParameters binder = new BindLogicServerParameters(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } +public class BindLogicServerParametersTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindLogicServerParameters binder = new BindLogicServerParameters(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindLogicServerParameters binder = new BindLogicServerParameters(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindLogicServerParameters binder = new BindLogicServerParameters(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testBindLogicServerWithEmptyName() - { - BindLogicServerParameters binder = new BindLogicServerParameters(); - LogicServerDto dto = new LogicServerDto(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, dto); - } + @Test(expectedExceptions = NullPointerException.class) + public void testBindLogicServerWithEmptyName() { + BindLogicServerParameters binder = new BindLogicServerParameters(); + LogicServerDto dto = new LogicServerDto(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, dto); + } - public void testBindLogicServer() - { - BindLogicServerParameters binder = new BindLogicServerParameters(); - LogicServerDto dto = new LogicServerDto(); - dto.setName("name"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - HttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), "GET http://localhost?lsName=name HTTP/1.1"); - } + public void testBindLogicServer() { + BindLogicServerParameters binder = new BindLogicServerParameters(); + LogicServerDto dto = new LogicServerDto(); + dto.setName("name"); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + HttpRequest newRequest = binder.bindToRequest(request, dto); + assertEquals(newRequest.getRequestLine(), "GET http://localhost?lsName=name HTTP/1.1"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java index 3e47226f13..753d7e4f9b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/ucs/BindOrganizationParametersTest.java @@ -34,44 +34,35 @@ import com.abiquo.server.core.infrastructure.OrganizationDto; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "BindOrganizationParametersTest") -public class BindOrganizationParametersTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - BindOrganizationParameters binder = new BindOrganizationParameters(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, null); - } +public class BindOrganizationParametersTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + BindOrganizationParameters binder = new BindOrganizationParameters(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidTypeInput() - { - BindOrganizationParameters binder = new BindOrganizationParameters(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidTypeInput() { + BindOrganizationParameters binder = new BindOrganizationParameters(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testBindLogicServerWithEmptyName() - { - BindOrganizationParameters binder = new BindOrganizationParameters(); - OrganizationDto dto = new OrganizationDto(); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - binder.bindToRequest(request, dto); - } + @Test(expectedExceptions = NullPointerException.class) + public void testBindLogicServerWithEmptyName() { + BindOrganizationParameters binder = new BindOrganizationParameters(); + OrganizationDto dto = new OrganizationDto(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + binder.bindToRequest(request, dto); + } - public void testBindLogicServer() - { - BindOrganizationParameters binder = new BindOrganizationParameters(); - OrganizationDto dto = new OrganizationDto(); - dto.setDn("org"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); - HttpRequest newRequest = binder.bindToRequest(request, dto); - assertEquals(newRequest.getRequestLine(), "GET http://localhost?org=org HTTP/1.1"); - } + public void testBindLogicServer() { + BindOrganizationParameters binder = new BindOrganizationParameters(); + OrganizationDto dto = new OrganizationDto(); + dto.setDn("org"); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build(); + HttpRequest newRequest = binder.bindToRequest(request, dto); + assertEquals(newRequest.getRequestLine(), "GET http://localhost?org=org HTTP/1.1"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java index 48d1f31797..853f55fd54 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/AbiquoComputeServiceLiveTest.java @@ -45,96 +45,82 @@ import com.google.inject.Module; * @author Ignasi Barrera */ @Test(groups = "live", testName = "AbiquoComputeServiceLiveTest", singleThreaded = true) -// Made abstract to avoid executing tests. Since the base class has test configuration, even if we -// disable tests here, or comment them out, the ones in the base class will be executed -public class AbiquoComputeServiceLiveTest extends BaseComputeServiceLiveTest -{ - public AbiquoComputeServiceLiveTest() - { - provider = "abiquo"; - } +// Made abstract to avoid executing tests. Since the base class has test +// configuration, even if we +// disable tests here, or comment them out, the ones in the base class will be +// executed +public class AbiquoComputeServiceLiveTest extends BaseComputeServiceLiveTest { + public AbiquoComputeServiceLiveTest() { + provider = "abiquo"; + } - @Override - public void setServiceDefaults() - { - System - .setProperty("test.abiquo.template", - "imageNameMatches=ubuntu_server_ssh_iptables,loginUser=user:abiquo,authenticateSudo=true"); - } + @Override + public void setServiceDefaults() { + System.setProperty("test.abiquo.template", + "imageNameMatches=ubuntu_server_ssh_iptables,loginUser=user:abiquo,authenticateSudo=true"); + } - @Override - protected Properties setupProperties() - { - Properties overrides = super.setupProperties(); - overrides.put(Constants.PROPERTY_MAX_RETRIES, "0"); - overrides.put(Constants.PROPERTY_MAX_REDIRECTS, "0"); - overrides.put("jclouds.timeouts.CloudApi.listVirtualMachines", "60000"); - return overrides; - } + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.put(Constants.PROPERTY_MAX_RETRIES, "0"); + overrides.put(Constants.PROPERTY_MAX_REDIRECTS, "0"); + overrides.put("jclouds.timeouts.CloudApi.listVirtualMachines", "60000"); + return overrides; + } - @Override - protected void initializeContext() - { - super.initializeContext(); - String templateId = buildTemplate(client.templateBuilder()).getImage().getId(); - view.getUtils().getCredentialStore().put("image#" + templateId, loginCredentials); - } + @Override + protected void initializeContext() { + super.initializeContext(); + String templateId = buildTemplate(client.templateBuilder()).getImage().getId(); + view.getUtils().getCredentialStore().put("image#" + templateId, loginCredentials); + } - @Override - protected LoggingModule getLoggingModule() - { - return new SLF4JLoggingModule(); - } + @Override + protected LoggingModule getLoggingModule() { + return new SLF4JLoggingModule(); + } - @Override - protected Module getSshModule() - { - return new SshjSshClientModule(); - } + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } - @Override - public void testListSizes() throws Exception - { - for (Hardware hardware : client.listHardwareProfiles()) - { - assert hardware.getProviderId() != null : hardware; - assert getCores(hardware) > 0 : hardware; - assert hardware.getVolumes().size() >= 0 : hardware; - // There are some small images in Abiquo that have less than 1GB of RAM - // assert hardware.getRam() > 0 : hardware; - assertEquals(hardware.getType(), ComputeType.HARDWARE); - } - } + @Override + public void testListSizes() throws Exception { + for (Hardware hardware : client.listHardwareProfiles()) { + assert hardware.getProviderId() != null : hardware; + assert getCores(hardware) > 0 : hardware; + assert hardware.getVolumes().size() >= 0 : hardware; + // There are some small images in Abiquo that have less than 1GB of RAM + // assert hardware.getRam() > 0 : hardware; + assertEquals(hardware.getType(), ComputeType.HARDWARE); + } + } - @Override - public void testOptionToNotBlock() throws Exception - { - // By default the provider blocks until the node is running - } + @Override + public void testOptionToNotBlock() throws Exception { + // By default the provider blocks until the node is running + } - // Abiquo does not set the hostname - @Override - protected void checkResponseEqualsHostname(final ExecResponse execResponse, - final NodeMetadata node) - { - assert node.getHostname() == null : node + " with hostname: " + node.getHostname(); - } + // Abiquo does not set the hostname + @Override + protected void checkResponseEqualsHostname(final ExecResponse execResponse, final NodeMetadata node) { + assert node.getHostname() == null : node + " with hostname: " + node.getHostname(); + } - // Abiquo does not support metadata - @Override - protected void checkUserMetadataInNodeEquals(final NodeMetadata node, - final ImmutableMap userMetadata) - { - assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format( + // Abiquo does not support metadata + @Override + protected void checkUserMetadataInNodeEquals(final NodeMetadata node, final ImmutableMap userMetadata) { + assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format( "node userMetadata did not match %s %s", userMetadata, node); - } + } - // Abiquo does not support tags - @Override - protected void checkTagsInNodeEquals(final NodeMetadata node, final ImmutableSet tags) - { - assert node.getTags().equals(ImmutableSet. of()) : String.format( - "node tags did not match %s %s", tags, node); - } + // Abiquo does not support tags + @Override + protected void checkTagsInNodeEquals(final NodeMetadata node, final ImmutableSet tags) { + assert node.getTags().equals(ImmutableSet. of()) : String.format("node tags did not match %s %s", tags, + node); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/DatacenterToLocationTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/DatacenterToLocationTest.java index 8350d47b4d..715af5cdb5 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/DatacenterToLocationTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/DatacenterToLocationTest.java @@ -36,19 +36,17 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "DatacenterToLocationTest") -public class DatacenterToLocationTest -{ - @SuppressWarnings("unchecked") - public void testDatacenterToLocation() - { - RestContext context = EasyMock.createMock(RestContext.class); - DatacenterToLocation function = new DatacenterToLocation(); +public class DatacenterToLocationTest { + @SuppressWarnings("unchecked") + public void testDatacenterToLocation() { + RestContext context = EasyMock.createMock(RestContext.class); + DatacenterToLocation function = new DatacenterToLocation(); - Datacenter datacenter = Datacenter.builder(context).name("dc").location("New York").build(); - datacenter.unwrap().setId(5); - Location location = function.apply(datacenter); + Datacenter datacenter = Datacenter.builder(context).name("dc").location("New York").build(); + datacenter.unwrap().setId(5); + Location location = function.apply(datacenter); - assertEquals(location.getId(), "5"); - assertEquals(location.getScope(), LocationScope.REGION); - } + assertEquals(location.getId(), "5"); + assertEquals(location.getScope(), LocationScope.REGION); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocationTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocationTest.java index 90e8d06ae1..644eb11eda 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocationTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualDatacenterToLocationTest.java @@ -49,57 +49,51 @@ import com.google.common.base.Supplier; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualDatacenterToLocationTest") -public class VirtualDatacenterToLocationTest -{ - public void testVirtualDatacenterToLocation() - { - Function dcToLocation = mockDatacenterToLocation(); - Supplier> regionMap = mockRegionMap(); - VirtualDatacenterToLocation function = - new VirtualDatacenterToLocation(dcToLocation, regionMap); +public class VirtualDatacenterToLocationTest { + public void testVirtualDatacenterToLocation() { + Function dcToLocation = mockDatacenterToLocation(); + Supplier> regionMap = mockRegionMap(); + VirtualDatacenterToLocation function = new VirtualDatacenterToLocation(dcToLocation, regionMap); - VirtualDatacenter vdc = mockVirtualDatacenter(); + VirtualDatacenter vdc = mockVirtualDatacenter(); - Location location = function.apply(vdc); + Location location = function.apply(vdc); - verify(regionMap); - verify(dcToLocation); + verify(regionMap); + verify(dcToLocation); - assertEquals(location.getId(), "5"); - assertEquals(location.getScope(), LocationScope.ZONE); - } + assertEquals(location.getId(), "5"); + assertEquals(location.getScope(), LocationScope.ZONE); + } - @SuppressWarnings("unchecked") - private static VirtualDatacenter mockVirtualDatacenter() - { - RestContext context = EasyMock.createMock(RestContext.class); - Datacenter datacenter = EasyMock.createMock(Datacenter.class); - Enterprise enterprise = EasyMock.createMock(Enterprise.class); - PrivateNetwork network = EasyMock.createMock(PrivateNetwork.class); + @SuppressWarnings("unchecked") + private static VirtualDatacenter mockVirtualDatacenter() { + RestContext context = EasyMock.createMock(RestContext.class); + Datacenter datacenter = EasyMock.createMock(Datacenter.class); + Enterprise enterprise = EasyMock.createMock(Enterprise.class); + PrivateNetwork network = EasyMock.createMock(PrivateNetwork.class); - VirtualDatacenter vdc = VirtualDatacenter.builder(context, datacenter, enterprise) // + VirtualDatacenter vdc = VirtualDatacenter.builder(context, datacenter, enterprise) // .network(network) // .name("mock").build(); - vdc.unwrap().setId(5); + vdc.unwrap().setId(5); - return vdc; - } + return vdc; + } - @SuppressWarnings("unchecked") - private static Function mockDatacenterToLocation() - { - Function mock = EasyMock.createMock(Function.class); - expect(mock.apply(anyObject(Datacenter.class))).andReturn(null); - replay(mock); - return mock; - } + @SuppressWarnings("unchecked") + private static Function mockDatacenterToLocation() { + Function mock = EasyMock.createMock(Function.class); + expect(mock.apply(anyObject(Datacenter.class))).andReturn(null); + replay(mock); + return mock; + } - @SuppressWarnings("unchecked") - private static Supplier> mockRegionMap() - { - Supplier> mock = EasyMock.createMock(Supplier.class); - expect(mock.get()).andReturn(Collections.EMPTY_MAP); - replay(mock); - return mock; - } + @SuppressWarnings("unchecked") + private static Supplier> mockRegionMap() { + Supplier> mock = EasyMock.createMock(Supplier.class); + expect(mock.get()).andReturn(Collections.EMPTY_MAP); + replay(mock); + return mock; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeStateTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeStateTest.java index e130f52796..c5c210677d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeStateTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineStateToNodeStateTest.java @@ -32,19 +32,17 @@ import com.abiquo.server.core.cloud.VirtualMachineState; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineStateToNodeStateTest") -public class VirtualMachineStateToNodeStateTest -{ - public void testVirtualMachineStateToNodeState() - { - VirtualMachineStateToNodeState function = new VirtualMachineStateToNodeState(); +public class VirtualMachineStateToNodeStateTest { + public void testVirtualMachineStateToNodeState() { + VirtualMachineStateToNodeState function = new VirtualMachineStateToNodeState(); - assertEquals(function.apply(VirtualMachineState.ALLOCATED), Status.PENDING); - assertEquals(function.apply(VirtualMachineState.LOCKED), Status.PENDING); - assertEquals(function.apply(VirtualMachineState.CONFIGURED), Status.PENDING); - assertEquals(function.apply(VirtualMachineState.ON), Status.RUNNING); - assertEquals(function.apply(VirtualMachineState.OFF), Status.SUSPENDED); - assertEquals(function.apply(VirtualMachineState.PAUSED), Status.SUSPENDED); - assertEquals(function.apply(VirtualMachineState.NOT_ALLOCATED), Status.PENDING); - assertEquals(function.apply(VirtualMachineState.UNKNOWN), Status.UNRECOGNIZED); - } + assertEquals(function.apply(VirtualMachineState.ALLOCATED), Status.PENDING); + assertEquals(function.apply(VirtualMachineState.LOCKED), Status.PENDING); + assertEquals(function.apply(VirtualMachineState.CONFIGURED), Status.PENDING); + assertEquals(function.apply(VirtualMachineState.ON), Status.RUNNING); + assertEquals(function.apply(VirtualMachineState.OFF), Status.SUSPENDED); + assertEquals(function.apply(VirtualMachineState.PAUSED), Status.SUSPENDED); + assertEquals(function.apply(VirtualMachineState.NOT_ALLOCATED), Status.PENDING); + assertEquals(function.apply(VirtualMachineState.UNKNOWN), Status.UNRECOGNIZED); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardwareTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardwareTest.java index bbad3c9d02..6ede999c5c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardwareTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateInVirtualDatacenterToHardwareTest.java @@ -48,201 +48,189 @@ import com.abiquo.server.core.cloud.VirtualDatacenterDto; import com.google.common.base.Function; /** - * Unit tests for the {@link VirtualMachineTemplateInVirtualDatacenterToHardware} function. + * Unit tests for the + * {@link VirtualMachineTemplateInVirtualDatacenterToHardware} function. * * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineTemplateInVirtualDatacenterToHardwareTest") -public class VirtualMachineTemplateInVirtualDatacenterToHardwareTest -{ - @SuppressWarnings("unchecked") - public void testVirtualMachineTemplateToHardware() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); +public class VirtualMachineTemplateInVirtualDatacenterToHardwareTest { + @SuppressWarnings("unchecked") + public void testVirtualMachineTemplateToHardware() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB - dto.setCpuRequired(5); - dto.setRamRequired(2048); - dto.addLink(new RESTLink("edit", "http://foo/bar")); - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB + dto.setCpuRequired(5); + dto.setRamRequired(2048); + dto.addLink(new RESTLink("edit", "http://foo/bar")); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); - VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); - vdcDto.setId(6); - vdcDto.setHypervisorType(HypervisorType.VMX_04); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); + VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); + vdcDto.setId(6); + vdcDto.setHypervisorType(HypervisorType.VMX_04); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); - Hardware hardware = - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - verify(vdcToLocation); + verify(vdcToLocation); - assertEquals(hardware.getProviderId(), template.getId().toString()); - assertEquals(hardware.getId(), template.getId() + "/" + vdc.getId()); - assertEquals(hardware.getName(), template.getName()); - assertEquals(hardware.getUri(), URI.create("http://foo/bar")); + assertEquals(hardware.getProviderId(), template.getId().toString()); + assertEquals(hardware.getId(), template.getId() + "/" + vdc.getId()); + assertEquals(hardware.getName(), template.getName()); + assertEquals(hardware.getUri(), URI.create("http://foo/bar")); - assertEquals(hardware.getRam(), template.getRamRequired()); - assertEquals(hardware.getProcessors().size(), 1); - assertEquals(hardware.getProcessors().get(0).getCores(), (double) template.getCpuRequired()); - assertEquals(hardware.getProcessors().get(0).getSpeed(), + assertEquals(hardware.getRam(), template.getRamRequired()); + assertEquals(hardware.getProcessors().size(), 1); + assertEquals(hardware.getProcessors().get(0).getCores(), (double) template.getCpuRequired()); + assertEquals(hardware.getProcessors().get(0).getSpeed(), VirtualMachineTemplateInVirtualDatacenterToHardware.DEFAULT_CORE_SPEED); - assertEquals(hardware.getVolumes().size(), 1); - assertEquals(hardware.getVolumes().get(0).getSize(), 50F); - assertEquals(hardware.getVolumes().get(0).getType(), Volume.Type.LOCAL); - assertEquals(hardware.getVolumes().get(0).isBootDevice(), true); - assertEquals(hardware.getVolumes().get(0).isDurable(), false); - } + assertEquals(hardware.getVolumes().size(), 1); + assertEquals(hardware.getVolumes().get(0).getSize(), 50F); + assertEquals(hardware.getVolumes().get(0).getType(), Volume.Type.LOCAL); + assertEquals(hardware.getVolumes().get(0).isBootDevice(), true); + assertEquals(hardware.getVolumes().get(0).isDurable(), false); + } - @SuppressWarnings("unchecked") - public void testConvertWithoutEditLink() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); + @SuppressWarnings("unchecked") + public void testConvertWithoutEditLink() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB - dto.setCpuRequired(5); - dto.setRamRequired(2048); - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB + dto.setCpuRequired(5); + dto.setRamRequired(2048); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); - VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); - vdcDto.setId(6); - vdcDto.setHypervisorType(HypervisorType.VMX_04); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); + VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); + vdcDto.setId(6); + vdcDto.setHypervisorType(HypervisorType.VMX_04); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); - Hardware hardware = - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - verify(vdcToLocation); + verify(vdcToLocation); - assertNull(hardware.getUri()); - } + assertNull(hardware.getUri()); + } - @SuppressWarnings("unchecked") - @Test(expectedExceptions = NullPointerException.class) - public void testConvertWithoutId() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); + @SuppressWarnings("unchecked") + @Test(expectedExceptions = NullPointerException.class) + public void testConvertWithoutId() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - VirtualMachineTemplate template = - wrap(context, VirtualMachineTemplate.class, new VirtualMachineTemplateDto()); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, new VirtualDatacenterDto()); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, new VirtualMachineTemplateDto()); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, new VirtualDatacenterDto()); - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - } + function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + } - @SuppressWarnings("unchecked") - public void testConvertWithoutCpu() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); + @SuppressWarnings("unchecked") + public void testConvertWithoutCpu() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB - dto.setRamRequired(2048); - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB + dto.setRamRequired(2048); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); - VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); - vdcDto.setId(6); - vdcDto.setHypervisorType(HypervisorType.VMX_04); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); + VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); + vdcDto.setId(6); + vdcDto.setHypervisorType(HypervisorType.VMX_04); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); - Hardware hardware = - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - verify(vdcToLocation); + verify(vdcToLocation); - assertEquals(hardware.getProcessors().size(), 1); - assertEquals(hardware.getProcessors().get(0).getCores(), 0D); - } + assertEquals(hardware.getProcessors().size(), 1); + assertEquals(hardware.getProcessors().get(0).getCores(), 0D); + } - @SuppressWarnings("unchecked") - public void testConvertWithoutRam() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); + @SuppressWarnings("unchecked") + public void testConvertWithoutRam() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB - dto.setCpuRequired(5); - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB + dto.setCpuRequired(5); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); - VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); - vdcDto.setId(6); - vdcDto.setHypervisorType(HypervisorType.VMX_04); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); + VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); + vdcDto.setId(6); + vdcDto.setHypervisorType(HypervisorType.VMX_04); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); - Hardware hardware = - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - verify(vdcToLocation); + verify(vdcToLocation); - assertEquals(hardware.getRam(), 0); - } + assertEquals(hardware.getRam(), 0); + } - @SuppressWarnings("unchecked") - public void testConvertWithoutHd() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function vdcToLocation = mockVirtualDatacenterToLocation(); - VirtualMachineTemplateInVirtualDatacenterToHardware function = - new VirtualMachineTemplateInVirtualDatacenterToHardware(vdcToLocation); + @SuppressWarnings("unchecked") + public void testConvertWithoutHd() { + RestContext context = EasyMock.createMock(RestContext.class); + Function vdcToLocation = mockVirtualDatacenterToLocation(); + VirtualMachineTemplateInVirtualDatacenterToHardware function = new VirtualMachineTemplateInVirtualDatacenterToHardware( + vdcToLocation); - // VirtualMachineTemplate domain object does not have a builder, it is read only - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.setCpuRequired(5); - dto.setRamRequired(2048); - VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); + // VirtualMachineTemplate domain object does not have a builder, it is + // read only + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.setCpuRequired(5); + dto.setRamRequired(2048); + VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto); - VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); - vdcDto.setId(6); - vdcDto.setHypervisorType(HypervisorType.VMX_04); - VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); + VirtualDatacenterDto vdcDto = new VirtualDatacenterDto(); + vdcDto.setId(6); + vdcDto.setHypervisorType(HypervisorType.VMX_04); + VirtualDatacenter vdc = wrap(context, VirtualDatacenter.class, vdcDto); - Hardware hardware = - function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); + Hardware hardware = function.apply(new VirtualMachineTemplateInVirtualDatacenter(template, vdc)); - verify(vdcToLocation); + verify(vdcToLocation); - assertEquals(hardware.getVolumes().size(), 1); - assertEquals(hardware.getVolumes().get(0).getSize(), 0F); - } + assertEquals(hardware.getVolumes().size(), 1); + assertEquals(hardware.getVolumes().get(0).getSize(), 0F); + } - @SuppressWarnings("unchecked") - private static Function mockVirtualDatacenterToLocation() - { - Function mock = EasyMock.createMock(Function.class); - expect(mock.apply(anyObject(VirtualDatacenter.class))).andReturn(null); - replay(mock); - return mock; - } + @SuppressWarnings("unchecked") + private static Function mockVirtualDatacenterToLocation() { + Function mock = EasyMock.createMock(Function.class); + expect(mock.apply(anyObject(VirtualDatacenter.class))).andReturn(null); + replay(mock); + return mock; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImageTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImageTest.java index 6cf6c2d935..8ca7319609 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImageTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineTemplateToImageTest.java @@ -53,89 +53,79 @@ import com.google.common.base.Supplier; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineTemplateToImageTest") -public class VirtualMachineTemplateToImageTest -{ - @SuppressWarnings("unchecked") - public void testVirtualMachineTemplateToImage() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function dcToLocation = mockDatacenterToLocation(); - Supplier> regionMap = mockRegionMap(); - VirtualMachineTemplateToImage function = - new VirtualMachineTemplateToImage(dcToLocation, regionMap); +public class VirtualMachineTemplateToImageTest { + @SuppressWarnings("unchecked") + public void testVirtualMachineTemplateToImage() { + RestContext context = EasyMock.createMock(RestContext.class); + Function dcToLocation = mockDatacenterToLocation(); + Supplier> regionMap = mockRegionMap(); + VirtualMachineTemplateToImage function = new VirtualMachineTemplateToImage(dcToLocation, regionMap); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.addLink(new RESTLink("diskfile", "http://foo/bar")); - dto.addLink(new RESTLink("datacenter", "http://foo/bar/4")); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.addLink(new RESTLink("diskfile", "http://foo/bar")); + dto.addLink(new RESTLink("datacenter", "http://foo/bar/4")); - Image image = function.apply(wrap(context, VirtualMachineTemplate.class, dto)); + Image image = function.apply(wrap(context, VirtualMachineTemplate.class, dto)); - verify(regionMap); - verify(dcToLocation); + verify(regionMap); + verify(dcToLocation); - assertEquals(image.getId(), dto.getId().toString()); - assertEquals(image.getName(), dto.getName()); - assertEquals(image.getDescription(), dto.getDescription()); - assertEquals(image.getUri(), URI.create("http://foo/bar")); - assertEquals(image.getOperatingSystem(), - OperatingSystem.builder().description(dto.getName()).build()); - } + assertEquals(image.getId(), dto.getId().toString()); + assertEquals(image.getName(), dto.getName()); + assertEquals(image.getDescription(), dto.getDescription()); + assertEquals(image.getUri(), URI.create("http://foo/bar")); + assertEquals(image.getOperatingSystem(), OperatingSystem.builder().description(dto.getName()).build()); + } - @SuppressWarnings("unchecked") - public void testConvertWithoutDownloadLink() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function dcToLocation = mockDatacenterToLocation(); - Supplier> regionMap = mockRegionMap(); - VirtualMachineTemplateToImage function = - new VirtualMachineTemplateToImage(dcToLocation, regionMap); + @SuppressWarnings("unchecked") + public void testConvertWithoutDownloadLink() { + RestContext context = EasyMock.createMock(RestContext.class); + Function dcToLocation = mockDatacenterToLocation(); + Supplier> regionMap = mockRegionMap(); + VirtualMachineTemplateToImage function = new VirtualMachineTemplateToImage(dcToLocation, regionMap); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - dto.setId(5); - dto.setName("Template"); - dto.setDescription("Template description"); - dto.addLink(new RESTLink("datacenter", "http://foo/bar/4")); + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + dto.setId(5); + dto.setName("Template"); + dto.setDescription("Template description"); + dto.addLink(new RESTLink("datacenter", "http://foo/bar/4")); - Image image = function.apply(wrap(context, VirtualMachineTemplate.class, dto)); + Image image = function.apply(wrap(context, VirtualMachineTemplate.class, dto)); - verify(regionMap); - verify(dcToLocation); + verify(regionMap); + verify(dcToLocation); - assertNull(image.getUri()); - } + assertNull(image.getUri()); + } - @SuppressWarnings("unchecked") - @Test(expectedExceptions = NullPointerException.class) - public void testConvertWithoutId() - { - RestContext context = EasyMock.createMock(RestContext.class); - Function dcToLocation = mockDatacenterToLocation(); - Supplier> regionMap = mockRegionMap(); - VirtualMachineTemplateToImage function = - new VirtualMachineTemplateToImage(dcToLocation, regionMap); + @SuppressWarnings("unchecked") + @Test(expectedExceptions = NullPointerException.class) + public void testConvertWithoutId() { + RestContext context = EasyMock.createMock(RestContext.class); + Function dcToLocation = mockDatacenterToLocation(); + Supplier> regionMap = mockRegionMap(); + VirtualMachineTemplateToImage function = new VirtualMachineTemplateToImage(dcToLocation, regionMap); - VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); - function.apply(wrap(context, VirtualMachineTemplate.class, dto)); - } + VirtualMachineTemplateDto dto = new VirtualMachineTemplateDto(); + function.apply(wrap(context, VirtualMachineTemplate.class, dto)); + } - @SuppressWarnings("unchecked") - private static Function mockDatacenterToLocation() - { - Function mock = EasyMock.createMock(Function.class); - expect(mock.apply(anyObject(Datacenter.class))).andReturn(null); - replay(mock); - return mock; - } + @SuppressWarnings("unchecked") + private static Function mockDatacenterToLocation() { + Function mock = EasyMock.createMock(Function.class); + expect(mock.apply(anyObject(Datacenter.class))).andReturn(null); + replay(mock); + return mock; + } - @SuppressWarnings("unchecked") - private static Supplier> mockRegionMap() - { - Supplier> mock = EasyMock.createMock(Supplier.class); - expect(mock.get()).andReturn(Collections.EMPTY_MAP); - replay(mock); - return mock; - } + @SuppressWarnings("unchecked") + private static Supplier> mockRegionMap() { + Supplier> mock = EasyMock.createMock(Supplier.class); + expect(mock.get()).andReturn(Collections.EMPTY_MAP); + replay(mock); + return mock; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadataTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadataTest.java index 1523e45623..0a24831924 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadataTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/functions/VirtualMachineToNodeMetadataTest.java @@ -64,182 +64,160 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineToNodeMetadataTest") -public class VirtualMachineToNodeMetadataTest -{ - private VirtualMachineToNodeMetadata function; +public class VirtualMachineToNodeMetadataTest { + private VirtualMachineToNodeMetadata function; - private VirtualMachineWithNodeExtendedDto vm; + private VirtualMachineWithNodeExtendedDto vm; - private PrivateIpDto privNic; + private PrivateIpDto privNic; - private PublicIpDto pubNic; + private PublicIpDto pubNic; - private ExternalIpDto extNic; + private ExternalIpDto extNic; - private Hardware hardware; + private Hardware hardware; - @BeforeMethod - public void setup() - { - vm = new VirtualMachineWithNodeExtendedDto(); - vm.setNodeName("VM"); - vm.setName("Internal name"); - vm.setId(5); - vm.setVdrpPort(22); - vm.setRam(2048); - vm.setCpu(2); - vm.setState(VirtualMachineState.ON); - vm.addLink(new RESTLink("edit", "http://foo/bar")); + @BeforeMethod + public void setup() { + vm = new VirtualMachineWithNodeExtendedDto(); + vm.setNodeName("VM"); + vm.setName("Internal name"); + vm.setId(5); + vm.setVdrpPort(22); + vm.setRam(2048); + vm.setCpu(2); + vm.setState(VirtualMachineState.ON); + vm.addLink(new RESTLink("edit", "http://foo/bar")); - privNic = new PrivateIpDto(); - privNic.setIp("192.168.1.2"); - privNic.setMac("2a:6e:40:69:84:e0"); + privNic = new PrivateIpDto(); + privNic.setIp("192.168.1.2"); + privNic.setMac("2a:6e:40:69:84:e0"); - pubNic = new PublicIpDto(); - pubNic.setIp("80.80.80.80"); - pubNic.setMac("2a:6e:40:69:84:e1"); + pubNic = new PublicIpDto(); + pubNic.setIp("80.80.80.80"); + pubNic.setMac("2a:6e:40:69:84:e1"); - extNic = new ExternalIpDto(); - extNic.setIp("10.10.10.10"); - extNic.setMac("2a:6e:40:69:84:e2"); + extNic = new ExternalIpDto(); + extNic.setIp("10.10.10.10"); + extNic.setMac("2a:6e:40:69:84:e2"); - hardware = new HardwareBuilder() // + hardware = new HardwareBuilder() // .ids("1") // .build(); - function = - new VirtualMachineToNodeMetadata(templateToImage(), - templateToHardware(), - stateToNodeState(), - virtualDatacenterToLocation()); - } + function = new VirtualMachineToNodeMetadata(templateToImage(), templateToHardware(), stateToNodeState(), + virtualDatacenterToLocation()); + } - public void testVirtualMachineToNodeMetadata() - { - VirtualAppliance vapp = EasyMock.createMock(VirtualAppliance.class); - VirtualMachine mockVm = mockVirtualMachine(vapp); + public void testVirtualMachineToNodeMetadata() { + VirtualAppliance vapp = EasyMock.createMock(VirtualAppliance.class); + VirtualMachine mockVm = mockVirtualMachine(vapp); - NodeMetadata node = function.apply(mockVm); + NodeMetadata node = function.apply(mockVm); - verify(mockVm); + verify(mockVm); - assertEquals(node.getId(), vm.getId().toString()); - assertEquals(node.getUri(), URI.create("http://foo/bar")); - assertEquals(node.getName(), vm.getNodeName()); - assertEquals(node.getGroup(), "VAPP"); - assertEquals(node.getLocation().getId(), "1"); - assertEquals(node.getLocation().getDescription(), "Mock Location"); - assertEquals(node.getImageId(), "1"); - assertEquals(node.getHardware().getId(), "1"); - assertEquals(node.getHardware().getRam(), vm.getRam()); - assertEquals(node.getHardware().getProcessors().get(0).getCores(), (double) vm.getCpu()); - assertEquals(node.getLoginPort(), vm.getVdrpPort()); - assertEquals(node.getPrivateAddresses().size(), 1); - assertEquals(node.getPublicAddresses().size(), 2); - assertEquals(Iterables.get(node.getPrivateAddresses(), 0), privNic.getIp()); - assertEquals(Iterables.get(node.getPublicAddresses(), 0), pubNic.getIp()); - assertEquals(Iterables.get(node.getPublicAddresses(), 1), extNic.getIp()); - } + assertEquals(node.getId(), vm.getId().toString()); + assertEquals(node.getUri(), URI.create("http://foo/bar")); + assertEquals(node.getName(), vm.getNodeName()); + assertEquals(node.getGroup(), "VAPP"); + assertEquals(node.getLocation().getId(), "1"); + assertEquals(node.getLocation().getDescription(), "Mock Location"); + assertEquals(node.getImageId(), "1"); + assertEquals(node.getHardware().getId(), "1"); + assertEquals(node.getHardware().getRam(), vm.getRam()); + assertEquals(node.getHardware().getProcessors().get(0).getCores(), (double) vm.getCpu()); + assertEquals(node.getLoginPort(), vm.getVdrpPort()); + assertEquals(node.getPrivateAddresses().size(), 1); + assertEquals(node.getPublicAddresses().size(), 2); + assertEquals(Iterables.get(node.getPrivateAddresses(), 0), privNic.getIp()); + assertEquals(Iterables.get(node.getPublicAddresses(), 0), pubNic.getIp()); + assertEquals(Iterables.get(node.getPublicAddresses(), 1), extNic.getIp()); + } - private VirtualMachineTemplateToImage templateToImage() - { - VirtualMachineTemplateToImage templateToImage = - EasyMock.createMock(VirtualMachineTemplateToImage.class); - Image image = EasyMock.createMock(Image.class); + private VirtualMachineTemplateToImage templateToImage() { + VirtualMachineTemplateToImage templateToImage = EasyMock.createMock(VirtualMachineTemplateToImage.class); + Image image = EasyMock.createMock(Image.class); - expect(image.getId()).andReturn("1"); - expect(image.getOperatingSystem()).andReturn(null); - expect(templateToImage.apply(anyObject(VirtualMachineTemplate.class))).andReturn(image); + expect(image.getId()).andReturn("1"); + expect(image.getOperatingSystem()).andReturn(null); + expect(templateToImage.apply(anyObject(VirtualMachineTemplate.class))).andReturn(image); - replay(image); - replay(templateToImage); + replay(image); + replay(templateToImage); - return templateToImage; - } + return templateToImage; + } - private VirtualMachineTemplateInVirtualDatacenterToHardware templateToHardware() - { - VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware = - EasyMock.createMock(VirtualMachineTemplateInVirtualDatacenterToHardware.class); + private VirtualMachineTemplateInVirtualDatacenterToHardware templateToHardware() { + VirtualMachineTemplateInVirtualDatacenterToHardware virtualMachineTemplateToHardware = EasyMock + .createMock(VirtualMachineTemplateInVirtualDatacenterToHardware.class); - expect( - virtualMachineTemplateToHardware.apply(anyObject(VirtualMachineTemplateInVirtualDatacenter.class))) + expect(virtualMachineTemplateToHardware.apply(anyObject(VirtualMachineTemplateInVirtualDatacenter.class))) .andReturn(hardware); - replay(virtualMachineTemplateToHardware); + replay(virtualMachineTemplateToHardware); - return virtualMachineTemplateToHardware; - } + return virtualMachineTemplateToHardware; + } - private VirtualDatacenterToLocation virtualDatacenterToLocation() - { - VirtualDatacenterToLocation datacenterToLocation = - EasyMock.createMock(VirtualDatacenterToLocation.class); - Location location = EasyMock.createMock(Location.class); + private VirtualDatacenterToLocation virtualDatacenterToLocation() { + VirtualDatacenterToLocation datacenterToLocation = EasyMock.createMock(VirtualDatacenterToLocation.class); + Location location = EasyMock.createMock(Location.class); - expect(location.getId()).andReturn("1"); - expect(location.getDescription()).andReturn("Mock Location"); + expect(location.getId()).andReturn("1"); + expect(location.getDescription()).andReturn("Mock Location"); - expect(datacenterToLocation.apply(anyObject(VirtualDatacenter.class))).andReturn(location); + expect(datacenterToLocation.apply(anyObject(VirtualDatacenter.class))).andReturn(location); - replay(location); - replay(datacenterToLocation); + replay(location); + replay(datacenterToLocation); - return datacenterToLocation; - } + return datacenterToLocation; + } - private VirtualMachineStateToNodeState stateToNodeState() - { - VirtualMachineStateToNodeState stateToNodeState = - EasyMock.createMock(VirtualMachineStateToNodeState.class); - expect(stateToNodeState.apply(anyObject(VirtualMachineState.class))).andReturn( - Status.RUNNING); - replay(stateToNodeState); - return stateToNodeState; - } + private VirtualMachineStateToNodeState stateToNodeState() { + VirtualMachineStateToNodeState stateToNodeState = EasyMock.createMock(VirtualMachineStateToNodeState.class); + expect(stateToNodeState.apply(anyObject(VirtualMachineState.class))).andReturn(Status.RUNNING); + replay(stateToNodeState); + return stateToNodeState; + } - private VirtualDatacenter mockVirtualDatacenter() - { - VirtualDatacenter vdc = EasyMock.createMock(VirtualDatacenter.class); - expect(vdc.getHypervisorType()).andReturn(HypervisorType.VMX_04); - expect(vdc.getDatacenter()).andReturn(null); - replay(vdc); - return vdc; - } + private VirtualDatacenter mockVirtualDatacenter() { + VirtualDatacenter vdc = EasyMock.createMock(VirtualDatacenter.class); + expect(vdc.getHypervisorType()).andReturn(HypervisorType.VMX_04); + expect(vdc.getDatacenter()).andReturn(null); + replay(vdc); + return vdc; + } - private VirtualMachineTemplate mockTemplate() - { - return EasyMock.createMock(VirtualMachineTemplate.class); - } + private VirtualMachineTemplate mockTemplate() { + return EasyMock.createMock(VirtualMachineTemplate.class); + } - @SuppressWarnings("unchecked") - private VirtualMachine mockVirtualMachine(final VirtualAppliance vapp) - { - VirtualMachine mockVm = EasyMock.createMock(VirtualMachine.class); + @SuppressWarnings("unchecked") + private VirtualMachine mockVirtualMachine(final VirtualAppliance vapp) { + VirtualMachine mockVm = EasyMock.createMock(VirtualMachine.class); - Ip< ? , ? > mockPrivNic = - wrap(EasyMock.createMock(RestContext.class), PrivateIp.class, privNic); - Ip< ? , ? > mockPubNic = - wrap(EasyMock.createMock(RestContext.class), PublicIp.class, pubNic); - Ip< ? , ? > mockExtNic = - wrap(EasyMock.createMock(RestContext.class), ExternalIp.class, extNic); + Ip mockPrivNic = wrap(EasyMock.createMock(RestContext.class), PrivateIp.class, privNic); + Ip mockPubNic = wrap(EasyMock.createMock(RestContext.class), PublicIp.class, pubNic); + Ip mockExtNic = wrap(EasyMock.createMock(RestContext.class), ExternalIp.class, extNic); - expect(mockVm.getId()).andReturn(vm.getId()); - expect(mockVm.getURI()).andReturn(URI.create(vm.getEditLink().getHref())); - expect(mockVm.getNameLabel()).andReturn(vm.getNodeName()); - expect(mockVm.getTemplate()).andReturn(mockTemplate()); - expect(mockVm.getState()).andReturn(vm.getState()); - expect(mockVm.listAttachedNics()).andReturn( - ImmutableList.> of(mockPubNic, mockPrivNic, mockExtNic)); - expect(mockVm.getVirtualAppliance()).andReturn(vapp); - expect(vapp.getName()).andReturn("VAPP"); - expect(mockVm.getVirtualDatacenter()).andReturn(mockVirtualDatacenter()); - expect(mockVm.getRam()).andReturn(vm.getRam()); - expect(mockVm.getCpu()).andReturn(vm.getCpu()); + expect(mockVm.getId()).andReturn(vm.getId()); + expect(mockVm.getURI()).andReturn(URI.create(vm.getEditLink().getHref())); + expect(mockVm.getNameLabel()).andReturn(vm.getNodeName()); + expect(mockVm.getTemplate()).andReturn(mockTemplate()); + expect(mockVm.getState()).andReturn(vm.getState()); + expect(mockVm.listAttachedNics()).andReturn(ImmutableList.> of(mockPubNic, mockPrivNic, mockExtNic)); + expect(mockVm.getVirtualAppliance()).andReturn(vapp); + expect(vapp.getName()).andReturn("VAPP"); + expect(mockVm.getVirtualDatacenter()).andReturn(mockVirtualDatacenter()); + expect(mockVm.getRam()).andReturn(vm.getRam()); + expect(mockVm.getCpu()).andReturn(vm.getCpu()); - replay(mockVm); - replay(vapp); + replay(mockVm); + replay(vapp); - return mockVm; - } + return mockVm; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptionsTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptionsTest.java index 1f0937a2b5..13b3064b9c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptionsTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/compute/options/AbiquoTemplateOptionsTest.java @@ -30,31 +30,25 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AbiquoTemplateOptionsTest") -public class AbiquoTemplateOptionsTest -{ - public void testAs() - { - TemplateOptions options = new AbiquoTemplateOptions(); - assertEquals(options.as(AbiquoTemplateOptions.class), options); - } +public class AbiquoTemplateOptionsTest { + public void testAs() { + TemplateOptions options = new AbiquoTemplateOptions(); + assertEquals(options.as(AbiquoTemplateOptions.class), options); + } - public void testOverrideCores() - { - TemplateOptions options = new AbiquoTemplateOptions().overrideCores(5); - assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideCores(), Integer.valueOf(5)); - } + public void testOverrideCores() { + TemplateOptions options = new AbiquoTemplateOptions().overrideCores(5); + assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideCores(), Integer.valueOf(5)); + } - public void testOverrideRam() - { - TemplateOptions options = new AbiquoTemplateOptions().overrideRam(2048); - assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideRam(), - Integer.valueOf(2048)); - } + public void testOverrideRam() { + TemplateOptions options = new AbiquoTemplateOptions().overrideRam(2048); + assertEquals(options.as(AbiquoTemplateOptions.class).getOverrideRam(), Integer.valueOf(2048)); + } - public void testVncPassword() - { - TemplateOptions options = new AbiquoTemplateOptions().vncPassword("foo"); - assertEquals(options.as(AbiquoTemplateOptions.class).getVncPassword(), "foo"); - } + public void testVncPassword() { + TemplateOptions options = new AbiquoTemplateOptions().vncPassword("foo"); + assertEquals(options.as(AbiquoTemplateOptions.class).getVncPassword(), "foo"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/config/SchedulerModuleTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/config/SchedulerModuleTest.java index c8ba73da03..1f160b4b25 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/config/SchedulerModuleTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/config/SchedulerModuleTest.java @@ -36,11 +36,9 @@ import com.google.inject.name.Names; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "SchedulerModuleTest") -public class SchedulerModuleTest extends BaseInjectionTest -{ - public void testScheduledExecutorIsProvided() - { - assertNotNull(injector.getInstance(Key.get(ScheduledExecutorService.class, +public class SchedulerModuleTest extends BaseInjectionTest { + public void testScheduledExecutorIsProvided() { + assertNotNull(injector.getInstance(Key.get(ScheduledExecutorService.class, Names.named(Constants.PROPERTY_SCHEDULER_THREADS)))); - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AbiquoVersionLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AbiquoVersionLiveApiTest.java index 0219fb15f4..1998ab483d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AbiquoVersionLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AbiquoVersionLiveApiTest.java @@ -36,26 +36,20 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "AbiquoVersionLiveApiTest") -public class AbiquoVersionLiveApiTest extends BaseAbiquoLiveApiTest -{ - @Override - protected Properties setupProperties() - { - Properties overrides = super.setupProperties(); - overrides.setProperty("abiquo.api-version", "0.0"); - return overrides; - } +public class AbiquoVersionLiveApiTest extends BaseAbiquoLiveApiTest { + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.setProperty("abiquo.api-version", "0.0"); + return overrides; + } - public void testUnsupportedVersion() - { - try - { - view.getAdministrationService().getCurrentUser(); - fail("Unsupported versions in mime types should not be allowed"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.NOT_ACCEPTABLE, "406-NOT-ACCEPTABLE"); - } - } + public void testUnsupportedVersion() { + try { + view.getAdministrationService().getCurrentUser(); + fail("Unsupported versions in mime types should not be allowed"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.NOT_ACCEPTABLE, "406-NOT-ACCEPTABLE"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AdminResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AdminResources.java index ac5ae69395..5406ab4db1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AdminResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/AdminResources.java @@ -33,184 +33,168 @@ import com.abiquo.server.core.enterprise.UserDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class AdminResources -{ - public static RoleDto rolePost() - { - RoleDto role = new RoleDto(); - role.addLink(new RESTLink("privileges", - "http://localhost/api/admin/roles/1/action/privileges")); - role.setName("HAWAIAN_ADMIN"); - return role; - } +public class AdminResources { + public static RoleDto rolePost() { + RoleDto role = new RoleDto(); + role.addLink(new RESTLink("privileges", "http://localhost/api/admin/roles/1/action/privileges")); + role.setName("HAWAIAN_ADMIN"); + return role; + } - public static RoleDto rolePut() - { - RoleDto role = rolePost(); - role.setId(1); - role.addLink(new RESTLink("edit", "http://localhost/api/admin/roles/1")); + public static RoleDto rolePut() { + RoleDto role = rolePost(); + role.setId(1); + role.addLink(new RESTLink("edit", "http://localhost/api/admin/roles/1")); - return role; - } + return role; + } - public static String rolePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1/action/privileges", "privileges")); - buffer.append("false"); - buffer.append("HAWAIAN_ADMIN"); - buffer.append(""); - return buffer.toString(); - } + public static String rolePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1/action/privileges", "privileges")); + buffer.append("false"); + buffer.append("HAWAIAN_ADMIN"); + buffer.append(""); + return buffer.toString(); + } - public static String rolePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1/action/privileges", "privileges")); - buffer.append(link("/admin/roles/1", "edit")); - buffer.append("false"); - buffer.append("1"); - buffer.append("HAWAIAN_ADMIN"); - buffer.append(""); - return buffer.toString(); - } + public static String rolePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1/action/privileges", "privileges")); + buffer.append(link("/admin/roles/1", "edit")); + buffer.append("false"); + buffer.append("1"); + buffer.append("HAWAIAN_ADMIN"); + buffer.append(""); + return buffer.toString(); + } - public static DatacenterLimitsDto datacenterLimitsPost() - { - DatacenterLimitsDto limits = new DatacenterLimitsDto(); - limits.setCpuCountLimits(0, 0); - limits.setHdLimitsInMb(0, 0); - limits.setPublicIPLimits(0, 0); - limits.setRamLimitsInMb(0, 0); - limits.setStorageLimits(0, 0); - limits.setVlansLimits(0, 0); - limits.setRepositoryHardLimitsInMb(0); - limits.setRepositorySoftLimitsInMb(0); - return limits; - } + public static DatacenterLimitsDto datacenterLimitsPost() { + DatacenterLimitsDto limits = new DatacenterLimitsDto(); + limits.setCpuCountLimits(0, 0); + limits.setHdLimitsInMb(0, 0); + limits.setPublicIPLimits(0, 0); + limits.setRamLimitsInMb(0, 0); + limits.setStorageLimits(0, 0); + limits.setVlansLimits(0, 0); + limits.setRepositoryHardLimitsInMb(0); + limits.setRepositorySoftLimitsInMb(0); + return limits; + } - public static DatacenterLimitsDto datacenterLimitsPut(final EnterpriseDto enterprise) - { - DatacenterLimitsDto limits = datacenterLimitsPost(); - limits.setId(1); - limits.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/" - + enterprise.getId() + "/limits/1")); - return limits; - } + public static DatacenterLimitsDto datacenterLimitsPut(final EnterpriseDto enterprise) { + DatacenterLimitsDto limits = datacenterLimitsPost(); + limits.setId(1); + limits.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/" + enterprise.getId() + "/limits/1")); + return limits; + } - public static String datacenterLimitsPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterLimitsPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String datacenterLimitsPutPayload(final EnterpriseDto enterprise) - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/" + enterprise.getId() + "/limits/1", "edit")); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterLimitsPutPayload(final EnterpriseDto enterprise) { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/" + enterprise.getId() + "/limits/1", "edit")); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String userPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1", "role")); - buffer.append("true"); - buffer.append("ABIQUO"); - buffer.append("A hawaian user"); - buffer.append("abe.joha@aloha.com"); - buffer.append("en_US"); - buffer.append("Aberahama"); - buffer.append("abejo"); - buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); - buffer.append("Johanson"); - buffer.append(""); - return buffer.toString(); - } + public static String userPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1", "role")); + buffer.append("true"); + buffer.append("ABIQUO"); + buffer.append("A hawaian user"); + buffer.append("abe.joha@aloha.com"); + buffer.append("en_US"); + buffer.append("Aberahama"); + buffer.append("abejo"); + buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); + buffer.append("Johanson"); + buffer.append(""); + return buffer.toString(); + } - public static UserDto userPost() - { - UserDto user = new UserDto(); - user.setName("Aberahama"); - user.setSurname("Johanson"); - user.setDescription("A hawaian user"); - user.setEmail("abe.joha@aloha.com"); - user.setNick("abejo"); - user.setAuthType("ABIQUO"); - user.setLocale("en_US"); - user.setActive(true); - user.setPassword("c69a39bd64ffb77ea7ee3369dce742f3"); - user.addLink(new RESTLink("role", "http://localhost/api/admin/roles/1")); - return user; - } + public static UserDto userPost() { + UserDto user = new UserDto(); + user.setName("Aberahama"); + user.setSurname("Johanson"); + user.setDescription("A hawaian user"); + user.setEmail("abe.joha@aloha.com"); + user.setNick("abejo"); + user.setAuthType("ABIQUO"); + user.setLocale("en_US"); + user.setActive(true); + user.setPassword("c69a39bd64ffb77ea7ee3369dce742f3"); + user.addLink(new RESTLink("role", "http://localhost/api/admin/roles/1")); + return user; + } - public static String userPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1", "role")); - buffer.append(link("/admin/enterprises/1/users/1", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer - .append(link("/admin/enterprises/1/users/1/action/virtualmachines", "virtualmachines")); - buffer.append("true"); - buffer.append("ABIQUO"); - buffer.append("A hawaian user"); - buffer.append("abe.joha@aloha.com"); - buffer.append("1"); - buffer.append("en_US"); - buffer.append("Aberahama"); - buffer.append("abejo"); - buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); - buffer.append("Johanson"); - buffer.append(""); - return buffer.toString(); - } + public static String userPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1", "role")); + buffer.append(link("/admin/enterprises/1/users/1", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/admin/enterprises/1/users/1/action/virtualmachines", "virtualmachines")); + buffer.append("true"); + buffer.append("ABIQUO"); + buffer.append("A hawaian user"); + buffer.append("abe.joha@aloha.com"); + buffer.append("1"); + buffer.append("en_US"); + buffer.append("Aberahama"); + buffer.append("abejo"); + buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); + buffer.append("Johanson"); + buffer.append(""); + return buffer.toString(); + } - public static UserDto userPut() - { - UserDto user = userPost(); - user.setId(1); - user.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/users/1")); - user.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - user.addLink(new RESTLink("virtualmachines", + public static UserDto userPut() { + UserDto user = userPost(); + user.setId(1); + user.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/users/1")); + user.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + user.addLink(new RESTLink("virtualmachines", "http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines")); - return user; - } + return user; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/CloudResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/CloudResources.java index f742124716..6038649620 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/CloudResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/CloudResources.java @@ -42,492 +42,414 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class CloudResources -{ - public static VirtualDatacenterDto virtualDatacenterPost() - { - VirtualDatacenterDto virtualDatacenter = new VirtualDatacenterDto(); - virtualDatacenter.setName("VDC"); - virtualDatacenter.setHypervisorType(HypervisorType.KVM); - virtualDatacenter.setVlan(NetworkResources.vlanPost()); - return virtualDatacenter; - } +public class CloudResources { + public static VirtualDatacenterDto virtualDatacenterPost() { + VirtualDatacenterDto virtualDatacenter = new VirtualDatacenterDto(); + virtualDatacenter.setName("VDC"); + virtualDatacenter.setHypervisorType(HypervisorType.KVM); + virtualDatacenter.setVlan(NetworkResources.vlanPost()); + return virtualDatacenter; + } - public static VirtualApplianceDto virtualAppliancePost() - { - VirtualApplianceDto virtualAppliance = new VirtualApplianceDto(); - virtualAppliance.setName("VA"); - return virtualAppliance; - } + public static VirtualApplianceDto virtualAppliancePost() { + VirtualApplianceDto virtualAppliance = new VirtualApplianceDto(); + virtualAppliance.setName("VA"); + return virtualAppliance; + } - public static VirtualMachineDto virtualMachinePost() - { - VirtualMachineDto virtualMachine = new VirtualMachineDto(); - virtualMachine.setName("VM"); - return virtualMachine; - } + public static VirtualMachineDto virtualMachinePost() { + VirtualMachineDto virtualMachine = new VirtualMachineDto(); + virtualMachine.setName("VM"); + return virtualMachine; + } - public static VirtualDatacenterDto virtualDatacenterPut() - { - VirtualDatacenterDto virtualDatacenter = virtualDatacenterPost(); - virtualDatacenter.setId(1); - virtualDatacenter.addLink(new RESTLink("datacenter", - "http://localhost/api/admin/datacenters/1")); - virtualDatacenter.addLink(new RESTLink("disks", - "http://localhost/api/cloud/virtualdatacenters/1/disks")); - virtualDatacenter.addLink(new RESTLink("enterprise", - "http://localhost/api/admin/enterprises/1")); - virtualDatacenter.addLink(new RESTLink("edit", - "http://localhost/api/cloud/virtualdatacenters/1")); - virtualDatacenter.addLink(new RESTLink("tiers", - "http://localhost/api/cloud/virtualdatacenters/1/tiers")); - virtualDatacenter.addLink(new RESTLink("virtualappliances", + public static VirtualDatacenterDto virtualDatacenterPut() { + VirtualDatacenterDto virtualDatacenter = virtualDatacenterPost(); + virtualDatacenter.setId(1); + virtualDatacenter.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + virtualDatacenter.addLink(new RESTLink("disks", "http://localhost/api/cloud/virtualdatacenters/1/disks")); + virtualDatacenter.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + virtualDatacenter.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1")); + virtualDatacenter.addLink(new RESTLink("tiers", "http://localhost/api/cloud/virtualdatacenters/1/tiers")); + virtualDatacenter.addLink(new RESTLink("virtualappliances", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances")); - virtualDatacenter.addLink(new RESTLink("volumes", - "http://localhost/api/cloud/virtualdatacenters/1/volumes")); - virtualDatacenter.addLink(new RESTLink("privatenetworks", + virtualDatacenter.addLink(new RESTLink("volumes", "http://localhost/api/cloud/virtualdatacenters/1/volumes")); + virtualDatacenter.addLink(new RESTLink("privatenetworks", "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks")); - virtualDatacenter.addLink(new RESTLink("defaultnetwork", + virtualDatacenter.addLink(new RESTLink("defaultnetwork", "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1")); - virtualDatacenter.addLink(new RESTLink("defaultvlan", + virtualDatacenter.addLink(new RESTLink("defaultvlan", "http://localhost/api/cloud/virtualdatacenters/1/action/defaultvlan")); - virtualDatacenter.addLink(new RESTLink("topurchase", + virtualDatacenter.addLink(new RESTLink("topurchase", "http://localhost/api/cloud/virtualdatacenters/1/publicips/topurchase")); - virtualDatacenter.addLink(new RESTLink("purchased", + virtualDatacenter.addLink(new RESTLink("purchased", "http://localhost/api/cloud/virtualdatacenters/1/publicips/purchased")); - virtualDatacenter.addLink(new RESTLink("templates", + virtualDatacenter.addLink(new RESTLink("templates", "http://localhost/api/cloud/virtualdatacenters/1/action/templates")); - return virtualDatacenter; + return virtualDatacenter; - } + } - public static VirtualApplianceDto virtualAppliancePut() - { - VirtualApplianceDto virtualAppliance = virtualAppliancePost(); - virtualAppliance.setId(1); - virtualAppliance.addLink(new RESTLink("virtualdatacenter", - "http://localhost/api/cloud/virtualdatacenters/1")); - virtualAppliance.addLink(new RESTLink("deploy", + public static VirtualApplianceDto virtualAppliancePut() { + VirtualApplianceDto virtualAppliance = virtualAppliancePost(); + virtualAppliance.setId(1); + virtualAppliance.addLink(new RESTLink("virtualdatacenter", "http://localhost/api/cloud/virtualdatacenters/1")); + virtualAppliance.addLink(new RESTLink("deploy", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy")); - virtualAppliance.addLink(new RESTLink("edit", + virtualAppliance.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1")); - virtualAppliance.addLink(new RESTLink("state", + virtualAppliance.addLink(new RESTLink("state", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/state")); - virtualAppliance.addLink(new RESTLink("undeploy", + virtualAppliance.addLink(new RESTLink("undeploy", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy")); - virtualAppliance.addLink(new RESTLink("virtualmachines", + virtualAppliance.addLink(new RESTLink("virtualmachines", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines")); - virtualAppliance.addLink(new RESTLink("price", + virtualAppliance.addLink(new RESTLink("price", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/price")); - return virtualAppliance; - } + return virtualAppliance; + } - public static VirtualMachineDto virtualMachinePut() - { - VirtualMachineDto virtualMachine = virtualMachinePost(); - virtualMachine.setId(1); - virtualMachine - .addLink(new RESTLink("deploy", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy")); - virtualMachine - .addLink(new RESTLink("disks", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks")); - virtualMachine - .addLink(new RESTLink("edit", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1")); - virtualMachine - .addLink(new RESTLink("state", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state")); - virtualMachine - .addLink(new RESTLink("reset", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset")); - virtualMachine - .addLink(new RESTLink("tasks", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks")); - virtualMachine - .addLink(new RESTLink("undeploy", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy")); - virtualMachine - .addLink(new RESTLink("persistent", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/persistent")); - virtualMachine.addLink(new RESTLink("virtualappliance", + public static VirtualMachineDto virtualMachinePut() { + VirtualMachineDto virtualMachine = virtualMachinePost(); + virtualMachine.setId(1); + virtualMachine.addLink(new RESTLink("deploy", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy")); + virtualMachine.addLink(new RESTLink("disks", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks")); + virtualMachine.addLink(new RESTLink("edit", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1")); + virtualMachine.addLink(new RESTLink("state", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state")); + virtualMachine.addLink(new RESTLink("reset", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset")); + virtualMachine.addLink(new RESTLink("tasks", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks")); + virtualMachine.addLink(new RESTLink("undeploy", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy")); + virtualMachine.addLink(new RESTLink("persistent", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/persistent")); + virtualMachine.addLink(new RESTLink("virtualappliance", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1")); - virtualMachine - .addLink(new RESTLink("virtualmachinetemplate", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1")); - virtualMachine - .addLink(new RESTLink("nics", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics")); - virtualMachine - .addLink(new RESTLink("volumes", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes")); - virtualMachine + virtualMachine.addLink(new RESTLink("virtualmachinetemplate", + "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1")); + virtualMachine.addLink(new RESTLink("nics", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics")); + virtualMachine.addLink(new RESTLink("volumes", + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes")); + virtualMachine .addLink(new RESTLink("configurations", - "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations")); - return virtualMachine; - } + "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations")); + return virtualMachine; + } - public static VirtualMachineStateDto virtualMachineState() - { - VirtualMachineStateDto state = new VirtualMachineStateDto(); - state.setState(VirtualMachineState.ON); - return state; - } + public static VirtualMachineStateDto virtualMachineState() { + VirtualMachineStateDto state = new VirtualMachineStateDto(); + state.setState(VirtualMachineState.ON); + return state; + } - public static String virtualMachineStatePayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("ON"); - buffer.append(""); - return buffer.toString(); - } + public static String virtualMachineStatePayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("ON"); + buffer.append(""); + return buffer.toString(); + } - public static VolumeManagementDto volumePost() - { - VolumeManagementDto volume = new VolumeManagementDto(); - volume.setName("Volume"); - volume.setSizeInMB(1024); - volume.addLink(new RESTLink("tier", - "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); - return volume; - } + public static VolumeManagementDto volumePost() { + VolumeManagementDto volume = new VolumeManagementDto(); + volume.setName("Volume"); + volume.setSizeInMB(1024); + volume.addLink(new RESTLink("tier", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); + return volume; + } - public static VolumeManagementDto volumePut() - { - VolumeManagementDto volume = volumePost(); - volume.setId(1); - volume.setState(VolumeState.DETACHED.name()); + public static VolumeManagementDto volumePut() { + VolumeManagementDto volume = volumePost(); + volume.setId(1); + volume.setState(VolumeState.DETACHED.name()); - volume.getLinks().clear(); + volume.getLinks().clear(); - RESTLink mappings = - new RESTLink("action", - "http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/initiatormappings"); - mappings.setTitle("initiator mappings"); - volume.addLink(mappings); - volume.addLink(new RESTLink("edit", - "http://localhost/api/cloud/virtualdatacenters/1/volumes/1")); - volume.addLink(new RESTLink("tier", - "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); - volume.addLink(new RESTLink("virtualdatacenter", - "http://localhost/api/cloud/virtualdatacenters/1")); - return volume; - } + RESTLink mappings = new RESTLink("action", + "http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/initiatormappings"); + mappings.setTitle("initiator mappings"); + volume.addLink(mappings); + volume.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/volumes/1")); + volume.addLink(new RESTLink("tier", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); + volume.addLink(new RESTLink("virtualdatacenter", "http://localhost/api/cloud/virtualdatacenters/1")); + return volume; + } - public static VirtualMachineTemplateDto virtualMachineTemplatePut() - { - VirtualMachineTemplateDto template = new VirtualMachineTemplateDto(); - template.setId(10); - template.setName("m0n0wall"); - template.setDiskFormatType(DiskFormatType.VMDK_FLAT.toString()); - template.setPath("1/abiquo-repository.abiquo.com/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk"); - template.setDiskFileSize(27262976); - template.setCpuRequired(1); - template.setRamRequired(128); - template.setCpuRequired(27262976); - template.setCreationUser("SYSTEM"); - template - .setIconUrl("http://ww1.prweb.com/prfiles/2010/08/02/2823234/gI_0_HakunaLogoMedium.jpg"); - template.addLink(new RESTLink("icon", "http://localhost/api/config/icons/1")); - template.addLink(new RESTLink("category", "http://localhost/api/config/categories/1")); + public static VirtualMachineTemplateDto virtualMachineTemplatePut() { + VirtualMachineTemplateDto template = new VirtualMachineTemplateDto(); + template.setId(10); + template.setName("m0n0wall"); + template.setDiskFormatType(DiskFormatType.VMDK_FLAT.toString()); + template.setPath("1/abiquo-repository.abiquo.com/m0n0wall/m0n0wall-1.3b18-i386-flat.vmdk"); + template.setDiskFileSize(27262976); + template.setCpuRequired(1); + template.setRamRequired(128); + template.setCpuRequired(27262976); + template.setCreationUser("SYSTEM"); + template.setIconUrl("http://ww1.prweb.com/prfiles/2010/08/02/2823234/gI_0_HakunaLogoMedium.jpg"); + template.addLink(new RESTLink("icon", "http://localhost/api/config/icons/1")); + template.addLink(new RESTLink("category", "http://localhost/api/config/categories/1")); - return template; + return template; - } + } - public static TierDto cloudTierPut() - { - TierDto tier = new TierDto(); - tier.setId(1); - tier.setEnabled(true); - tier.setName("Tier"); - tier.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); - return tier; - } + public static TierDto cloudTierPut() { + TierDto tier = new TierDto(); + tier.setId(1); + tier.setEnabled(true); + tier.setName("Tier"); + tier.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); + return tier; + } - public static VirtualMachineTaskDto deployOptions() - { - VirtualMachineTaskDto deploy = new VirtualMachineTaskDto(); - deploy.setForceEnterpriseSoftLimits(false); - return deploy; + public static VirtualMachineTaskDto deployOptions() { + VirtualMachineTaskDto deploy = new VirtualMachineTaskDto(); + deploy.setForceEnterpriseSoftLimits(false); + return deploy; - } + } - public static VirtualMachineTaskDto undeployOptions() - { - VirtualMachineTaskDto deploy = new VirtualMachineTaskDto(); - deploy.setForceUndeploy(true); - return deploy; - } + public static VirtualMachineTaskDto undeployOptions() { + VirtualMachineTaskDto deploy = new VirtualMachineTaskDto(); + deploy.setForceUndeploy(true); + return deploy; + } - public static String virtualDatacenterPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("KVM"); - buffer.append("VDC"); - buffer.append(NetworkResources.vlanNetworkPostPayload()); - buffer.append(""); - return buffer.toString(); - } + public static String virtualDatacenterPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("KVM"); + buffer.append("VDC"); + buffer.append(NetworkResources.vlanNetworkPostPayload()); + buffer.append(""); + return buffer.toString(); + } - public static String virtualAppliancePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("VA"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String virtualAppliancePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("VA"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String virtualMachinePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("VM"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String virtualMachinePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("VM"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String virtualDatacenterPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/cloud/virtualdatacenters/1/disks", "disks")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer.append(link("/cloud/virtualdatacenters/1", "edit")); - buffer.append(link("/cloud/virtualdatacenters/1/tiers", "tiers")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances", "virtualappliances")); - buffer.append(link("/cloud/virtualdatacenters/1/volumes", "volumes")); - buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks", "privatenetworks")); - buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1", "defaultnetwork")); - buffer.append(link("/cloud/virtualdatacenters/1/action/defaultvlan", "defaultvlan")); - buffer.append(link("/cloud/virtualdatacenters/1/publicips/topurchase", "topurchase")); - buffer.append(link("/cloud/virtualdatacenters/1/publicips/purchased", "purchased")); - buffer.append(link("/cloud/virtualdatacenters/1/action/templates", "templates")); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("KVM"); - buffer.append("1"); - buffer.append("VDC"); - buffer.append(NetworkResources.vlanNetworkPostPayload()); - buffer.append(""); - return buffer.toString(); - } + public static String virtualDatacenterPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/cloud/virtualdatacenters/1/disks", "disks")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/cloud/virtualdatacenters/1", "edit")); + buffer.append(link("/cloud/virtualdatacenters/1/tiers", "tiers")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances", "virtualappliances")); + buffer.append(link("/cloud/virtualdatacenters/1/volumes", "volumes")); + buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks", "privatenetworks")); + buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1", "defaultnetwork")); + buffer.append(link("/cloud/virtualdatacenters/1/action/defaultvlan", "defaultvlan")); + buffer.append(link("/cloud/virtualdatacenters/1/publicips/topurchase", "topurchase")); + buffer.append(link("/cloud/virtualdatacenters/1/publicips/purchased", "purchased")); + buffer.append(link("/cloud/virtualdatacenters/1/action/templates", "templates")); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("KVM"); + buffer.append("1"); + buffer.append("VDC"); + buffer.append(NetworkResources.vlanNetworkPostPayload()); + buffer.append(""); + return buffer.toString(); + } - public static String virtualDatacenterRefPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append(""); - return buffer.toString(); - } + public static String virtualDatacenterRefPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); + buffer.append(""); + return buffer.toString(); + } - public static String virtualAppliancePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy", - "deploy")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1", "edit")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/state", "state")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy", + public static String virtualAppliancePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy", "deploy")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1", "edit")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/state", "state")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy", "undeploy")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines", "virtualmachines")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/price", "price")); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("VA"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } + + public static String virtualMachinePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy", "deploy")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks", "disks")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1", "edit")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state", "state")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset", "reset")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks", "tasks")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy", "undeploy")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines", - "virtualmachines")); - buffer - .append(link("/cloud/virtualdatacenters/1/virtualappliances/1/action/price", "price")); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("VA"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } - - public static String virtualMachinePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy", - "deploy")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks", - "disks")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1", - "edit")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state", "state")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset", - "reset")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks", "tasks")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy", - "undeploy")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/persistent", + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/persistent", "persistent")); - buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1", "virtualappliance")); - buffer.append(link( - "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1", "virtualappliance")); + buffer.append(link("/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", "virtualmachinetemplate")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics", - "nics")); - buffer.append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes", - "volumes")); - buffer - .append(link( - "/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations", - "configurations")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics", "nics")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes", "volumes")); + buffer.append(link("/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations", + "configurations")); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("0"); - buffer.append("0"); - buffer.append("VM"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("0"); + buffer.append("0"); + buffer.append("VM"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String volumePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); - buffer.append("Volume"); - buffer.append("1024"); - buffer.append(""); - return buffer.toString(); - } + public static String volumePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); + buffer.append("Volume"); + buffer.append("1024"); + buffer.append(""); + return buffer.toString(); + } - public static String volumePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/volumes/1/action/initiatormappings", - "action", "initiator mappings")); - buffer.append(link("/cloud/virtualdatacenters/1/volumes/1", "edit")); - buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append("1"); - buffer.append("Volume"); - buffer.append("DETACHED"); - buffer.append("1024"); - buffer.append(""); - return buffer.toString(); - } + public static String volumePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/volumes/1/action/initiatormappings", "action", + "initiator mappings")); + buffer.append(link("/cloud/virtualdatacenters/1/volumes/1", "edit")); + buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); + buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); + buffer.append("1"); + buffer.append("Volume"); + buffer.append("DETACHED"); + buffer.append("1024"); + buffer.append(""); + return buffer.toString(); + } - public static String cloudTierPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "edit")); - buffer.append("true"); - buffer.append("1"); - buffer.append("Tier"); - buffer.append(""); - return buffer.toString(); - } + public static String cloudTierPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "edit")); + buffer.append("true"); + buffer.append("1"); + buffer.append("Tier"); + buffer.append(""); + return buffer.toString(); + } - public static String deployPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("false"); - buffer.append(""); - return buffer.toString(); - } + public static String deployPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("false"); + buffer.append(""); + return buffer.toString(); + } - public static String undeployPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("false"); - buffer.append("true"); - buffer.append(""); - return buffer.toString(); - } + public static String undeployPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("false"); + buffer.append("true"); + buffer.append(""); + return buffer.toString(); + } - public static DiskManagementDto hardDiskPost() - { - DiskManagementDto disk = new DiskManagementDto(); - disk.setSizeInMb(1024L); - return disk; - } + public static DiskManagementDto hardDiskPost() { + DiskManagementDto disk = new DiskManagementDto(); + disk.setSizeInMb(1024L); + return disk; + } - public static DiskManagementDto hardDiskPut() - { - DiskManagementDto disk = hardDiskPost(); - disk.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/disks/1")); - disk.addLink(new RESTLink("virtualdatacenter", - "http://localhost/api/cloud/virtualdatacenters/1")); - return disk; - } + public static DiskManagementDto hardDiskPut() { + DiskManagementDto disk = hardDiskPost(); + disk.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/disks/1")); + disk.addLink(new RESTLink("virtualdatacenter", "http://localhost/api/cloud/virtualdatacenters/1")); + return disk; + } - public static String hardDiskPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("1024"); - buffer.append(""); - return buffer.toString(); - } + public static String hardDiskPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("1024"); + buffer.append(""); + return buffer.toString(); + } - public static String hardDiskPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append(link("/cloud/virtualdatacenters/1/disks/1", "edit")); - buffer.append("0"); - buffer.append("1024"); - buffer.append(""); - return buffer.toString(); - } + public static String hardDiskPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); + buffer.append(link("/cloud/virtualdatacenters/1/disks/1", "edit")); + buffer.append("0"); + buffer.append("1024"); + buffer.append(""); + return buffer.toString(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/ConfigResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/ConfigResources.java index f3df44905a..9c07bbcca3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/ConfigResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/ConfigResources.java @@ -37,146 +37,128 @@ import com.google.common.io.Resources; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class ConfigResources -{ - public static LicenseDto licensePost() - { - LicenseDto license = new LicenseDto(); - license.setCode(readLicense("license/expired")); - license.setCustomerid("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); - return license; - } +public class ConfigResources { + public static LicenseDto licensePost() { + LicenseDto license = new LicenseDto(); + license.setCode(readLicense("license/expired")); + license.setCustomerid("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); + return license; + } - public static CategoryDto categoryPost() - { - CategoryDto category = new CategoryDto(); - category.setName("category"); - category.setErasable(false); - category.setDefaultCategory(false); - return category; - } + public static CategoryDto categoryPost() { + CategoryDto category = new CategoryDto(); + category.setName("category"); + category.setErasable(false); + category.setDefaultCategory(false); + return category; + } - public static CategoryDto categoryPut() - { - CategoryDto category = categoryPost(); - category.setId(1); - category.addLink(new RESTLink("edit", "http://localhost/api/config/categories/1")); - return category; - } + public static CategoryDto categoryPut() { + CategoryDto category = categoryPost(); + category.setId(1); + category.addLink(new RESTLink("edit", "http://localhost/api/config/categories/1")); + return category; + } - public static LicenseDto licensePut() - { - LicenseDto license = licensePost(); - license.setId(1); - license.addLink(new RESTLink("edit", "http://localhost/api/config/licenses/1")); + public static LicenseDto licensePut() { + LicenseDto license = licensePost(); + license.setId(1); + license.addLink(new RESTLink("edit", "http://localhost/api/config/licenses/1")); - return license; - } + return license; + } - public static SystemPropertyDto propertyPut() - { - SystemPropertyDto property = new SystemPropertyDto(); - property.setId(1); - property.setDescription("Time interval in seconds"); - property.setValue("10"); - property.setName("api.applibrary.ovfpackagesDownloadingProgressUpdateInterval"); - property.addLink(new RESTLink("edit", "http://localhost/api/config/properties/1")); + public static SystemPropertyDto propertyPut() { + SystemPropertyDto property = new SystemPropertyDto(); + property.setId(1); + property.setDescription("Time interval in seconds"); + property.setValue("10"); + property.setName("api.applibrary.ovfpackagesDownloadingProgressUpdateInterval"); + property.addLink(new RESTLink("edit", "http://localhost/api/config/properties/1")); - return property; - } + return property; + } - public static String licensePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/config/licenses/1", "edit")); - buffer.append("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); - buffer.append("" + readLicense("license/expired") + ""); - buffer.append("1"); - buffer.append(""); - return buffer.toString(); - } + public static String licensePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/config/licenses/1", "edit")); + buffer.append("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); + buffer.append("" + readLicense("license/expired") + ""); + buffer.append("1"); + buffer.append(""); + return buffer.toString(); + } - public static String licensePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); - buffer.append("" + readLicense("license/expired") + ""); - buffer.append(""); - return buffer.toString(); - } + public static String licensePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("3bca6d1d-5fe2-42c5-82ea-a5276ea8c71c"); + buffer.append("" + readLicense("license/expired") + ""); + buffer.append(""); + return buffer.toString(); + } - public static String categoryPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("false"); - buffer.append("false"); - buffer.append("category"); - buffer.append(""); - return buffer.toString(); - } + public static String categoryPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("false"); + buffer.append("false"); + buffer.append("category"); + buffer.append(""); + return buffer.toString(); + } - public static String categoryPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/config/categories/1", "edit")); - buffer.append("false"); - buffer.append("false"); - buffer.append("1"); - buffer.append("category"); - buffer.append(""); - return buffer.toString(); - } + public static String categoryPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/config/categories/1", "edit")); + buffer.append("false"); + buffer.append("false"); + buffer.append("1"); + buffer.append("category"); + buffer.append(""); + return buffer.toString(); + } - public static String iconPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/config/icons/1", "edit")); - buffer.append("1"); - buffer.append("icon"); - buffer.append("http://www.pixeljoint.com/files/icons/mipreview1.gif"); - buffer.append(""); - return buffer.toString(); - } + public static String iconPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/config/icons/1", "edit")); + buffer.append("1"); + buffer.append("icon"); + buffer.append("http://www.pixeljoint.com/files/icons/mipreview1.gif"); + buffer.append(""); + return buffer.toString(); + } - public static String iconPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("icon"); - buffer.append("http://www.pixeljoint.com/files/icons/mipreview1.gif"); - buffer.append(""); - return buffer.toString(); - } + public static String iconPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("icon"); + buffer.append("http://www.pixeljoint.com/files/icons/mipreview1.gif"); + buffer.append(""); + return buffer.toString(); + } - public static String propertyPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/config/properties/1", "edit")); - buffer.append("Time interval in seconds"); - buffer.append("1"); - buffer - .append("api.applibrary.ovfpackagesDownloadingProgressUpdateInterval"); - buffer.append("10"); - buffer.append(""); - return buffer.toString(); - } + public static String propertyPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/config/properties/1", "edit")); + buffer.append("Time interval in seconds"); + buffer.append("1"); + buffer.append("api.applibrary.ovfpackagesDownloadingProgressUpdateInterval"); + buffer.append("10"); + buffer.append(""); + return buffer.toString(); + } - private static String readLicense(final String filename) - { - URL url = ConfigResources.class.getResource("/" + filename); - try - { - return Resources.toString(url, Charset.defaultCharset()); - } - catch (IOException e) - { - throw new RuntimeException("Could not read file " + filename); - } - } + private static String readLicense(final String filename) { + URL url = ConfigResources.class.getResource("/" + filename); + try { + return Resources.toString(url, Charset.defaultCharset()); + } catch (IOException e) { + throw new RuntimeException("Could not read file " + filename); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/DomainUtils.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/DomainUtils.java index 88e3092f09..23557553ff 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/DomainUtils.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/DomainUtils.java @@ -28,39 +28,33 @@ import com.abiquo.model.rest.RESTLink; * * @author Ignasi Barrera */ -public class DomainUtils -{ - /** - * Adds the XML header to the given XML. - */ - public static String withHeader(final String xml) - { - return XMLParser.DEFAULT_XML_HEADER + xml; - } +public class DomainUtils { + /** + * Adds the XML header to the given XML. + */ + public static String withHeader(final String xml) { + return XMLParser.DEFAULT_XML_HEADER + xml; + } - /** - * Builds a link in xml format - */ - public static String link(final String href, final String rel) - { - return ""; - } + /** + * Builds a link in xml format + */ + public static String link(final String href, final String rel) { + return ""; + } - /** - * Builds a link in xml format - */ - public static String link(final String href, final String rel, final String title) - { - return ""; - } + /** + * Builds a link in xml format + */ + public static String link(final String href, final String rel, final String title) { + return ""; + } - /** - * Builds a link in xml format - */ - public static String link(final RESTLink link) - { - return ""; - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/EnterpriseResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/EnterpriseResources.java index 6dc496b1d8..4b32b0aced 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/EnterpriseResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/EnterpriseResources.java @@ -37,317 +37,286 @@ import com.abiquo.server.core.enterprise.UserDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class EnterpriseResources -{ - public static EnterpriseDto enterprisePost() - { - EnterpriseDto enterprise = new EnterpriseDto(); - enterprise.setName("Kalakaua"); - return enterprise; - } +public class EnterpriseResources { + public static EnterpriseDto enterprisePost() { + EnterpriseDto enterprise = new EnterpriseDto(); + enterprise.setName("Kalakaua"); + return enterprise; + } - public static EnterpriseDto enterprisePut() - { - EnterpriseDto enterprise = enterprisePost(); - enterprise.setId(1); - enterprise.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1")); - enterprise - .addLink(new RESTLink("limits", "http://localhost/api/admin/enterprises/1/limits")); - enterprise.addLink(new RESTLink("users", "http://localhost/api/admin/enterprises/1/users")); - enterprise.addLink(new RESTLink("properties", - "http://localhost/api/admin/enterprises/1/properties")); - enterprise.addLink(new RESTLink("reservedmachines", - "http://localhost/api/admin/enterprises/1/reservedmachines")); - enterprise.addLink(new RESTLink("datacenterrepositories", + public static EnterpriseDto enterprisePut() { + EnterpriseDto enterprise = enterprisePost(); + enterprise.setId(1); + enterprise.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1")); + enterprise.addLink(new RESTLink("limits", "http://localhost/api/admin/enterprises/1/limits")); + enterprise.addLink(new RESTLink("users", "http://localhost/api/admin/enterprises/1/users")); + enterprise.addLink(new RESTLink("properties", "http://localhost/api/admin/enterprises/1/properties")); + enterprise.addLink(new RESTLink("reservedmachines", "http://localhost/api/admin/enterprises/1/reservedmachines")); + enterprise.addLink(new RESTLink("datacenterrepositories", "http://localhost/api/admin/enterprises/1/datacenterrepositories")); - enterprise.addLink(new RESTLink("externalnetworks", + enterprise.addLink(new RESTLink("externalnetworks", "http://localhost/api/admin/enterprises/1/action/externalnetworks")); - enterprise.addLink(new RESTLink("virtualmachines", + enterprise.addLink(new RESTLink("virtualmachines", "http://localhost/api/admin/enterprises/1/action/virtualmachines")); - enterprise.addLink(new RESTLink("cloud/virtualdatacenters", + enterprise.addLink(new RESTLink("cloud/virtualdatacenters", "http://localhost/api/admin/enterprises/1/action/virtualdatacenters")); - enterprise.addLink(new RESTLink("virtualappliances", + enterprise.addLink(new RESTLink("virtualappliances", "http://localhost/api/admin/enterprises/1/action/virtualappliances")); - enterprise.addLink(new RESTLink("appslib/templateDefinitionLists", + enterprise.addLink(new RESTLink("appslib/templateDefinitionLists", "http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists")); - return enterprise; - } + return enterprise; + } - public static EnterprisePropertiesDto enterprisePropertiesPut() - { - EnterprisePropertiesDto enterpriseProp = new EnterprisePropertiesDto(); - enterpriseProp.setId(1); - Map props = new HashMap(); - props.put("key", "value"); - enterpriseProp.setProperties(props); - enterpriseProp.addLink(new RESTLink("edit", - "http://localhost/api/admin/enterprises/1/properties")); - enterpriseProp.addLink(new RESTLink("enterprise", - "http://localhost/api/admin/enterprises/1")); + public static EnterprisePropertiesDto enterprisePropertiesPut() { + EnterprisePropertiesDto enterpriseProp = new EnterprisePropertiesDto(); + enterpriseProp.setId(1); + Map props = new HashMap(); + props.put("key", "value"); + enterpriseProp.setProperties(props); + enterpriseProp.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/properties")); + enterpriseProp.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - return enterpriseProp; - } + return enterpriseProp; + } - public static String enterprisePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("false"); - buffer.append("Kalakaua"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String enterprisePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("false"); + buffer.append("Kalakaua"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String enterprisePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/1", "edit")); - buffer.append(link("/admin/enterprises/1/limits", "limits")); - buffer.append(link("/admin/enterprises/1/users", "users")); - buffer.append(link("/admin/enterprises/1/properties", "properties")); - buffer.append(link("/admin/enterprises/1/reservedmachines", "reservedmachines")); - buffer - .append(link("/admin/enterprises/1/datacenterrepositories", "datacenterrepositories")); - buffer.append(link("/admin/enterprises/1/action/externalnetworks", "externalnetworks")); - buffer.append(link("/admin/enterprises/1/action/virtualmachines", "virtualmachines")); - buffer.append(link("/admin/enterprises/1/action/virtualdatacenters", - "cloud/virtualdatacenters")); - buffer.append(link("/admin/enterprises/1/action/virtualappliances", "virtualappliances")); - buffer.append(link("/admin/enterprises/1/appslib/templateDefinitionLists", - "appslib/templateDefinitionLists")); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("false"); - buffer.append("Kalakaua"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String enterprisePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/1", "edit")); + buffer.append(link("/admin/enterprises/1/limits", "limits")); + buffer.append(link("/admin/enterprises/1/users", "users")); + buffer.append(link("/admin/enterprises/1/properties", "properties")); + buffer.append(link("/admin/enterprises/1/reservedmachines", "reservedmachines")); + buffer.append(link("/admin/enterprises/1/datacenterrepositories", "datacenterrepositories")); + buffer.append(link("/admin/enterprises/1/action/externalnetworks", "externalnetworks")); + buffer.append(link("/admin/enterprises/1/action/virtualmachines", "virtualmachines")); + buffer.append(link("/admin/enterprises/1/action/virtualdatacenters", "cloud/virtualdatacenters")); + buffer.append(link("/admin/enterprises/1/action/virtualappliances", "virtualappliances")); + buffer.append(link("/admin/enterprises/1/appslib/templateDefinitionLists", "appslib/templateDefinitionLists")); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("false"); + buffer.append("Kalakaua"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String enterprisePropertiesPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/1/properties", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer.append("1"); - buffer.append(""); - buffer.append(""); - buffer.append("key"); - buffer.append("value"); - buffer.append(""); - buffer.append(""); - buffer.append(""); - return buffer.toString(); - } + public static String enterprisePropertiesPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/1/properties", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append("1"); + buffer.append(""); + buffer.append(""); + buffer.append("key"); + buffer.append("value"); + buffer.append(""); + buffer.append(""); + buffer.append(""); + return buffer.toString(); + } - public static DatacenterLimitsDto datacenterLimitsPost() - { - DatacenterLimitsDto limits = new DatacenterLimitsDto(); - limits.setCpuCountLimits(0, 0); - limits.setHdLimitsInMb(0, 0); - limits.setPublicIPLimits(0, 0); - limits.setRamLimitsInMb(0, 0); - limits.setStorageLimits(0, 0); - limits.setVlansLimits(0, 0); - limits.setRepositoryHardLimitsInMb(0); - limits.setRepositorySoftLimitsInMb(0); - return limits; - } + public static DatacenterLimitsDto datacenterLimitsPost() { + DatacenterLimitsDto limits = new DatacenterLimitsDto(); + limits.setCpuCountLimits(0, 0); + limits.setHdLimitsInMb(0, 0); + limits.setPublicIPLimits(0, 0); + limits.setRamLimitsInMb(0, 0); + limits.setStorageLimits(0, 0); + limits.setVlansLimits(0, 0); + limits.setRepositoryHardLimitsInMb(0); + limits.setRepositorySoftLimitsInMb(0); + return limits; + } - public static DatacenterLimitsDto datacenterLimitsPut(final EnterpriseDto enterprise) - { - DatacenterLimitsDto limits = datacenterLimitsPost(); - limits.setId(1); - limits.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/" - + enterprise.getId() + "/limits/1")); - return limits; - } + public static DatacenterLimitsDto datacenterLimitsPut(final EnterpriseDto enterprise) { + DatacenterLimitsDto limits = datacenterLimitsPost(); + limits.setId(1); + limits.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/" + enterprise.getId() + "/limits/1")); + return limits; + } - public static TemplateDefinitionListDto templateListPost() - { - TemplateDefinitionListDto templateList = new TemplateDefinitionListDto(); - templateList.setName("myList"); - templateList.setUrl("http://virtualapp-repository.com/vapp1.ovf"); - return templateList; - } + public static TemplateDefinitionListDto templateListPost() { + TemplateDefinitionListDto templateList = new TemplateDefinitionListDto(); + templateList.setName("myList"); + templateList.setUrl("http://virtualapp-repository.com/vapp1.ovf"); + return templateList; + } - public static TemplateDefinitionListDto templateListPut() - { - TemplateDefinitionListDto templateList = templateListPost(); - templateList.setId(1); - templateList.addLink(new RESTLink("edit", + public static TemplateDefinitionListDto templateListPut() { + TemplateDefinitionListDto templateList = templateListPost(); + templateList.setId(1); + templateList.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1")); - templateList - .addLink(new RESTLink("repositoryStatus", - "http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1/actions/repositoryStatus")); - return templateList; - } + templateList.addLink(new RESTLink("repositoryStatus", + "http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1/actions/repositoryStatus")); + return templateList; + } - public static String datacenterLimitsPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterLimitsPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String templateListPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("myList"); - buffer.append("http://virtualapp-repository.com/vapp1.ovf"); - buffer.append(""); - return buffer.toString(); - } + public static String templateListPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("myList"); + buffer.append("http://virtualapp-repository.com/vapp1.ovf"); + buffer.append(""); + return buffer.toString(); + } - public static String templateListPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/1/appslib/templateDefinitionLists/1", "edit")); - buffer.append(link( - "/admin/enterprises/1/appslib/templateDefinitionLists/1/actions/repositoryStatus", + public static String templateListPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/1/appslib/templateDefinitionLists/1", "edit")); + buffer.append(link("/admin/enterprises/1/appslib/templateDefinitionLists/1/actions/repositoryStatus", "repositoryStatus")); - buffer.append("1"); - buffer.append("myList"); - buffer.append("http://virtualapp-repository.com/vapp1.ovf"); - buffer.append(""); - return buffer.toString(); - } + buffer.append("1"); + buffer.append("myList"); + buffer.append("http://virtualapp-repository.com/vapp1.ovf"); + buffer.append(""); + return buffer.toString(); + } - public static String datacenterLimitsPutPayload(final EnterpriseDto enterprise) - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/enterprises/" + enterprise.getId() + "/limits/1", "edit")); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterLimitsPutPayload(final EnterpriseDto enterprise) { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/" + enterprise.getId() + "/limits/1", "edit")); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String userPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1", "role")); - buffer.append("true"); - buffer.append("ABIQUO"); - buffer.append("A hawaian user"); - buffer.append("abe.joha@aloha.com"); - buffer.append("en_US"); - buffer.append("Aberahama"); - buffer.append("abejo"); - buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); - buffer.append("Johanson"); - buffer.append(""); - return buffer.toString(); - } + public static String userPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1", "role")); + buffer.append("true"); + buffer.append("ABIQUO"); + buffer.append("A hawaian user"); + buffer.append("abe.joha@aloha.com"); + buffer.append("en_US"); + buffer.append("Aberahama"); + buffer.append("abejo"); + buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); + buffer.append("Johanson"); + buffer.append(""); + return buffer.toString(); + } - public static UserDto userPost() - { - UserDto user = new UserDto(); - user.setName("Aberahama"); - user.setSurname("Johanson"); - user.setDescription("A hawaian user"); - user.setEmail("abe.joha@aloha.com"); - user.setNick("abejo"); - user.setAuthType("ABIQUO"); - user.setLocale("en_US"); - user.setActive(true); - user.setPassword("c69a39bd64ffb77ea7ee3369dce742f3"); - user.addLink(new RESTLink("role", "http://localhost/api/admin/roles/1")); - return user; - } + public static UserDto userPost() { + UserDto user = new UserDto(); + user.setName("Aberahama"); + user.setSurname("Johanson"); + user.setDescription("A hawaian user"); + user.setEmail("abe.joha@aloha.com"); + user.setNick("abejo"); + user.setAuthType("ABIQUO"); + user.setLocale("en_US"); + user.setActive(true); + user.setPassword("c69a39bd64ffb77ea7ee3369dce742f3"); + user.addLink(new RESTLink("role", "http://localhost/api/admin/roles/1")); + return user; + } - public static String userPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/roles/1", "role")); - buffer.append(link("/admin/enterprises/1/users/1", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer - .append(link("/admin/enterprises/1/users/1/action/virtualmachines", "virtualmachines")); - buffer.append("true"); - buffer.append("ABIQUO"); - buffer.append("A hawaian user"); - buffer.append("abe.joha@aloha.com"); - buffer.append("1"); - buffer.append("en_US"); - buffer.append("Aberahama"); - buffer.append("abejo"); - buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); - buffer.append("Johanson"); - buffer.append(""); - return buffer.toString(); - } + public static String userPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/roles/1", "role")); + buffer.append(link("/admin/enterprises/1/users/1", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/admin/enterprises/1/users/1/action/virtualmachines", "virtualmachines")); + buffer.append("true"); + buffer.append("ABIQUO"); + buffer.append("A hawaian user"); + buffer.append("abe.joha@aloha.com"); + buffer.append("1"); + buffer.append("en_US"); + buffer.append("Aberahama"); + buffer.append("abejo"); + buffer.append("c69a39bd64ffb77ea7ee3369dce742f3"); + buffer.append("Johanson"); + buffer.append(""); + return buffer.toString(); + } - public static UserDto userPut() - { - UserDto user = userPost(); - user.setId(1); - user.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/users/1")); - user.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - user.addLink(new RESTLink("virtualmachines", + public static UserDto userPut() { + UserDto user = userPost(); + user.setId(1); + user.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/users/1")); + user.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + user.addLink(new RESTLink("virtualmachines", "http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines")); - return user; - } + return user; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java index 89cef979df..07d4f1d436 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/InfrastructureResources.java @@ -39,517 +39,453 @@ import com.abiquo.server.core.infrastructure.storage.TierDto; * * @author Ignasi Barrera */ -public class InfrastructureResources -{ - public static DatacenterDto datacenterPost() - { - DatacenterDto datacenter = new DatacenterDto(); - datacenter.setName("DC"); - datacenter.setLocation("Honolulu"); - return datacenter; - } +public class InfrastructureResources { + public static DatacenterDto datacenterPost() { + DatacenterDto datacenter = new DatacenterDto(); + datacenter.setName("DC"); + datacenter.setLocation("Honolulu"); + return datacenter; + } - public static RackDto rackPost() - { - RackDto rack = new RackDto(); - rack.setName("Aloha"); - rack.setShortDescription("A hawaian rack"); - rack.setHaEnabled(false); - rack.setVlanIdMin(6); - rack.setVlanIdMax(3024); - rack.setVlanPerVdcReserved(6); - rack.setNrsq(80); - return rack; - } + public static RackDto rackPost() { + RackDto rack = new RackDto(); + rack.setName("Aloha"); + rack.setShortDescription("A hawaian rack"); + rack.setHaEnabled(false); + rack.setVlanIdMin(6); + rack.setVlanIdMax(3024); + rack.setVlanPerVdcReserved(6); + rack.setNrsq(80); + return rack; + } - public static UcsRackDto managedRackPost() - { - UcsRackDto rack = new UcsRackDto(); - rack.setName("Aloha"); - rack.setShortDescription("A hawaian rack"); - rack.setHaEnabled(false); - rack.setVlanIdMin(6); - rack.setVlanIdMax(3024); - rack.setVlanPerVdcReserved(6); - rack.setNrsq(80); - return rack; - } + public static UcsRackDto managedRackPost() { + UcsRackDto rack = new UcsRackDto(); + rack.setName("Aloha"); + rack.setShortDescription("A hawaian rack"); + rack.setHaEnabled(false); + rack.setVlanIdMin(6); + rack.setVlanIdMax(3024); + rack.setVlanPerVdcReserved(6); + rack.setNrsq(80); + return rack; + } - public static MachineDto machinePost() - { - MachineDto machine = new MachineDto(); - machine.setName("Kamehameha"); - machine.setVirtualCpuCores(3); - machine.setDescription("A hawaian machine"); - machine.setVirtualRamInMb(512); - machine.setVirtualSwitch("192.168.1.10"); - return machine; - } + public static MachineDto machinePost() { + MachineDto machine = new MachineDto(); + machine.setName("Kamehameha"); + machine.setVirtualCpuCores(3); + machine.setDescription("A hawaian machine"); + machine.setVirtualRamInMb(512); + machine.setVirtualSwitch("192.168.1.10"); + return machine; + } - public static RemoteServiceDto remoteServicePost() - { - RemoteServiceDto remoteService = new RemoteServiceDto(); - remoteService.setType(RemoteServiceType.NODE_COLLECTOR); - remoteService.setUri("http://localhost:80/nodecollector"); - remoteService.setStatus(0); - return remoteService; - } + public static RemoteServiceDto remoteServicePost() { + RemoteServiceDto remoteService = new RemoteServiceDto(); + remoteService.setType(RemoteServiceType.NODE_COLLECTOR); + remoteService.setUri("http://localhost:80/nodecollector"); + remoteService.setStatus(0); + return remoteService; + } - public static StorageDeviceDto storageDevicePost() - { - StorageDeviceDto storage = new StorageDeviceDto(); - storage.setName("Aloha aloha"); - storage.setIscsiIp("10.10.10.10"); - storage.setIscsiPort(99); - storage.setManagementPort(90); + public static StorageDeviceDto storageDevicePost() { + StorageDeviceDto storage = new StorageDeviceDto(); + storage.setName("Aloha aloha"); + storage.setIscsiIp("10.10.10.10"); + storage.setIscsiPort(99); + storage.setManagementPort(90); - return storage; - } + return storage; + } - public static StoragePoolDto storagePoolPost() - { - StoragePoolDto storagePool = new StoragePoolDto(); - storagePool.setName("Hawaian Storage Pool"); - return storagePool; - } + public static StoragePoolDto storagePoolPost() { + StoragePoolDto storagePool = new StoragePoolDto(); + storagePool.setName("Hawaian Storage Pool"); + return storagePool; + } - public static DatacenterDto datacenterPut() - { - DatacenterDto datacenter = datacenterPost(); - datacenter.setId(1); - datacenter.addLink(new RESTLink("checkmachinestate", + public static DatacenterDto datacenterPut() { + DatacenterDto datacenter = datacenterPost(); + datacenter.setId(1); + datacenter.addLink(new RESTLink("checkmachinestate", "http://localhost/api/admin/datacenters/1/action/checkmachinestate")); - datacenter.addLink(new RESTLink("checkmachineipmistate", + datacenter.addLink(new RESTLink("checkmachineipmistate", "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate")); - datacenter.addLink(new RESTLink("checkremoteservice", + datacenter.addLink(new RESTLink("checkremoteservice", "http://localhost/api/admin/datacenters/1/action/checkremoteservice")); - datacenter.addLink(new RESTLink("devices", - "http://localhost/api/admin/datacenters/1/storage/devices")); - datacenter.addLink(new RESTLink("discovermultiple", + datacenter.addLink(new RESTLink("devices", "http://localhost/api/admin/datacenters/1/storage/devices")); + datacenter.addLink(new RESTLink("discovermultiple", "http://localhost/api/admin/datacenters/1/action/discovermultiple")); - datacenter.addLink(new RESTLink("discoversingle", + datacenter.addLink(new RESTLink("discoversingle", "http://localhost/api/admin/datacenters/1/action/discoversingle")); - datacenter.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1")); - datacenter.addLink(new RESTLink("getLimits", - "http://localhost/api/admin/datacenters/1/action/getLimits")); - datacenter.addLink(new RESTLink("racks", "http://localhost/api/admin/datacenters/1/racks")); - datacenter.addLink(new RESTLink("remoteservices", - "http://localhost/api/admin/datacenters/1/remoteservices")); - datacenter.addLink(new RESTLink("tiers", - "http://localhost/api/admin/datacenters/1/storage/tiers")); - datacenter.addLink(new RESTLink("network", - "http://localhost/api/admin/datacenters/1/network")); - datacenter.addLink(new RESTLink("enterprises", - "http://localhost/api/admin/datacenters/1/action/enterprises")); - datacenter.addLink(new RESTLink("hypervisor", - "http://localhost/api/admin/datacenters/1/action/hypervisor")); - datacenter.addLink(new RESTLink("hypervisors", - "http://localhost/api/admin/datacenters/1/hypervisors")); - return datacenter; - } + datacenter.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1")); + datacenter.addLink(new RESTLink("getLimits", "http://localhost/api/admin/datacenters/1/action/getLimits")); + datacenter.addLink(new RESTLink("racks", "http://localhost/api/admin/datacenters/1/racks")); + datacenter.addLink(new RESTLink("remoteservices", "http://localhost/api/admin/datacenters/1/remoteservices")); + datacenter.addLink(new RESTLink("tiers", "http://localhost/api/admin/datacenters/1/storage/tiers")); + datacenter.addLink(new RESTLink("network", "http://localhost/api/admin/datacenters/1/network")); + datacenter.addLink(new RESTLink("enterprises", "http://localhost/api/admin/datacenters/1/action/enterprises")); + datacenter.addLink(new RESTLink("hypervisor", "http://localhost/api/admin/datacenters/1/action/hypervisor")); + datacenter.addLink(new RESTLink("hypervisors", "http://localhost/api/admin/datacenters/1/hypervisors")); + return datacenter; + } - public static RackDto rackPut() - { - RackDto rack = rackPost(); - rack.setId(1); - rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1")); - rack.addLink(new RESTLink("machines", - "http://localhost/api/admin/datacenters/1/racks/1/machines")); - return rack; - } + public static RackDto rackPut() { + RackDto rack = rackPost(); + rack.setId(1); + rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1")); + rack.addLink(new RESTLink("machines", "http://localhost/api/admin/datacenters/1/racks/1/machines")); + return rack; + } - public static UcsRackDto managedRackPut() - { - UcsRackDto rack = managedRackPost(); - rack.setId(1); - rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1")); - rack.addLink(new RESTLink("fsm", "http://localhost/api/admin/datacenters/1/racks/1/fsm")); - rack.addLink(new RESTLink("logicservers", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers")); - rack.addLink(new RESTLink("ls-templates", - "http://localhost/api/admin/datacenters/1/racks/1/lstemplates")); - rack.addLink(new RESTLink("organizations", - "http://localhost/api/admin/datacenters/1/racks/1/organizations")); - rack.addLink(new RESTLink("ls-associate", + public static UcsRackDto managedRackPut() { + UcsRackDto rack = managedRackPost(); + rack.setId(1); + rack.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + rack.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1")); + rack.addLink(new RESTLink("fsm", "http://localhost/api/admin/datacenters/1/racks/1/fsm")); + rack.addLink(new RESTLink("logicservers", "http://localhost/api/admin/datacenters/1/racks/1/logicservers")); + rack.addLink(new RESTLink("ls-templates", "http://localhost/api/admin/datacenters/1/racks/1/lstemplates")); + rack.addLink(new RESTLink("organizations", "http://localhost/api/admin/datacenters/1/racks/1/organizations")); + rack.addLink(new RESTLink("ls-associate", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate")); - rack.addLink(new RESTLink("ls-associateclone", + rack.addLink(new RESTLink("ls-associateclone", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone")); - rack.addLink(new RESTLink("ls-associatetemplate", + rack.addLink(new RESTLink("ls-associatetemplate", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate")); - rack.addLink(new RESTLink("ls-clone", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone")); - rack.addLink(new RESTLink("ls-delete", - "http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete")); - rack.addLink(new RESTLink("ls-dissociate", + rack.addLink(new RESTLink("ls-clone", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone")); + rack.addLink(new RESTLink("ls-delete", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete")); + rack.addLink(new RESTLink("ls-dissociate", "http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate")); - return rack; - } + return rack; + } - public static LogicServerDto logicServerPut() - { - LogicServerDto logicServer = new LogicServerDto(); - logicServer.setName("server"); - logicServer.setAssociated("associated"); - logicServer.setType("instance"); + public static LogicServerDto logicServerPut() { + LogicServerDto logicServer = new LogicServerDto(); + logicServer.setName("server"); + logicServer.setAssociated("associated"); + logicServer.setType("instance"); - return logicServer; - } + return logicServer; + } - public static OrganizationDto organizationPut() - { - OrganizationDto org = new OrganizationDto(); - org.setName("org"); - org.setDn("org-root/org-Finance"); - org.setLevel("1"); + public static OrganizationDto organizationPut() { + OrganizationDto org = new OrganizationDto(); + org.setName("org"); + org.setDn("org-root/org-Finance"); + org.setLevel("1"); - return org; - } + return org; + } - public static TierDto tierPut() - { - TierDto tier = new TierDto(); - tier.setId(1); - tier.setEnabled(true); - tier.setName("Tier"); - tier.addLink(new RESTLink("edit", - "http://localhost/api/admin/datacenters/1/storage/tiers/1")); - tier.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - tier.addLink(new RESTLink("pools", - "http://localhost/api/admin/datacenters/1/storage/tiers/1/pools")); + public static TierDto tierPut() { + TierDto tier = new TierDto(); + tier.setId(1); + tier.setEnabled(true); + tier.setName("Tier"); + tier.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/storage/tiers/1")); + tier.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + tier.addLink(new RESTLink("pools", "http://localhost/api/admin/datacenters/1/storage/tiers/1/pools")); - return tier; - } + return tier; + } - public static StorageDeviceDto storageDevicePut() - { - StorageDeviceDto storageDevice = storageDevicePost(); - storageDevice.setId(1); - storageDevice - .addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - storageDevice.addLink(new RESTLink("edit", - "http://localhost/api/admin/datacenters/1/storage/devices/1")); - storageDevice.addLink(new RESTLink("pools", - "http://localhost/api/admin/datacenters/1/storage/devices/1/pools")); + public static StorageDeviceDto storageDevicePut() { + StorageDeviceDto storageDevice = storageDevicePost(); + storageDevice.setId(1); + storageDevice.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + storageDevice.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/storage/devices/1")); + storageDevice.addLink(new RESTLink("pools", "http://localhost/api/admin/datacenters/1/storage/devices/1/pools")); - return storageDevice; - } + return storageDevice; + } - public static StoragePoolDto storagePoolPut() - { - StoragePoolDto storagePool = storagePoolPost(); - storagePool.setIdStorage("tururututu"); - storagePool.addLink(new RESTLink("device", - "http://localhost/api/admin/datacenters/1/storage/devices/1")); - storagePool.addLink(new RESTLink("edit", + public static StoragePoolDto storagePoolPut() { + StoragePoolDto storagePool = storagePoolPost(); + storagePool.setIdStorage("tururututu"); + storagePool.addLink(new RESTLink("device", "http://localhost/api/admin/datacenters/1/storage/devices/1")); + storagePool.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu")); - return storagePool; - } + return storagePool; + } - public static RemoteServiceDto remoteServicePut() - { - RemoteServiceDto remoteService = remoteServicePost(); - remoteService.setId(1); - remoteService.addLink(new RESTLink("check", + public static RemoteServiceDto remoteServicePut() { + RemoteServiceDto remoteService = remoteServicePost(); + remoteService.setId(1); + remoteService.addLink(new RESTLink("check", "http://localhost/api/admin/datacenters/1/remoteservices/nodecollector/action/check")); - remoteService - .addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - remoteService.addLink(new RESTLink("edit", + remoteService.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + remoteService.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/remoteservices/nodecollector")); - return remoteService; - } + return remoteService; + } - public static MachineDto machinePut() - { - MachineDto machine = machinePost(); - machine.setId(1); - machine.addLink(new RESTLink("edit", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1")); - machine.addLink(new RESTLink("rack", "http://localhost/api/admin/datacenters/1/racks/1")); - machine.addLink(new RESTLink("checkstate", + public static MachineDto machinePut() { + MachineDto machine = machinePost(); + machine.setId(1); + machine.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/racks/1/machines/1")); + machine.addLink(new RESTLink("rack", "http://localhost/api/admin/datacenters/1/racks/1")); + machine.addLink(new RESTLink("checkstate", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/checkstate")); - machine.addLink(new RESTLink("checkipmistate", + machine.addLink(new RESTLink("checkipmistate", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/checkipmistate")); - machine.addLink(new RESTLink("led", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/led")); - machine.addLink(new RESTLink("ledoff", + machine.addLink(new RESTLink("led", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/led")); + machine.addLink(new RESTLink("ledoff", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledoff")); - machine.addLink(new RESTLink("ledon", - "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledon")); - machine.addLink(new RESTLink("logicserver", + machine + .addLink(new RESTLink("ledon", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledon")); + machine.addLink(new RESTLink("logicserver", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/logicserver")); - machine.addLink(new RESTLink("poweroff", + machine.addLink(new RESTLink("poweroff", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweroff")); - machine.addLink(new RESTLink("poweron", + machine.addLink(new RESTLink("poweron", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweron")); - machine.addLink(new RESTLink("virtualmachines", + machine.addLink(new RESTLink("virtualmachines", "http://localhost/api/admin/datacenters/1/racks/1/machines/1/virtualmachines")); - machine.setVirtualCpuCores(5); + machine.setVirtualCpuCores(5); - return machine; - } + return machine; + } - public static String datacenterPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("Honolulu"); - buffer.append("DC"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("Honolulu"); + buffer.append("DC"); + buffer.append(""); + return buffer.toString(); + } - public static String rackPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("false"); - buffer.append("Aloha"); - buffer.append("80"); - buffer.append("A hawaian rack"); - buffer.append("3024"); - buffer.append("6"); - buffer.append("6"); - buffer.append(""); - return buffer.toString(); - } + public static String rackPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("false"); + buffer.append("Aloha"); + buffer.append("80"); + buffer.append("A hawaian rack"); + buffer.append("3024"); + buffer.append("6"); + buffer.append("6"); + buffer.append(""); + return buffer.toString(); + } - public static String managedRackPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("false"); - buffer.append("Aloha"); - buffer.append("80"); - buffer.append("A hawaian rack"); - buffer.append("3024"); - buffer.append("6"); - buffer.append("6"); - buffer.append(""); - return buffer.toString(); - } + public static String managedRackPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("false"); + buffer.append("Aloha"); + buffer.append("80"); + buffer.append("A hawaian rack"); + buffer.append("3024"); + buffer.append("6"); + buffer.append("6"); + buffer.append(""); + return buffer.toString(); + } - public static String storagePoolPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("false"); - buffer.append("Hawaian Storage Pool"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String storagePoolPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("false"); + buffer.append("Hawaian Storage Pool"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String storageDevicePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("10.10.10.10"); - buffer.append("99"); - buffer.append("90"); - buffer.append("Aloha aloha"); - buffer.append(""); - return buffer.toString(); - } + public static String storageDevicePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("10.10.10.10"); + buffer.append("99"); + buffer.append("90"); + buffer.append("Aloha aloha"); + buffer.append(""); + return buffer.toString(); + } - public static String machinePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(""); - buffer.append("A hawaian machine"); - buffer.append("Kamehameha"); - buffer.append("3"); - buffer.append("1"); - buffer.append("512"); - buffer.append("1"); - buffer.append("192.168.1.10"); - buffer.append(""); - return buffer.toString(); - } + public static String machinePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(""); + buffer.append("A hawaian machine"); + buffer.append("Kamehameha"); + buffer.append("3"); + buffer.append("1"); + buffer.append("512"); + buffer.append("1"); + buffer.append("192.168.1.10"); + buffer.append(""); + return buffer.toString(); + } - public static String remoteServicePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("0"); - buffer.append("NODE_COLLECTOR"); - buffer.append("http://localhost:80/nodecollector"); - buffer.append(""); - return buffer.toString(); - } + public static String remoteServicePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("0"); + buffer.append("NODE_COLLECTOR"); + buffer.append("http://localhost:80/nodecollector"); + buffer.append(""); + return buffer.toString(); + } - public static String datacenterPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/action/checkmachinestate", "checkmachinestate")); - buffer.append(link("/admin/datacenters/1/action/checkmachineipmistate", - "checkmachineipmistate")); - buffer.append(link("/admin/datacenters/1/action/checkremoteservice", "checkremoteservice")); - buffer.append(link("/admin/datacenters/1/storage/devices", "devices")); - buffer.append(link("/admin/datacenters/1/action/discovermultiple", "discovermultiple")); - buffer.append(link("/admin/datacenters/1/action/discoversingle", "discoversingle")); - buffer.append(link("/admin/datacenters/1", "edit")); - buffer.append(link("/admin/datacenters/1/action/getLimits", "getLimits")); - buffer.append(link("/admin/datacenters/1/racks", "racks")); - buffer.append(link("/admin/datacenters/1/remoteservices", "remoteservices")); - buffer.append(link("/admin/datacenters/1/storage/tiers", "tiers")); - buffer.append(link("/admin/datacenters/1/network", "network")); - buffer.append(link("/admin/datacenters/1/action/enterprises", "enterprises")); - buffer.append(link("/admin/datacenters/1/action/hypervisor", "hypervisor")); - buffer.append(link("/admin/datacenters/1/hypervisors", "hypervisors")); - buffer.append("1"); - buffer.append("Honolulu"); - buffer.append("DC"); - buffer.append(""); - return buffer.toString(); - } + public static String datacenterPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/action/checkmachinestate", "checkmachinestate")); + buffer.append(link("/admin/datacenters/1/action/checkmachineipmistate", "checkmachineipmistate")); + buffer.append(link("/admin/datacenters/1/action/checkremoteservice", "checkremoteservice")); + buffer.append(link("/admin/datacenters/1/storage/devices", "devices")); + buffer.append(link("/admin/datacenters/1/action/discovermultiple", "discovermultiple")); + buffer.append(link("/admin/datacenters/1/action/discoversingle", "discoversingle")); + buffer.append(link("/admin/datacenters/1", "edit")); + buffer.append(link("/admin/datacenters/1/action/getLimits", "getLimits")); + buffer.append(link("/admin/datacenters/1/racks", "racks")); + buffer.append(link("/admin/datacenters/1/remoteservices", "remoteservices")); + buffer.append(link("/admin/datacenters/1/storage/tiers", "tiers")); + buffer.append(link("/admin/datacenters/1/network", "network")); + buffer.append(link("/admin/datacenters/1/action/enterprises", "enterprises")); + buffer.append(link("/admin/datacenters/1/action/hypervisor", "hypervisor")); + buffer.append(link("/admin/datacenters/1/hypervisors", "hypervisors")); + buffer.append("1"); + buffer.append("Honolulu"); + buffer.append("DC"); + buffer.append(""); + return buffer.toString(); + } - public static String storagePoolPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/storage/devices/1", "device")); - buffer.append(link("/admin/datacenters/1/storage/devices/1/pools/tururututu", "edit")); - buffer.append("0"); - buffer.append("false"); - buffer.append("tururututu"); - buffer.append("Hawaian Storage Pool"); - buffer.append("0"); - buffer.append("0"); - buffer.append(""); - return buffer.toString(); - } + public static String storagePoolPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/storage/devices/1", "device")); + buffer.append(link("/admin/datacenters/1/storage/devices/1/pools/tururututu", "edit")); + buffer.append("0"); + buffer.append("false"); + buffer.append("tururututu"); + buffer.append("Hawaian Storage Pool"); + buffer.append("0"); + buffer.append("0"); + buffer.append(""); + return buffer.toString(); + } - public static String tierPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/storage/tiers/1", "edit")); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/admin/datacenters/1/storage/tiers/1/pools", "pools")); - buffer.append("true"); - buffer.append("1"); - buffer.append("Tier"); - buffer.append(""); - return buffer.toString(); - } + public static String tierPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/storage/tiers/1", "edit")); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/admin/datacenters/1/storage/tiers/1/pools", "pools")); + buffer.append("true"); + buffer.append("1"); + buffer.append("Tier"); + buffer.append(""); + return buffer.toString(); + } - public static String rackPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/admin/datacenters/1/racks/1", "edit")); - buffer.append(link("/admin/datacenters/1/racks/1/machines", "machines")); - buffer.append("false"); - buffer.append("1"); - buffer.append("Aloha"); - buffer.append("80"); - buffer.append("A hawaian rack"); - buffer.append("3024"); - buffer.append("6"); - buffer.append("6"); - buffer.append(""); - return buffer.toString(); - } + public static String rackPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/admin/datacenters/1/racks/1", "edit")); + buffer.append(link("/admin/datacenters/1/racks/1/machines", "machines")); + buffer.append("false"); + buffer.append("1"); + buffer.append("Aloha"); + buffer.append("80"); + buffer.append("A hawaian rack"); + buffer.append("3024"); + buffer.append("6"); + buffer.append("6"); + buffer.append(""); + return buffer.toString(); + } - public static String managedRackPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/admin/datacenters/1/racks/1", "edit")); - buffer.append(link("/admin/datacenters/1/racks/1/fsm", "fsm")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers", "logicservers")); - buffer.append(link("/admin/datacenters/1/racks/1/lstemplates", "ls-templates")); - buffer.append(link("/admin/datacenters/1/racks/1/organizations", "organizations")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associate", "ls-associate")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers/assocclone", - "ls-associateclone")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associatetemplate", - "ls-associatetemplate")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers/clone", "ls-clone")); - buffer.append(link("/admin/datacenters/1/racks/1/logicservers/delete", "ls-delete")); - buffer - .append(link("/admin/datacenters/1/racks/1/logicservers/dissociate", "ls-dissociate")); - buffer.append("false"); - buffer.append("1"); - buffer.append("Aloha"); - buffer.append("80"); - buffer.append("A hawaian rack"); - buffer.append("3024"); - buffer.append("6"); - buffer.append("6"); - buffer.append(""); - return buffer.toString(); - } + public static String managedRackPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/admin/datacenters/1/racks/1", "edit")); + buffer.append(link("/admin/datacenters/1/racks/1/fsm", "fsm")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers", "logicservers")); + buffer.append(link("/admin/datacenters/1/racks/1/lstemplates", "ls-templates")); + buffer.append(link("/admin/datacenters/1/racks/1/organizations", "organizations")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associate", "ls-associate")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/assocclone", "ls-associateclone")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/associatetemplate", "ls-associatetemplate")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/clone", "ls-clone")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/delete", "ls-delete")); + buffer.append(link("/admin/datacenters/1/racks/1/logicservers/dissociate", "ls-dissociate")); + buffer.append("false"); + buffer.append("1"); + buffer.append("Aloha"); + buffer.append("80"); + buffer.append("A hawaian rack"); + buffer.append("3024"); + buffer.append("6"); + buffer.append("6"); + buffer.append(""); + return buffer.toString(); + } - public static String storageDevicePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/admin/datacenters/1/storage/devices/1", "edit")); - buffer.append(link("/admin/datacenters/1/storage/devices/1/pools", "pools")); - buffer.append("1"); - buffer.append("10.10.10.10"); - buffer.append("99"); - buffer.append("90"); - buffer.append("Aloha aloha"); - buffer.append(""); - return buffer.toString(); - } + public static String storageDevicePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/admin/datacenters/1/storage/devices/1", "edit")); + buffer.append(link("/admin/datacenters/1/storage/devices/1/pools", "pools")); + buffer.append("1"); + buffer.append("10.10.10.10"); + buffer.append("99"); + buffer.append("90"); + buffer.append("Aloha aloha"); + buffer.append(""); + return buffer.toString(); + } - public static String remoteServicePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/remoteservices/nodecollector/action/check", - "check")); - buffer.append(link("/admin/datacenters/1", "datacenter")); - buffer.append(link("/admin/datacenters/1/remoteservices/nodecollector", "edit")); - buffer.append("1"); - buffer.append("0"); - buffer.append("NODE_COLLECTOR"); - buffer.append("http://localhost:80/nodecollector"); - buffer.append(""); - return buffer.toString(); - } + public static String remoteServicePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/remoteservices/nodecollector/action/check", "check")); + buffer.append(link("/admin/datacenters/1", "datacenter")); + buffer.append(link("/admin/datacenters/1/remoteservices/nodecollector", "edit")); + buffer.append("1"); + buffer.append("0"); + buffer.append("NODE_COLLECTOR"); + buffer.append("http://localhost:80/nodecollector"); + buffer.append(""); + return buffer.toString(); + } - public static String machinePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1", "edit")); - buffer.append(link("/admin/datacenters/1/racks/1", "rack")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/checkstate", - "checkstate")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/checkipmistate", - "checkipmistate")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/led", "led")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/ledoff", "ledoff")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/ledon", "ledon")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/logicserver", "logicserver")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/poweroff", "poweroff")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/poweron", "poweron")); - buffer.append(link("/admin/datacenters/1/racks/1/machines/1/virtualmachines", - "virtualmachines")); - buffer.append(""); - buffer.append("A hawaian machine"); - buffer.append("1"); - buffer.append("Kamehameha"); - buffer.append("5"); - buffer.append("1"); - buffer.append("512"); - buffer.append("1"); - buffer.append("192.168.1.10"); - buffer.append(""); - return buffer.toString(); - } + public static String machinePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1", "edit")); + buffer.append(link("/admin/datacenters/1/racks/1", "rack")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/checkstate", "checkstate")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/checkipmistate", "checkipmistate")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/led", "led")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/ledoff", "ledoff")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/ledon", "ledon")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/logicserver", "logicserver")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/poweroff", "poweroff")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/action/poweron", "poweron")); + buffer.append(link("/admin/datacenters/1/racks/1/machines/1/virtualmachines", "virtualmachines")); + buffer.append(""); + buffer.append("A hawaian machine"); + buffer.append("1"); + buffer.append("Kamehameha"); + buffer.append("5"); + buffer.append("1"); + buffer.append("512"); + buffer.append("1"); + buffer.append("192.168.1.10"); + buffer.append(""); + return buffer.toString(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/NetworkResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/NetworkResources.java index 6db98f41d3..364645fcb7 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/NetworkResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/NetworkResources.java @@ -35,243 +35,214 @@ import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class NetworkResources -{ - public static VLANNetworkDto vlanPost() - { - VLANNetworkDto vlan = new VLANNetworkDto(); - vlan.setAddress("192.168.1.0"); - vlan.setDefaultNetwork(true); - vlan.setName("DefaultNetwork"); - vlan.setGateway("192.168.1.1"); - vlan.setMask(24); +public class NetworkResources { + public static VLANNetworkDto vlanPost() { + VLANNetworkDto vlan = new VLANNetworkDto(); + vlan.setAddress("192.168.1.0"); + vlan.setDefaultNetwork(true); + vlan.setName("DefaultNetwork"); + vlan.setGateway("192.168.1.1"); + vlan.setMask(24); - return vlan; - } + return vlan; + } - public static PrivateIpDto privateIpPut() - { - PrivateIpDto ip = new PrivateIpDto(); - ip.setId(1); - ip.setName("private ip"); - ip.setMac("00:58:5A:c0:C3:01"); - RESTLink self = - new RESTLink("self", - "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips/1"); - self.setTitle("privateip"); - ip.addLink(self); - return ip; - } + public static PrivateIpDto privateIpPut() { + PrivateIpDto ip = new PrivateIpDto(); + ip.setId(1); + ip.setName("private ip"); + ip.setMac("00:58:5A:c0:C3:01"); + RESTLink self = new RESTLink("self", "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips/1"); + self.setTitle("privateip"); + ip.addLink(self); + return ip; + } - public static PublicIpDto publicIpToPurchase() - { - PublicIpDto ip = new PublicIpDto(); - RESTLink self = - new RESTLink("purchase", - "http://localhost/api/cloud/virtualdatacenters/5/publicips/purchased/1"); - ip.addLink(self); - return ip; - } + public static PublicIpDto publicIpToPurchase() { + PublicIpDto ip = new PublicIpDto(); + RESTLink self = new RESTLink("purchase", "http://localhost/api/cloud/virtualdatacenters/5/publicips/purchased/1"); + ip.addLink(self); + return ip; + } - public static PublicIpDto publicIpToRelease() - { - PublicIpDto ip = new PublicIpDto(); - RESTLink self = - new RESTLink("release", - "http://localhost/api/cloud/virtualdatacenters/5/publicips/topurchase/1"); - ip.addLink(self); - return ip; - } + public static PublicIpDto publicIpToRelease() { + PublicIpDto ip = new PublicIpDto(); + RESTLink self = new RESTLink("release", "http://localhost/api/cloud/virtualdatacenters/5/publicips/topurchase/1"); + ip.addLink(self); + return ip; + } - public static NicDto nicPut() - { - NicDto nic = new NicDto(); - nic.setId(1); - nic.setIp("123.123.123.123"); - nic.setMac("00:58:5A:c0:C3:01"); - nic.addLink(new RESTLink("edit", + public static NicDto nicPut() { + NicDto nic = new NicDto(); + nic.setId(1); + nic.setIp("123.123.123.123"); + nic.setMac("00:58:5A:c0:C3:01"); + nic.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/nics/1")); - return nic; - } + return nic; + } - public static VLANNetworkDto privateNetworkPut() - { - VLANNetworkDto vlan = new VLANNetworkDto(); - vlan.setId(1); - vlan.setAddress("192.168.1.0"); - vlan.setDefaultNetwork(true); - vlan.setName("DefaultNetwork"); - vlan.setGateway("192.168.1.1"); - vlan.setMask(24); - vlan.setType(NetworkType.INTERNAL); - vlan.addLink(new RESTLink("edit", - "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1")); - vlan.addLink(new RESTLink("ips", - "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips")); + public static VLANNetworkDto privateNetworkPut() { + VLANNetworkDto vlan = new VLANNetworkDto(); + vlan.setId(1); + vlan.setAddress("192.168.1.0"); + vlan.setDefaultNetwork(true); + vlan.setName("DefaultNetwork"); + vlan.setGateway("192.168.1.1"); + vlan.setMask(24); + vlan.setType(NetworkType.INTERNAL); + vlan.addLink(new RESTLink("edit", "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1")); + vlan.addLink(new RESTLink("ips", "http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips")); - return vlan; - } + return vlan; + } - public static VLANNetworkDto publicNetworkPut() - { - VLANNetworkDto vlan = new VLANNetworkDto(); - vlan.setId(1); - vlan.setAddress("192.168.1.0"); - vlan.setDefaultNetwork(true); - vlan.setName("PublicNetwork"); - vlan.setGateway("192.168.1.1"); - vlan.setMask(24); - vlan.setType(NetworkType.PUBLIC); - vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); - vlan.addLink(new RESTLink("ips", "http://localhost/api/admin/datacenters/1/network/1/ips")); + public static VLANNetworkDto publicNetworkPut() { + VLANNetworkDto vlan = new VLANNetworkDto(); + vlan.setId(1); + vlan.setAddress("192.168.1.0"); + vlan.setDefaultNetwork(true); + vlan.setName("PublicNetwork"); + vlan.setGateway("192.168.1.1"); + vlan.setMask(24); + vlan.setType(NetworkType.PUBLIC); + vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); + vlan.addLink(new RESTLink("ips", "http://localhost/api/admin/datacenters/1/network/1/ips")); - return vlan; - } + return vlan; + } - public static VLANNetworkDto externalNetworkPut() - { - VLANNetworkDto vlan = new VLANNetworkDto(); - vlan.setId(1); - vlan.setAddress("192.168.1.0"); - vlan.setDefaultNetwork(true); - vlan.setName("ExternalNetwork"); - vlan.setGateway("192.168.1.1"); - vlan.setMask(24); - vlan.setType(NetworkType.EXTERNAL); - vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); - vlan.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - vlan.addLink(new RESTLink("ips", - "http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips")); + public static VLANNetworkDto externalNetworkPut() { + VLANNetworkDto vlan = new VLANNetworkDto(); + vlan.setId(1); + vlan.setAddress("192.168.1.0"); + vlan.setDefaultNetwork(true); + vlan.setName("ExternalNetwork"); + vlan.setGateway("192.168.1.1"); + vlan.setMask(24); + vlan.setType(NetworkType.EXTERNAL); + vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); + vlan.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + vlan.addLink(new RESTLink("ips", "http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips")); - return vlan; - } + return vlan; + } - public static VLANNetworkDto unmanagedNetworkPut() - { - VLANNetworkDto vlan = new VLANNetworkDto(); - vlan.setId(1); - vlan.setAddress("192.168.1.0"); - vlan.setDefaultNetwork(true); - vlan.setName("UnmanagedNetwork"); - vlan.setGateway("192.168.1.1"); - vlan.setMask(24); - vlan.setType(NetworkType.UNMANAGED); - vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); - vlan.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - vlan.addLink(new RESTLink("ips", - "http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips")); + public static VLANNetworkDto unmanagedNetworkPut() { + VLANNetworkDto vlan = new VLANNetworkDto(); + vlan.setId(1); + vlan.setAddress("192.168.1.0"); + vlan.setDefaultNetwork(true); + vlan.setName("UnmanagedNetwork"); + vlan.setGateway("192.168.1.1"); + vlan.setMask(24); + vlan.setType(NetworkType.UNMANAGED); + vlan.addLink(new RESTLink("edit", "http://localhost/api/admin/datacenters/1/network/1")); + vlan.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + vlan.addLink(new RESTLink("ips", "http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips")); - return vlan; - } + return vlan; + } - public static String vlanNetworkPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("
192.168.1.0
"); - buffer.append("true"); - buffer.append("192.168.1.1"); - buffer.append("24"); - buffer.append("DefaultNetwork"); - buffer.append("
"); - return buffer.toString(); - } + public static String vlanNetworkPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("
192.168.1.0
"); + buffer.append("true"); + buffer.append("192.168.1.1"); + buffer.append("24"); + buffer.append("DefaultNetwork"); + buffer.append("
"); + return buffer.toString(); + } - public static String privateNetworkPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1", "edit")); - buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1/ips", "ips")); - buffer.append("
192.168.1.0
"); - buffer.append("true"); - buffer.append("192.168.1.1"); - buffer.append("1"); - buffer.append("24"); - buffer.append("DefaultNetwork"); - buffer.append("INTERNAL"); - buffer.append("
"); - return buffer.toString(); - } + public static String privateNetworkPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1", "edit")); + buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1/ips", "ips")); + buffer.append("
192.168.1.0
"); + buffer.append("true"); + buffer.append("192.168.1.1"); + buffer.append("1"); + buffer.append("24"); + buffer.append("DefaultNetwork"); + buffer.append("INTERNAL"); + buffer.append("
"); + return buffer.toString(); + } - public static String publicNetworkPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/network/1", "edit")); - buffer.append(link("/admin/datacenters/1/network/1/ips", "ips")); - buffer.append("
192.168.1.0
"); - buffer.append("true"); - buffer.append("192.168.1.1"); - buffer.append("1"); - buffer.append("24"); - buffer.append("PublicNetwork"); - buffer.append("PUBLIC"); - buffer.append("
"); - return buffer.toString(); - } + public static String publicNetworkPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/network/1", "edit")); + buffer.append(link("/admin/datacenters/1/network/1/ips", "ips")); + buffer.append("
192.168.1.0
"); + buffer.append("true"); + buffer.append("192.168.1.1"); + buffer.append("1"); + buffer.append("24"); + buffer.append("PublicNetwork"); + buffer.append("PUBLIC"); + buffer.append("
"); + return buffer.toString(); + } - public static String externalNetworkPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/network/1", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer.append(link("/admin/enterprises/1/limits/1/externalnetworks/1/ips", "ips")); - buffer.append("
192.168.1.0
"); - buffer.append("true"); - buffer.append("192.168.1.1"); - buffer.append("1"); - buffer.append("24"); - buffer.append("ExternalNetwork"); - buffer.append("EXTERNAL"); - buffer.append("
"); - return buffer.toString(); - } + public static String externalNetworkPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/network/1", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/admin/enterprises/1/limits/1/externalnetworks/1/ips", "ips")); + buffer.append("
192.168.1.0
"); + buffer.append("true"); + buffer.append("192.168.1.1"); + buffer.append("1"); + buffer.append("24"); + buffer.append("ExternalNetwork"); + buffer.append("EXTERNAL"); + buffer.append("
"); + return buffer.toString(); + } - public static String unmanagedNetworkPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/admin/datacenters/1/network/1", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer.append(link("/admin/enterprises/1/limits/1/externalnetworks/1/ips", "ips")); - buffer.append("
192.168.1.0
"); - buffer.append("true"); - buffer.append("192.168.1.1"); - buffer.append("1"); - buffer.append("24"); - buffer.append("UnmanagedNetwork"); - buffer.append("UNMANAGED"); - buffer.append("
"); - return buffer.toString(); - } + public static String unmanagedNetworkPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/datacenters/1/network/1", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/admin/enterprises/1/limits/1/externalnetworks/1/ips", "ips")); + buffer.append("
192.168.1.0
"); + buffer.append("true"); + buffer.append("192.168.1.1"); + buffer.append("1"); + buffer.append("24"); + buffer.append("UnmanagedNetwork"); + buffer.append("UNMANAGED"); + buffer.append("
"); + return buffer.toString(); + } - public static String privateIpPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1/ips/1", "self", - "privateip")); - buffer.append("false"); - buffer.append("1"); - buffer.append("00:58:5A:c0:C3:01"); - buffer.append("private ip"); - buffer.append("false"); - buffer.append(""); - return buffer.toString(); - } + public static String privateIpPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/privatenetworks/1/ips/1", "self", "privateip")); + buffer.append("false"); + buffer.append("1"); + buffer.append("00:58:5A:c0:C3:01"); + buffer.append("private ip"); + buffer.append("false"); + buffer.append(""); + return buffer.toString(); + } - public static String linksDtoPayload(final LinksDto dto) - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - for (RESTLink link : dto.getLinks()) - { - buffer.append(link(link)); - } - buffer.append(""); - return buffer.toString(); - } + public static String linksDtoPayload(final LinksDto dto) { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + for (RESTLink link : dto.getLinks()) { + buffer.append(link(link)); + } + buffer.append(""); + return buffer.toString(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java index bbca9da2cb..636e7f5d15 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/PricingResources.java @@ -38,273 +38,239 @@ import com.abiquo.server.core.pricing.PricingTierDto; * @author Ignasi Barrera * @author Susana Acedo */ -public class PricingResources -{ +public class PricingResources { - public static CurrencyDto currencyPost() - { - CurrencyDto currency = new CurrencyDto(); - currency.setName("yuan"); - currency.setSymbol("DUMMY"); - currency.setDigits(3); - return currency; - } + public static CurrencyDto currencyPost() { + CurrencyDto currency = new CurrencyDto(); + currency.setName("yuan"); + currency.setSymbol("DUMMY"); + currency.setDigits(3); + return currency; + } - public static CurrencyDto currencyPut() - { - CurrencyDto currency = new CurrencyDto(); - currency.setName("yuan"); - currency.setSymbol("DUMMY"); - currency.setDigits(3); - currency.setId(1); - currency.addLink(new RESTLink("edit", "http://localhost/api/config/currencies/1")); - return currency; - } + public static CurrencyDto currencyPut() { + CurrencyDto currency = new CurrencyDto(); + currency.setName("yuan"); + currency.setSymbol("DUMMY"); + currency.setDigits(3); + currency.setId(1); + currency.addLink(new RESTLink("edit", "http://localhost/api/config/currencies/1")); + return currency; + } - public static String currencyPostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("DUMMY"); - buffer.append("3"); - buffer.append("yuan"); - buffer.append(""); - return buffer.toString(); - } + public static String currencyPostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("DUMMY"); + buffer.append("3"); + buffer.append("yuan"); + buffer.append(""); + return buffer.toString(); + } - public static String currencyPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/config/currencies/1", "edit")); - buffer.append("DUMMY"); - buffer.append("3"); - buffer.append("1"); - buffer.append("yuan"); - buffer.append(""); - return buffer.toString(); - } + public static String currencyPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/config/currencies/1", "edit")); + buffer.append("DUMMY"); + buffer.append("3"); + buffer.append("1"); + buffer.append("yuan"); + buffer.append(""); + return buffer.toString(); + } - public static Object costcodePost() - { - CostCodeDto costcode = new CostCodeDto(); - costcode.setName("cost code"); - costcode.setDescription("description"); - return costcode; - } + public static Object costcodePost() { + CostCodeDto costcode = new CostCodeDto(); + costcode.setName("cost code"); + costcode.setDescription("description"); + return costcode; + } - public static Object costcodePut() - { - CostCodeDto costcode = new CostCodeDto(); - costcode.setName("cost code"); - costcode.setDescription("description"); - costcode.setId(1); - costcode.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1")); - return costcode; - } + public static Object costcodePut() { + CostCodeDto costcode = new CostCodeDto(); + costcode.setName("cost code"); + costcode.setDescription("description"); + costcode.setId(1); + costcode.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1")); + return costcode; + } - public static String costcodePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("cost code"); - buffer.append("description"); - buffer.append(""); - return buffer.toString(); - } + public static String costcodePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("cost code"); + buffer.append("description"); + buffer.append(""); + return buffer.toString(); + } - public static String costcodePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/config/costcodes/1", "edit")); - buffer.append("description"); - buffer.append("1"); - buffer.append("cost code"); - buffer.append(""); - return buffer.toString(); - } + public static String costcodePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/config/costcodes/1", "edit")); + buffer.append("description"); + buffer.append("1"); + buffer.append("cost code"); + buffer.append(""); + return buffer.toString(); + } - public static Object pricingtemplatePost() - { - PricingTemplateDto pricingtemplate = new PricingTemplateDto(); - pricingtemplate.setName("pricing template"); - pricingtemplate.setDescription("pt_description"); - pricingtemplate.setHdGB(new BigDecimal(0)); - pricingtemplate.setStandingChargePeriod(new BigDecimal(0)); - pricingtemplate.setVlan(new BigDecimal(0)); - pricingtemplate.setChargingPeriod(1); - pricingtemplate.setMinimumChargePeriod(new BigDecimal(0)); - pricingtemplate.setShowChangesBefore(true); - pricingtemplate.setShowMinimumCharge(false); - pricingtemplate.setMinimumCharge(2); - pricingtemplate.setPublicIp(new BigDecimal(0)); - pricingtemplate.setVcpu(new BigDecimal(0)); - pricingtemplate.setMemoryGB(new BigDecimal(0)); - pricingtemplate.setDefaultTemplate(true); - pricingtemplate - .addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1")); - return pricingtemplate; - } + public static Object pricingtemplatePost() { + PricingTemplateDto pricingtemplate = new PricingTemplateDto(); + pricingtemplate.setName("pricing template"); + pricingtemplate.setDescription("pt_description"); + pricingtemplate.setHdGB(new BigDecimal(0)); + pricingtemplate.setStandingChargePeriod(new BigDecimal(0)); + pricingtemplate.setVlan(new BigDecimal(0)); + pricingtemplate.setChargingPeriod(1); + pricingtemplate.setMinimumChargePeriod(new BigDecimal(0)); + pricingtemplate.setShowChangesBefore(true); + pricingtemplate.setShowMinimumCharge(false); + pricingtemplate.setMinimumCharge(2); + pricingtemplate.setPublicIp(new BigDecimal(0)); + pricingtemplate.setVcpu(new BigDecimal(0)); + pricingtemplate.setMemoryGB(new BigDecimal(0)); + pricingtemplate.setDefaultTemplate(true); + pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1")); + return pricingtemplate; + } - public static Object pricingtemplatePut() - { - PricingTemplateDto pricingtemplate = new PricingTemplateDto(); - pricingtemplate.setName("pricing template"); - pricingtemplate.setDescription("pt_description"); - pricingtemplate.setHdGB(new BigDecimal(0)); - pricingtemplate.setStandingChargePeriod(new BigDecimal(0)); - pricingtemplate.setVlan(new BigDecimal(0)); - pricingtemplate.setChargingPeriod(1); - pricingtemplate.setMinimumChargePeriod(new BigDecimal(0)); - pricingtemplate.setShowChangesBefore(true); - pricingtemplate.setShowMinimumCharge(false); - pricingtemplate.setMinimumCharge(2); - pricingtemplate.setPublicIp(new BigDecimal(0)); - pricingtemplate.setVcpu(new BigDecimal(0)); - pricingtemplate.setMemoryGB(new BigDecimal(0)); - pricingtemplate.setDefaultTemplate(true); - pricingtemplate - .addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1")); - pricingtemplate.setId(1); - pricingtemplate.addLink(new RESTLink("edit", - "http://localhost/api/config/pricingtemplates/1")); - return pricingtemplate; - } + public static Object pricingtemplatePut() { + PricingTemplateDto pricingtemplate = new PricingTemplateDto(); + pricingtemplate.setName("pricing template"); + pricingtemplate.setDescription("pt_description"); + pricingtemplate.setHdGB(new BigDecimal(0)); + pricingtemplate.setStandingChargePeriod(new BigDecimal(0)); + pricingtemplate.setVlan(new BigDecimal(0)); + pricingtemplate.setChargingPeriod(1); + pricingtemplate.setMinimumChargePeriod(new BigDecimal(0)); + pricingtemplate.setShowChangesBefore(true); + pricingtemplate.setShowMinimumCharge(false); + pricingtemplate.setMinimumCharge(2); + pricingtemplate.setPublicIp(new BigDecimal(0)); + pricingtemplate.setVcpu(new BigDecimal(0)); + pricingtemplate.setMemoryGB(new BigDecimal(0)); + pricingtemplate.setDefaultTemplate(true); + pricingtemplate.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1")); + pricingtemplate.setId(1); + pricingtemplate.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1")); + return pricingtemplate; + } - public static String pricingtemplatePostPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("pricing template"); - buffer.append("pt_description"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("0"); - buffer.append("true"); - buffer.append("false"); - buffer.append("2"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("true"); - buffer.append(""); - buffer.append(""); - return buffer.toString(); - } + public static String pricingtemplatePostPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("pricing template"); + buffer.append("pt_description"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("0"); + buffer.append("true"); + buffer.append("false"); + buffer.append("2"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("true"); + buffer.append(""); + buffer.append(""); + return buffer.toString(); + } - public static String pricingtemplatePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append("pricing template"); - buffer.append("pt_description"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("1"); - buffer.append("0"); - buffer.append("true"); - buffer.append("false"); - buffer.append("2"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("true"); - buffer.append(""); - buffer.append("1"); - buffer.append(link("/config/pricingtemplates/1", "edit")); - buffer.append(""); - return buffer.toString(); - } + public static String pricingtemplatePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append("pricing template"); + buffer.append("pt_description"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("1"); + buffer.append("0"); + buffer.append("true"); + buffer.append("false"); + buffer.append("2"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("true"); + buffer.append(""); + buffer.append("1"); + buffer.append(link("/config/pricingtemplates/1", "edit")); + buffer.append(""); + return buffer.toString(); + } - public static Object costcodecurrencyPut() - { - CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto(); - costcodecurrency.addLink(new RESTLink("edit", - "http://localhost/api/config/costcodes/1/currencies")); - costcodecurrency.addLink(new RESTLink("currency", - "http://localhost/api/config/currencies/1")); - costcodecurrency.setPrice(new BigDecimal("300")); - CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto(); - costcodecurrencies.add(costcodecurrency); - return costcodecurrencies; - } + public static Object costcodecurrencyPut() { + CostCodeCurrencyDto costcodecurrency = new CostCodeCurrencyDto(); + costcodecurrency.addLink(new RESTLink("edit", "http://localhost/api/config/costcodes/1/currencies")); + costcodecurrency.addLink(new RESTLink("currency", "http://localhost/api/config/currencies/1")); + costcodecurrency.setPrice(new BigDecimal("300")); + CostCodeCurrenciesDto costcodecurrencies = new CostCodeCurrenciesDto(); + costcodecurrencies.add(costcodecurrency); + return costcodecurrencies; + } - public static String costcodecurrencyPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(""); - buffer.append("300"); - buffer - .append(""); - buffer.append(""); - buffer.append(""); + public static String costcodecurrencyPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(""); + buffer.append("300"); + buffer.append(""); + buffer.append(""); + buffer.append(""); - buffer.append(""); - return buffer.toString(); - } + buffer.append(""); + return buffer.toString(); + } - public static Object pricingCostcodePut() - { - PricingCostCodeDto pricingcostcode = new PricingCostCodeDto(); - pricingcostcode.setId(1); - pricingcostcode.setPrice(new BigDecimal("400")); - pricingcostcode - .addLink(new RESTLink("costcode", "http://localhost/api/config/costcodes/1")); - pricingcostcode.addLink(new RESTLink("pricingtemplate", - "http://localhost/api/config/pricingtemplates/1")); - pricingcostcode.addLink(new RESTLink("edit", - "http://localhost/api/config/pricingtemplates/1/costcodes/1")); - return pricingcostcode; - } + public static Object pricingCostcodePut() { + PricingCostCodeDto pricingcostcode = new PricingCostCodeDto(); + pricingcostcode.setId(1); + pricingcostcode.setPrice(new BigDecimal("400")); + pricingcostcode.addLink(new RESTLink("costcode", "http://localhost/api/config/costcodes/1")); + pricingcostcode.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1")); + pricingcostcode.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/costcodes/1")); + return pricingcostcode; + } - public static String pricingCostCodePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(""); - buffer - .append(""); - buffer.append("400"); - buffer.append("1"); - buffer.append(link("/config/pricingtemplates/1/costcodes/1", "edit")); - buffer.append(""); - return buffer.toString(); - } + public static String pricingCostCodePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(""); + buffer.append(""); + buffer.append("400"); + buffer.append("1"); + buffer.append(link("/config/pricingtemplates/1/costcodes/1", "edit")); + buffer.append(""); + return buffer.toString(); + } - public static Object pricingTierPut() - { - PricingTierDto pricingtier = new PricingTierDto(); - pricingtier.setId(1); - pricingtier.setPrice(new BigDecimal("600")); - pricingtier.addLink(new RESTLink("tier", - "http://localhost/api/admin/datacenters/1/storage/tiers/2")); - pricingtier.addLink(new RESTLink("pricingtemplate", - "http://localhost/api/config/pricingtemplates/1")); - pricingtier.addLink(new RESTLink("edit", - "http://localhost/api/config/pricingtemplates/1/tiers/2")); - return pricingtier; - } + public static Object pricingTierPut() { + PricingTierDto pricingtier = new PricingTierDto(); + pricingtier.setId(1); + pricingtier.setPrice(new BigDecimal("600")); + pricingtier.addLink(new RESTLink("tier", "http://localhost/api/admin/datacenters/1/storage/tiers/2")); + pricingtier.addLink(new RESTLink("pricingtemplate", "http://localhost/api/config/pricingtemplates/1")); + pricingtier.addLink(new RESTLink("edit", "http://localhost/api/config/pricingtemplates/1/tiers/2")); + return pricingtier; + } - public static String pricingTierPutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer - .append(""); - buffer - .append(""); - buffer.append("600"); - buffer.append("1"); - buffer.append(link("/config/pricingtemplates/1/tiers/2", "edit")); - buffer.append(""); - return buffer.toString(); - } + public static String pricingTierPutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(""); + buffer.append(""); + buffer.append("600"); + buffer.append("1"); + buffer.append(link("/config/pricingtemplates/1/tiers/2", "edit")); + buffer.append(""); + return buffer.toString(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/TemplateResources.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/TemplateResources.java index d8f67b403c..304889b5ce 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/TemplateResources.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/TemplateResources.java @@ -35,144 +35,121 @@ import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; * @author Ignasi Barrera * @author Francesc Montserrat */ -public class TemplateResources -{ - public static DatacenterRepositoryDto datacenterRepositoryPut() - { - DatacenterRepositoryDto dcRepository = new DatacenterRepositoryDto(); - dcRepository.setName("Datacenter Repo"); - dcRepository.setRepositoryCapacityMb(0); - dcRepository.setRepositoryLocation("10.60.1.104:/volume1/nfs-devel"); - dcRepository.setRepositoryRemainingMb(0); - dcRepository.addLink(new RESTLink("applianceManagerRepositoryUri", - "http://localhost/am/erepos/1")); - dcRepository - .addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); - dcRepository.addLink(new RESTLink("edit", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1")); - dcRepository - .addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - dcRepository.addLink(new RESTLink("refresh", +public class TemplateResources { + public static DatacenterRepositoryDto datacenterRepositoryPut() { + DatacenterRepositoryDto dcRepository = new DatacenterRepositoryDto(); + dcRepository.setName("Datacenter Repo"); + dcRepository.setRepositoryCapacityMb(0); + dcRepository.setRepositoryLocation("10.60.1.104:/volume1/nfs-devel"); + dcRepository.setRepositoryRemainingMb(0); + dcRepository.addLink(new RESTLink("applianceManagerRepositoryUri", "http://localhost/am/erepos/1")); + dcRepository.addLink(new RESTLink("datacenter", "http://localhost/api/admin/datacenters/1")); + dcRepository.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/datacenterrepositories/1")); + dcRepository.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + dcRepository.addLink(new RESTLink("refresh", "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/actions/refresh")); - dcRepository - .addLink(new RESTLink("virtualmachinetemplates", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates")); + dcRepository.addLink(new RESTLink("virtualmachinetemplates", + "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates")); - return dcRepository; - } + return dcRepository; + } - public static VirtualMachineTemplateDto virtualMachineTemplatePut() - { - VirtualMachineTemplateDto template = new VirtualMachineTemplateDto(); - template.setName("Template"); - template.setId(1); - template.setDescription("Description"); - template - .addLink(new RESTLink("edit", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1")); - template.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); - template.addLink(new RESTLink("conversions", "http://localhost/api/admin/enterprises/1" + public static VirtualMachineTemplateDto virtualMachineTemplatePut() { + VirtualMachineTemplateDto template = new VirtualMachineTemplateDto(); + template.setName("Template"); + template.setId(1); + template.setDescription("Description"); + template.addLink(new RESTLink("edit", + "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1")); + template.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1")); + template.addLink(new RESTLink("conversions", "http://localhost/api/admin/enterprises/1" + "/datacenterrepositories/1/virtualmachinetemplates/1/conversions")); - template.addLink(new RESTLink("tasks", "http://localhost/api/admin/enterprises/1" + template.addLink(new RESTLink("tasks", "http://localhost/api/admin/enterprises/1" + "/datacenterrepositories/1/virtualmachinetemplates/1/tasks")); - return template; - } + return template; + } - public static String virtualMachineTemplatePutPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link( - "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", "edit")); - buffer.append(link("/admin/enterprises/1", "enterprise")); - buffer.append(link("/admin/enterprises/1" - + "/datacenterrepositories/1/virtualmachinetemplates/1/conversions", "conversions")); + public static String virtualMachineTemplatePutPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", "edit")); + buffer.append(link("/admin/enterprises/1", "enterprise")); + buffer.append(link("/admin/enterprises/1" + "/datacenterrepositories/1/virtualmachinetemplates/1/conversions", + "conversions")); - buffer.append(link("/admin/enterprises/1" - + "/datacenterrepositories/1/virtualmachinetemplates/1/tasks", "tasks")); - buffer.append("1"); - buffer.append("Template"); - buffer.append("Description"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("0"); - buffer.append("false"); - buffer.append("0"); - buffer.append("false"); - buffer.append(""); - return buffer.toString(); - } + buffer.append(link("/admin/enterprises/1" + "/datacenterrepositories/1/virtualmachinetemplates/1/tasks", "tasks")); + buffer.append("1"); + buffer.append("Template"); + buffer.append("Description"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("0"); + buffer.append("false"); + buffer.append("0"); + buffer.append("false"); + buffer.append(""); + return buffer.toString(); + } - public static VirtualMachineTemplatePersistentDto persistentData() - { - VirtualMachineTemplatePersistentDto dto = new VirtualMachineTemplatePersistentDto(); - dto.setPersistentTemplateName("New persistent template name"); - dto.setPersistentVolumeName("New persistent volume name"); - dto.addLink(new RESTLink("tier", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); - dto.addLink(new RESTLink("virtualdatacenter", - "http://localhost/api/cloud/virtualdatacenters/1")); - dto.addLink(new RESTLink("virtualmachinetemplate", + public static VirtualMachineTemplatePersistentDto persistentData() { + VirtualMachineTemplatePersistentDto dto = new VirtualMachineTemplatePersistentDto(); + dto.setPersistentTemplateName("New persistent template name"); + dto.setPersistentVolumeName("New persistent volume name"); + dto.addLink(new RESTLink("tier", "http://localhost/api/cloud/virtualdatacenters/1/tiers/1")); + dto.addLink(new RESTLink("virtualdatacenter", "http://localhost/api/cloud/virtualdatacenters/1")); + dto.addLink(new RESTLink("virtualmachinetemplate", "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1")); - return dto; - } + return dto; + } - public static String persistentPayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); - buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); - buffer.append(link( - "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", + public static String persistentPayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/cloud/virtualdatacenters/1/tiers/1", "tier")); + buffer.append(link("/cloud/virtualdatacenters/1", "virtualdatacenter")); + buffer.append(link("/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1", "virtualmachinetemplate")); - buffer - .append("New persistent template name"); - buffer.append("New persistent volume name"); - buffer.append(""); - return buffer.toString(); - } + buffer.append("New persistent template name"); + buffer.append("New persistent volume name"); + buffer.append(""); + return buffer.toString(); + } - public static ConversionDto conversionPut() - { - ConversionDto conversion = new ConversionDto(); - conversion.setState(ConversionState.ENQUEUED); - conversion.setSourceFormat(DiskFormatType.VMDK_STREAM_OPTIMIZED); - conversion.setSourcePath("source/path.vmkd"); - conversion.setTargetFormat(DiskFormatType.RAW); - conversion.setTargetPath("target/path.raw"); - conversion.setTargetSizeInBytes(1000000l); - conversion + public static ConversionDto conversionPut() { + ConversionDto conversion = new ConversionDto(); + conversion.setState(ConversionState.ENQUEUED); + conversion.setSourceFormat(DiskFormatType.VMDK_STREAM_OPTIMIZED); + conversion.setSourcePath("source/path.vmkd"); + conversion.setTargetFormat(DiskFormatType.RAW); + conversion.setTargetPath("target/path.raw"); + conversion.setTargetSizeInBytes(1000000l); + conversion .addLink(new RESTLink("edit", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW")); - conversion + "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW")); + conversion .addLink(new RESTLink("tasks", - "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW/tasks")); + "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW/tasks")); - return conversion; - } + return conversion; + } - public static String conversionPutPlayload() - { - StringBuffer buffer = new StringBuffer(); - buffer.append(""); - buffer - .append(link( - "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW", - "edit")); - buffer - .append(link( - "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW/tasks", - "tasks")); + public static String conversionPutPlayload() { + StringBuffer buffer = new StringBuffer(); + buffer.append(""); + buffer.append(link("/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW", + "edit")); + buffer.append(link( + "/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW/tasks", "tasks")); - buffer.append("ENQUEUED"); - buffer.append("VMDK_STREAM_OPTIMIZED"); - buffer.append("source/path.vmkd"); - buffer.append("RAW"); - buffer.append("target/path.raw"); - buffer.append("1000000"); - buffer.append(""); - return buffer.toString(); - } + buffer.append("ENQUEUED"); + buffer.append("VMDK_STREAM_OPTIMIZED"); + buffer.append("source/path.vmkd"); + buffer.append("RAW"); + buffer.append("target/path.raw"); + buffer.append("1000000"); + buffer.append(""); + return buffer.toString(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java index f096f8d4f1..40cdb681b1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/admin/RoleLiveApiTest.java @@ -46,67 +46,57 @@ import com.abiquo.server.core.enterprise.RoleDto; * @author Francesc Montserrat */ @Test(groups = "api", testName = "RoleLiveApiTest") -public class RoleLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class RoleLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - Role role = - Role.builder(env.context.getApiContext()).name("dummyRoleUpdateRole").blocked(false) - .build(); - role.save(); + public void testUpdate() { + Role role = Role.builder(env.context.getApiContext()).name("dummyRoleUpdateRole").blocked(false).build(); + role.save(); - role.setName("UPDATED_ROLE"); - role.update(); + role.setName("UPDATED_ROLE"); + role.update(); - // Recover the updated role - RoleDto updated = env.adminApi.getRole(role.getId()); + // Recover the updated role + RoleDto updated = env.adminApi.getRole(role.getId()); - assertEquals(updated.getName(), "UPDATED_ROLE"); + assertEquals(updated.getName(), "UPDATED_ROLE"); - role.delete(); - } + role.delete(); + } - public void testCreateRepeated() - { - Role repeated = Role.Builder.fromRole(env.role).build(); + public void testCreateRepeated() { + Role repeated = Role.Builder.fromRole(env.role).build(); - try - { - repeated.save(); - fail("Should not be able to create roles with the same name"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "ROLE-7"); - } - } + try { + repeated.save(); + fail("Should not be able to create roles with the same name"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "ROLE-7"); + } + } - public void testCreateEnterpriseRole() - { - Role entRole = Role.Builder.fromRole(env.role).build(); - entRole.setName(entRole.getName() + "enterprise"); - entRole.setEnterprise(env.enterprise); - entRole.save(); + public void testCreateEnterpriseRole() { + Role entRole = Role.Builder.fromRole(env.role).build(); + entRole.setName(entRole.getName() + "enterprise"); + entRole.setEnterprise(env.enterprise); + entRole.save(); - entRole = env.enterprise.findRole(RolePredicates.name(entRole.getName())); + entRole = env.enterprise.findRole(RolePredicates.name(entRole.getName())); - assertNotNull(entRole); - } + assertNotNull(entRole); + } - public void testAddPrivilege() - { - PrivilegeDto dto = env.configApi.getPrivilege(8); - Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto); - List privileges = env.role.listPrivileges(); - privileges.add(privilege); + public void testAddPrivilege() { + PrivilegeDto dto = env.configApi.getPrivilege(8); + Privilege privilege = DomainWrapper.wrap(env.context.getApiContext(), Privilege.class, dto); + List privileges = env.role.listPrivileges(); + privileges.add(privilege); - env.role.setPrivileges(privileges); + env.role.setPrivileges(privileges); - env.role.update(); + env.role.update(); - privilege = env.role.findPrivileges(PrivilegePredicates.name(dto.getName())); + privilege = env.role.findPrivileges(PrivilegePredicates.name(dto.getName())); - assertNotNull(privilege); - } + assertNotNull(privilege); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/HardDiskLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/HardDiskLiveApiTest.java index 98884bf3ef..3c745f5372 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/HardDiskLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/HardDiskLiveApiTest.java @@ -34,43 +34,37 @@ import com.abiquo.model.enumerator.HypervisorType; * @author Ignasi Barrera */ @Test(groups = "api", testName = "HardDiskLiveApiTest") -public class HardDiskLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private HardDisk hardDisk; +public class HardDiskLiveApiTest extends BaseAbiquoApiLiveApiTest { + private HardDisk hardDisk; - public void createHardDisk() - { - skipIfUnsupported(); + public void createHardDisk() { + skipIfUnsupported(); - hardDisk = - HardDisk.builder(env.context.getApiContext(), env.virtualDatacenter).sizeInMb(64L) - .build(); - hardDisk.save(); + hardDisk = HardDisk.builder(env.context.getApiContext(), env.virtualDatacenter).sizeInMb(64L).build(); + hardDisk.save(); - assertNotNull(hardDisk.getId()); - assertNotNull(hardDisk.getSequence()); + assertNotNull(hardDisk.getId()); + assertNotNull(hardDisk.getSequence()); - assertNotNull(env.virtualDatacenter.getHardDisk(hardDisk.getId())); - } + assertNotNull(env.virtualDatacenter.getHardDisk(hardDisk.getId())); + } - @Test(dependsOnMethods = "createHardDisk") - public void deleteHardDisk() - { - skipIfUnsupported(); + @Test(dependsOnMethods = "createHardDisk") + public void deleteHardDisk() { + skipIfUnsupported(); - HardDisk hd = env.virtualDatacenter.getHardDisk(hardDisk.getId()); - assertNotNull(hd); + HardDisk hd = env.virtualDatacenter.getHardDisk(hardDisk.getId()); + assertNotNull(hd); - Integer id = hd.getId(); - hardDisk.delete(); - assertNull(env.virtualDatacenter.getHardDisk(id)); - } + Integer id = hd.getId(); + hardDisk.delete(); + assertNull(env.virtualDatacenter.getHardDisk(id)); + } - protected static void skipIfUnsupported() - { - if (!env.machine.getType().equals(HypervisorType.VMX_04)) - { - throw new SkipException("Cannot perform this test because hard disk actions are not available for this hypervisor"); - } - } + protected static void skipIfUnsupported() { + if (!env.machine.getType().equals(HypervisorType.VMX_04)) { + throw new SkipException( + "Cannot perform this test because hard disk actions are not available for this hypervisor"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveApiTest.java index 827c83b756..7f70c00a81 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualApplianceLiveApiTest.java @@ -39,70 +39,58 @@ import com.abiquo.server.core.cloud.VirtualApplianceState; * @author Francesc Montserrat */ @Test(groups = "api", testName = "VirtualApplianceLiveApiTest") -public class VirtualApplianceLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class VirtualApplianceLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - env.virtualAppliance.setName("Virtual AppAloha updated"); - env.virtualAppliance.update(); + public void testUpdate() { + env.virtualAppliance.setName("Virtual AppAloha updated"); + env.virtualAppliance.update(); - // Recover the updated virtual appliance - VirtualApplianceDto updated = - env.cloudApi.getVirtualAppliance(env.virtualDatacenter.unwrap(), - env.virtualAppliance.getId()); + // Recover the updated virtual appliance + VirtualApplianceDto updated = env.cloudApi.getVirtualAppliance(env.virtualDatacenter.unwrap(), + env.virtualAppliance.getId()); - assertEquals(updated.getName(), "Virtual AppAloha updated"); - } + assertEquals(updated.getName(), "Virtual AppAloha updated"); + } - public void testCreateRepeated() - { - VirtualAppliance repeated = - VirtualAppliance.Builder.fromVirtualAppliance(env.virtualAppliance).build(); + public void testCreateRepeated() { + VirtualAppliance repeated = VirtualAppliance.Builder.fromVirtualAppliance(env.virtualAppliance).build(); - repeated.save(); + repeated.save(); - List virtualAppliances = - env.cloudApi.listVirtualAppliances(env.virtualDatacenter.unwrap()).getCollection(); + List virtualAppliances = env.cloudApi.listVirtualAppliances(env.virtualDatacenter.unwrap()) + .getCollection(); - assertEquals(virtualAppliances.size(), 2); - repeated.delete(); - } + assertEquals(virtualAppliances.size(), 2); + repeated.delete(); + } - public void testGetState() - { - assertEquals(env.virtualAppliance.getState(), VirtualApplianceState.NOT_DEPLOYED); - } + public void testGetState() { + assertEquals(env.virtualAppliance.getState(), VirtualApplianceState.NOT_DEPLOYED); + } - public void testListVirtualMachinesReturnsAll() - { - List vms = new ArrayList(); + public void testListVirtualMachinesReturnsAll() { + List vms = new ArrayList(); - // Pagination by default is set to 25 items per page, so create a few more to verify that - // all are returned when listing - int numVms = 30; + // Pagination by default is set to 25 items per page, so create a few more + // to verify that + // all are returned when listing + int numVms = 30; - for (int i = 0; i < numVms; i++) - { - VirtualMachine vm = - VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).build(); - vm.save(); - vms.add(vm); - } + for (int i = 0; i < numVms; i++) { + VirtualMachine vm = VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).build(); + vm.save(); + vms.add(vm); + } - try - { - Iterable all = env.virtualAppliance.listVirtualMachines(); + try { + Iterable all = env.virtualAppliance.listVirtualMachines(); - assertNotNull(all); - assertTrue(size(all) >= numVms); - } - finally - { - for (VirtualMachine vm : vms) - { - vm.delete(); - } - } - } + assertNotNull(all); + assertTrue(size(all) >= numVms); + } finally { + for (VirtualMachine vm : vms) { + vm.delete(); + } + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java index 5c5025016a..14fdf14cba 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualDatacenterLiveApiTest.java @@ -49,161 +49,133 @@ import com.abiquo.server.core.cloud.VirtualDatacenterDto; * @author Francesc Montserrat */ @Test(groups = "api", testName = "VirtualDatacenterLiveApiTest") -public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private VirtualMachineTemplate template; +public class VirtualDatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest { + private VirtualMachineTemplate template; - public void testUpdate() - { - env.virtualDatacenter.setName("Aloha updated"); - env.virtualDatacenter.update(); + public void testUpdate() { + env.virtualDatacenter.setName("Aloha updated"); + env.virtualDatacenter.update(); - // Recover the updated virtual datacenter - VirtualDatacenterDto updated = - env.cloudApi.getVirtualDatacenter(env.virtualDatacenter.getId()); + // Recover the updated virtual datacenter + VirtualDatacenterDto updated = env.cloudApi.getVirtualDatacenter(env.virtualDatacenter.getId()); - assertEquals(updated.getName(), "Aloha updated"); - } + assertEquals(updated.getName(), "Aloha updated"); + } - public void testCreateRepeated() - { - PrivateNetwork newnet = - PrivateNetwork.builder(env.context.getApiContext()).name("Newnet").gateway("10.0.0.1") - .address("10.0.0.0").mask(24).build(); + public void testCreateRepeated() { + PrivateNetwork newnet = PrivateNetwork.builder(env.context.getApiContext()).name("Newnet").gateway("10.0.0.1") + .address("10.0.0.0").mask(24).build(); - VirtualDatacenter repeated = - Builder.fromVirtualDatacenter(env.virtualDatacenter).network(newnet).build(); + VirtualDatacenter repeated = Builder.fromVirtualDatacenter(env.virtualDatacenter).network(newnet).build(); - repeated.save(); + repeated.save(); - List virtualDatacenters = - env.cloudApi.listVirtualDatacenters(VirtualDatacenterOptions.builder().build()) - .getCollection(); + List virtualDatacenters = env.cloudApi.listVirtualDatacenters( + VirtualDatacenterOptions.builder().build()).getCollection(); - assertEquals(virtualDatacenters.size(), 2); - assertEquals(virtualDatacenters.get(0).getName(), virtualDatacenters.get(1).getName()); - repeated.delete(); - } + assertEquals(virtualDatacenters.size(), 2); + assertEquals(virtualDatacenters.get(0).getName(), virtualDatacenters.get(1).getName()); + repeated.delete(); + } - public void testCreateFromEnterprise() - { - Enterprise enterprise = - env.enterpriseAdminContext.getAdministrationService().getCurrentUser().getEnterprise(); - assertNotNull(enterprise); + public void testCreateFromEnterprise() { + Enterprise enterprise = env.enterpriseAdminContext.getAdministrationService().getCurrentUser().getEnterprise(); + assertNotNull(enterprise); - List datacenters = enterprise.listAllowedDatacenters(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); + List datacenters = enterprise.listAllowedDatacenters(); + assertNotNull(datacenters); + assertTrue(size(datacenters) > 0); - Datacenter datacenter = datacenters.get(0); + Datacenter datacenter = datacenters.get(0); - List hypervisors = datacenter.listAvailableHypervisors(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); + List hypervisors = datacenter.listAvailableHypervisors(); + assertNotNull(datacenters); + assertTrue(size(datacenters) > 0); - HypervisorType hypervisor = hypervisors.get(0); + HypervisorType hypervisor = hypervisors.get(0); - PrivateNetwork network = - PrivateNetwork.builder(env.enterpriseAdminContext.getApiContext()) - .name("DefaultNetwork").gateway("192.168.1.1").address("192.168.1.0").mask(24) - .build(); + PrivateNetwork network = PrivateNetwork.builder(env.enterpriseAdminContext.getApiContext()) + .name("DefaultNetwork").gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); - VirtualDatacenter virtualDatacenter = - VirtualDatacenter - .builder(env.enterpriseAdminContext.getApiContext(), datacenters.get(0), enterprise) - .name(PREFIX + "Plain Virtual Aloha from ENT").cpuCountLimits(18, 20) - .hdLimitsInMb(279172872, 279172872).publicIpsLimits(2, 2).ramLimits(19456, 20480) - .storageLimits(289910292, 322122547).vlansLimits(1, 2).hypervisorType(hypervisor) - .network(network).build(); + VirtualDatacenter virtualDatacenter = VirtualDatacenter + .builder(env.enterpriseAdminContext.getApiContext(), datacenters.get(0), enterprise) + .name(PREFIX + "Plain Virtual Aloha from ENT").cpuCountLimits(18, 20).hdLimitsInMb(279172872, 279172872) + .publicIpsLimits(2, 2).ramLimits(19456, 20480).storageLimits(289910292, 322122547).vlansLimits(1, 2) + .hypervisorType(hypervisor).network(network).build(); - virtualDatacenter.save(); - assertNotNull(virtualDatacenter.getId()); + virtualDatacenter.save(); + assertNotNull(virtualDatacenter.getId()); - virtualDatacenter.delete(); - } + virtualDatacenter.delete(); + } - public void testCreateFromVirtualDatacenter() - { - HypervisorType hypervisor = env.virtualDatacenter.getHypervisorType(); + public void testCreateFromVirtualDatacenter() { + HypervisorType hypervisor = env.virtualDatacenter.getHypervisorType(); - Enterprise enterprise = env.user.getEnterprise(); - assertNotNull(enterprise); + Enterprise enterprise = env.user.getEnterprise(); + assertNotNull(enterprise); - Datacenter datacenter = env.virtualDatacenter.getDatacenter(); - assertNotNull(datacenter); + Datacenter datacenter = env.virtualDatacenter.getDatacenter(); + assertNotNull(datacenter); - PrivateNetwork network = - PrivateNetwork.builder(env.plainUserContext.getApiContext()).name("DefaultNetwork") - .gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); + PrivateNetwork network = PrivateNetwork.builder(env.plainUserContext.getApiContext()).name("DefaultNetwork") + .gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); - VirtualDatacenter virtualDatacenter = - VirtualDatacenter.builder(env.context.getApiContext(), datacenter, enterprise) - .name(PREFIX + "Plain Virtual Aloha from VDC").cpuCountLimits(18, 20) - .hdLimitsInMb(279172872, 279172872).publicIpsLimits(2, 2).ramLimits(19456, 20480) - .storageLimits(289910292, 322122547).vlansLimits(1, 2).hypervisorType(hypervisor) - .network(network).build(); + VirtualDatacenter virtualDatacenter = VirtualDatacenter + .builder(env.context.getApiContext(), datacenter, enterprise).name(PREFIX + "Plain Virtual Aloha from VDC") + .cpuCountLimits(18, 20).hdLimitsInMb(279172872, 279172872).publicIpsLimits(2, 2).ramLimits(19456, 20480) + .storageLimits(289910292, 322122547).vlansLimits(1, 2).hypervisorType(hypervisor).network(network).build(); - virtualDatacenter.save(); - assertNotNull(virtualDatacenter.getId()); + virtualDatacenter.save(); + assertNotNull(virtualDatacenter.getId()); - virtualDatacenter.delete(); - } + virtualDatacenter.delete(); + } - public void testPurchaseIp() - { - PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0); - assertNotNull(publicIp); - env.virtualDatacenter.purchasePublicIp(publicIp); + public void testPurchaseIp() { + PublicIp publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0); + assertNotNull(publicIp); + env.virtualDatacenter.purchasePublicIp(publicIp); - PublicIp apiIp = - env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp - .getIp())); - assertNotNull(apiIp); + PublicIp apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp.getIp())); + assertNotNull(apiIp); - env.virtualDatacenter.releaseePublicIp(apiIp); - apiIp = - env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp - .getIp())); - assertNull(apiIp); - } + env.virtualDatacenter.releaseePublicIp(apiIp); + apiIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp.getIp())); + assertNull(apiIp); + } - public void testGetDefaultNetwork() - { - PrivateNetwork network = env.virtualDatacenter.getDefaultNetwork().toPrivateNetwork(); + public void testGetDefaultNetwork() { + PrivateNetwork network = env.virtualDatacenter.getDefaultNetwork().toPrivateNetwork(); - assertNotNull(network); - assertEquals(network.getName(), env.privateNetwork.getName()); - assertEquals(network.getType(), env.privateNetwork.getType()); - } + assertNotNull(network); + assertEquals(network.getName(), env.privateNetwork.getName()); + assertEquals(network.getType(), env.privateNetwork.getType()); + } - public void testGetAvailableTemplates() - { - List templates = env.virtualDatacenter.listAvailableTemplates(); - assertNotNull(templates); - assertFalse(templates.isEmpty()); + public void testGetAvailableTemplates() { + List templates = env.virtualDatacenter.listAvailableTemplates(); + assertNotNull(templates); + assertFalse(templates.isEmpty()); - template = templates.get(0); - } + template = templates.get(0); + } - @Test(dependsOnMethods = "testGetAvailableTemplates") - public void testFindAvailableTemplate() - { - VirtualMachineTemplate templateFound = - env.virtualDatacenter.findAvailableTemplate(VirtualMachineTemplatePredicates - .id(template.getId())); + @Test(dependsOnMethods = "testGetAvailableTemplates") + public void testFindAvailableTemplate() { + VirtualMachineTemplate templateFound = env.virtualDatacenter + .findAvailableTemplate(VirtualMachineTemplatePredicates.id(template.getId())); - assertNotNull(template); - assertNotNull(templateFound); - assertEquals(templateFound.getId(), template.getId()); - } + assertNotNull(template); + assertNotNull(templateFound); + assertEquals(templateFound.getId(), template.getId()); + } - @Test(dependsOnMethods = "testGetAvailableTemplates") - public void testGetAvailableTemplate() - { - VirtualMachineTemplate templateFound = - env.virtualDatacenter.getAvailableTemplate(template.getId()); - assertNotNull(templateFound); - assertEquals(templateFound.getId(), template.getId()); - } + @Test(dependsOnMethods = "testGetAvailableTemplates") + public void testGetAvailableTemplate() { + VirtualMachineTemplate templateFound = env.virtualDatacenter.getAvailableTemplate(template.getId()); + assertNotNull(templateFound); + assertEquals(templateFound.getId(), template.getId()); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java index 1416d81fc1..4f867928ef 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineLiveApiTest.java @@ -45,98 +45,81 @@ import com.abiquo.server.core.cloud.VirtualMachineState; * @author Francesc Montserrat */ @Test(groups = "api", testName = "VirtualMachineLiveApiTest") -public class VirtualMachineLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testHasDataFromNode() - { - assertNotNull(env.virtualMachine.getNameLabel()); - assertNotNull(env.virtualMachine.getInternalName()); - assertNotNull(env.virtualMachine.getOwnerName()); - } +public class VirtualMachineLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testHasDataFromNode() { + assertNotNull(env.virtualMachine.getNameLabel()); + assertNotNull(env.virtualMachine.getInternalName()); + assertNotNull(env.virtualMachine.getOwnerName()); + } - public void testUpdateInfoFromNode() - { - env.virtualMachine.setNameLabel(PREFIX + "-label-updated"); - env.virtualMachine.update(); - env.virtualMachine.refresh(); + public void testUpdateInfoFromNode() { + env.virtualMachine.setNameLabel(PREFIX + "-label-updated"); + env.virtualMachine.update(); + env.virtualMachine.refresh(); - assertEquals(env.virtualMachine.getNameLabel(), PREFIX + "-label-updated"); - } + assertEquals(env.virtualMachine.getNameLabel(), PREFIX + "-label-updated"); + } - public void testGetTasks() - { - List tasks = env.virtualMachine.listTasks(); - assertNotNull(tasks); - } + public void testGetTasks() { + List tasks = env.virtualMachine.listTasks(); + assertNotNull(tasks); + } - public void testGetState() - { - VirtualMachineState state = env.virtualMachine.getState(); - assertEquals(state, VirtualMachineState.NOT_ALLOCATED); - } + public void testGetState() { + VirtualMachineState state = env.virtualMachine.getState(); + assertEquals(state, VirtualMachineState.NOT_ALLOCATED); + } - public void testIsPersistent() - { - assertFalse(env.virtualMachine.isPersistent()); - } + public void testIsPersistent() { + assertFalse(env.virtualMachine.isPersistent()); + } - public void testGetVirtualAppliance() - { - VirtualAppliance vapp = env.virtualMachine.getVirtualAppliance(); - assertNotNull(vapp); - assertEquals(vapp.getId(), env.virtualAppliance.getId()); - } + public void testGetVirtualAppliance() { + VirtualAppliance vapp = env.virtualMachine.getVirtualAppliance(); + assertNotNull(vapp); + assertEquals(vapp.getId(), env.virtualAppliance.getId()); + } - public void testRebootVirtualMachineFailsWhenNotAllocated() - { - // Since the virtual machine is not deployed, this should not generate a task + public void testRebootVirtualMachineFailsWhenNotAllocated() { + // Since the virtual machine is not deployed, this should not generate a + // task - try - { - env.virtualMachine.reboot(); - fail("Reboot should have failed for the NOT_ALLOCATED virtual machine"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "VM-11"); - } - } + try { + env.virtualMachine.reboot(); + fail("Reboot should have failed for the NOT_ALLOCATED virtual machine"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "VM-11"); + } + } - public void testUpdateForcingLimits() - { - int originalHard = env.virtualDatacenter.getCpuCountHardLimit(); - int originalSoft = env.virtualDatacenter.getCpuCountSoftLimit(); + public void testUpdateForcingLimits() { + int originalHard = env.virtualDatacenter.getCpuCountHardLimit(); + int originalSoft = env.virtualDatacenter.getCpuCountSoftLimit(); - env.virtualDatacenter.setCpuCountHardLimit(10); - env.virtualDatacenter.setCpuCountSoftLimit(5); - env.virtualDatacenter.update(); + env.virtualDatacenter.setCpuCountHardLimit(10); + env.virtualDatacenter.setCpuCountSoftLimit(5); + env.virtualDatacenter.update(); - try - { - VirtualMachine vm = env.virtualAppliance.getVirtualMachine(env.virtualMachine.getId()); - vm.setCpu(7); - AsyncTask task = vm.update(true); + try { + VirtualMachine vm = env.virtualAppliance.getVirtualMachine(env.virtualMachine.getId()); + vm.setCpu(7); + AsyncTask task = vm.update(true); - assertNull(task); - assertEquals(vm.getCpu(), 7); - } - finally - { - env.virtualDatacenter.setCpuCountHardLimit(originalHard); - env.virtualDatacenter.setCpuCountSoftLimit(originalSoft); - env.virtualDatacenter.update(); - } - } + assertNull(task); + assertEquals(vm.getCpu(), 7); + } finally { + env.virtualDatacenter.setCpuCountHardLimit(originalHard); + env.virtualDatacenter.setCpuCountSoftLimit(originalSoft); + env.virtualDatacenter.update(); + } + } - public void testAttachDvd() - { - VirtualMachine vm = - VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).dvd(true).build(); - vm.save(); + public void testAttachDvd() { + VirtualMachine vm = VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).dvd(true).build(); + vm.save(); - VirtualMachineDto updated = - env.cloudApi.getVirtualMachine(env.virtualAppliance.unwrap(), vm.getId()); + VirtualMachineDto updated = env.cloudApi.getVirtualMachine(env.virtualAppliance.unwrap(), vm.getId()); - assertNotNull(updated.getDvd()); - } + assertNotNull(updated.getDvd()); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java index 0a82a9b806..6a5e5beb5b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineNetworkingLiveApiTest.java @@ -52,190 +52,168 @@ import com.google.common.collect.Lists; * @author Ignasi Barrera */ @Test(groups = "api", testName = "VirtualMachineNetworkingLiveApiTest") -public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private PrivateIp privateIp; +public class VirtualMachineNetworkingLiveApiTest extends BaseAbiquoApiLiveApiTest { + private PrivateIp privateIp; - private ExternalIp externalIp; + private ExternalIp externalIp; - private PublicIp publicIpInfrastructure; + private PublicIp publicIpInfrastructure; - private PublicIp publicIpCloud; + private PublicIp publicIpCloud; - private UnmanagedIp unmanagedIp1; + private UnmanagedIp unmanagedIp1; - private UnmanagedIp unmanagedIp2; + private UnmanagedIp unmanagedIp2; - @BeforeClass - public void setupIps() - { - privateIp = env.privateNetwork.listUnusedIps().get(0); - assertNotNull(privateIp); + @BeforeClass + public void setupIps() { + privateIp = env.privateNetwork.listUnusedIps().get(0); + assertNotNull(privateIp); - externalIp = env.externalNetwork.listUnusedIps().get(0); - assertNotNull(externalIp); + externalIp = env.externalNetwork.listUnusedIps().get(0); + assertNotNull(externalIp); - publicIpInfrastructure = env.virtualDatacenter.listAvailablePublicIps().get(0); - env.virtualDatacenter.purchasePublicIp(publicIpInfrastructure); + publicIpInfrastructure = env.virtualDatacenter.listAvailablePublicIps().get(0); + env.virtualDatacenter.purchasePublicIp(publicIpInfrastructure); - publicIpCloud = - env.virtualDatacenter.findPurchasedPublicIp(IpPredicates - . address(publicIpInfrastructure.getIp())); - assertNotNull(publicIpCloud); - } + publicIpCloud = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates + . address(publicIpInfrastructure.getIp())); + assertNotNull(publicIpCloud); + } - @AfterClass - public void restorePrivateIp() - { - AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(privateIp)); - assertNull(task); + @AfterClass + public void restorePrivateIp() { + AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(privateIp)); + assertNull(task); - List> nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 1); - assertEquals(nics.get(0).getId(), privateIp.getId()); + List> nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 1); + assertEquals(nics.get(0).getId(), privateIp.getId()); - String address = publicIpCloud.getIp(); - env.virtualDatacenter.releaseePublicIp(publicIpCloud); - assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates - . address(address))); - } + String address = publicIpCloud.getIp(); + env.virtualDatacenter.releaseePublicIp(publicIpCloud); + assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(address))); + } - // TODO: Infrastructure edit link for public ips can not be used to attach - @Test(enabled = false) - public void testAttachInfrastructurePublicIp() - { - AsyncTask task = - env.virtualMachine.setNics(Lists.> newArrayList(publicIpInfrastructure)); - assertNull(task); + // TODO: Infrastructure edit link for public ips can not be used to attach + @Test(enabled = false) + public void testAttachInfrastructurePublicIp() { + AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(publicIpInfrastructure)); + assertNull(task); - List> nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 1); - assertEquals(nics.get(0).getId(), publicIpInfrastructure.getId()); - } + List> nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 1); + assertEquals(nics.get(0).getId(), publicIpInfrastructure.getId()); + } - public void testAttachPublicIp() - { - AsyncTask task = - env.virtualMachine.setNics(Lists.> newArrayList(publicIpCloud)); - assertNull(task); + public void testAttachPublicIp() { + AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(publicIpCloud)); + assertNull(task); - List> nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 1); - assertEquals(nics.get(0).getId(), publicIpCloud.getId()); - } + List> nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 1); + assertEquals(nics.get(0).getId(), publicIpCloud.getId()); + } - @Test(dependsOnMethods = "testAttachPublicIp") - public void testAttachPrivateIp() - { - List> nics = env.virtualMachine.listAttachedNics(); - nics.add(privateIp); + @Test(dependsOnMethods = "testAttachPublicIp") + public void testAttachPrivateIp() { + List> nics = env.virtualMachine.listAttachedNics(); + nics.add(privateIp); - AsyncTask task = env.virtualMachine.setNics(nics); - assertNull(task); + AsyncTask task = env.virtualMachine.setNics(nics); + assertNull(task); - nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 2); - assertEquals(nics.get(0).getId(), publicIpCloud.getId()); - assertEquals(nics.get(1).getId(), privateIp.getId()); - } + nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 2); + assertEquals(nics.get(0).getId(), publicIpCloud.getId()); + assertEquals(nics.get(1).getId(), privateIp.getId()); + } - @Test(dependsOnMethods = "testAttachPrivateIp") - public void testAttachExternalIp() - { - List> nics = env.virtualMachine.listAttachedNics(); - nics.add(externalIp); + @Test(dependsOnMethods = "testAttachPrivateIp") + public void testAttachExternalIp() { + List> nics = env.virtualMachine.listAttachedNics(); + nics.add(externalIp); - AsyncTask task = env.virtualMachine.setNics(nics); - assertNull(task); + AsyncTask task = env.virtualMachine.setNics(nics); + assertNull(task); - nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 3); - assertEquals(nics.get(0).getId(), publicIpCloud.getId()); - assertEquals(nics.get(1).getId(), privateIp.getId()); - assertEquals(nics.get(2).getId(), externalIp.getId()); - } + nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 3); + assertEquals(nics.get(0).getId(), publicIpCloud.getId()); + assertEquals(nics.get(1).getId(), privateIp.getId()); + assertEquals(nics.get(2).getId(), externalIp.getId()); + } - @Test(dependsOnMethods = "testAttachExternalIp") - public void testAddUnmanagedNics() - { - List> nics = env.virtualMachine.listAttachedNics(); + @Test(dependsOnMethods = "testAttachExternalIp") + public void testAddUnmanagedNics() { + List> nics = env.virtualMachine.listAttachedNics(); - AsyncTask task = - env.virtualMachine.setNics(nics, - Lists. newArrayList(env.unmanagedNetwork, env.unmanagedNetwork)); - assertNull(task); + AsyncTask task = env.virtualMachine.setNics(nics, + Lists. newArrayList(env.unmanagedNetwork, env.unmanagedNetwork)); + assertNull(task); - nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 5); - assertEquals(nics.get(0).getId(), publicIpCloud.getId()); - assertEquals(nics.get(1).getId(), privateIp.getId()); - assertEquals(nics.get(2).getId(), externalIp.getId()); - // Unmanaged ips are created during the attach. - assertEquals(nics.get(3).getNetworkName(), env.unmanagedNetwork.getName()); - assertEquals(nics.get(4).getNetworkName(), env.unmanagedNetwork.getName()); + nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 5); + assertEquals(nics.get(0).getId(), publicIpCloud.getId()); + assertEquals(nics.get(1).getId(), privateIp.getId()); + assertEquals(nics.get(2).getId(), externalIp.getId()); + // Unmanaged ips are created during the attach. + assertEquals(nics.get(3).getNetworkName(), env.unmanagedNetwork.getName()); + assertEquals(nics.get(4).getNetworkName(), env.unmanagedNetwork.getName()); - unmanagedIp1 = (UnmanagedIp) nics.get(3); - unmanagedIp2 = (UnmanagedIp) nics.get(4); - } + unmanagedIp1 = (UnmanagedIp) nics.get(3); + unmanagedIp2 = (UnmanagedIp) nics.get(4); + } - @Test(dependsOnMethods = "testAddUnmanagedNics") - public void testReorderNics() - { - List> nics = env.virtualMachine.listAttachedNics(); + @Test(dependsOnMethods = "testAddUnmanagedNics") + public void testReorderNics() { + List> nics = env.virtualMachine.listAttachedNics(); - AsyncTask task = - env.virtualMachine.setNics(Lists.> newArrayList(nics.get(2), nics.get(1), - nics.get(0), nics.get(4), nics.get(3))); - assertNull(task); + AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(nics.get(2), nics.get(1), nics.get(0), + nics.get(4), nics.get(3))); + assertNull(task); - nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 5); - assertEquals(nics.get(0).getId(), externalIp.getId()); - assertEquals(nics.get(1).getId(), privateIp.getId()); - assertEquals(nics.get(2).getId(), publicIpCloud.getId()); - assertEquals(nics.get(3).getId(), unmanagedIp2.getId()); - assertEquals(nics.get(4).getId(), unmanagedIp1.getId()); - } + nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 5); + assertEquals(nics.get(0).getId(), externalIp.getId()); + assertEquals(nics.get(1).getId(), privateIp.getId()); + assertEquals(nics.get(2).getId(), publicIpCloud.getId()); + assertEquals(nics.get(3).getId(), unmanagedIp2.getId()); + assertEquals(nics.get(4).getId(), unmanagedIp1.getId()); + } - @Test(dependsOnMethods = "testReorderNics") - public void testDetachNics() - { - List> nics = env.virtualMachine.listAttachedNics(); + @Test(dependsOnMethods = "testReorderNics") + public void testDetachNics() { + List> nics = env.virtualMachine.listAttachedNics(); - AsyncTask task = - env.virtualMachine.setNics(Lists.> newArrayList(nics.get(1), nics.get(2))); - assertNull(task); + AsyncTask task = env.virtualMachine.setNics(Lists.> newArrayList(nics.get(1), nics.get(2))); + assertNull(task); - nics = env.virtualMachine.listAttachedNics(); - assertEquals(nics.size(), 2); - assertEquals(nics.get(0).getId(), privateIp.getId()); - assertEquals(nics.get(1).getId(), publicIpCloud.getId()); - } + nics = env.virtualMachine.listAttachedNics(); + assertEquals(nics.size(), 2); + assertEquals(nics.get(0).getId(), privateIp.getId()); + assertEquals(nics.get(1).getId(), publicIpCloud.getId()); + } - @Test(dependsOnMethods = "testDetachNics") - public void testSetDefaultGateway() - { - PublicNetwork network = publicIpCloud.getNetwork(); - env.virtualMachine.setGatewayNetwork(network); + @Test(dependsOnMethods = "testDetachNics") + public void testSetDefaultGateway() { + PublicNetwork network = publicIpCloud.getNetwork(); + env.virtualMachine.setGatewayNetwork(network); - Integer configId = env.virtualMachine.unwrap().getIdFromLink("network_configuration"); - assertEquals(configId, network.getId()); - } + Integer configId = env.virtualMachine.unwrap().getIdFromLink("network_configuration"); + assertEquals(configId, network.getId()); + } - // TODO: Review this functionality - @Test(dependsOnMethods = "testSetDefaultGateway", enabled = false) - public void testDetachAllNics() - { - try - { - env.virtualMachine.setNics(null); + // TODO: Review this functionality + @Test(dependsOnMethods = "testSetDefaultGateway", enabled = false) + public void testDetachAllNics() { + try { + env.virtualMachine.setNics(null); - fail("It should not be allowed to remove all nics from a vm"); - } - catch (AbiquoException ex) - { - // At least one nic must be configured - assertHasError(ex, Status.BAD_REQUEST, "VM-46"); - } - } + fail("It should not be allowed to remove all nics from a vm"); + } catch (AbiquoException ex) { + // At least one nic must be configured + assertHasError(ex, Status.BAD_REQUEST, "VM-46"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java index 074f40288d..99f694989f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineStorageLiveApiTest.java @@ -39,121 +39,111 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "VirtualMachineStorageLiveApiTest") -public class VirtualMachineStorageLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private Volume volume; +public class VirtualMachineStorageLiveApiTest extends BaseAbiquoApiLiveApiTest { + private Volume volume; - private HardDisk hardDisk; + private HardDisk hardDisk; - public void testAttachVolumes() - { - volume = createVolume(); + public void testAttachVolumes() { + volume = createVolume(); - // Since the virtual machine is not deployed, this should not generate a task - AsyncTask task = env.virtualMachine.attachVolumes(volume); - assertNull(task); + // Since the virtual machine is not deployed, this should not generate a + // task + AsyncTask task = env.virtualMachine.attachVolumes(volume); + assertNull(task); - List attached = env.virtualMachine.listAttachedVolumes(); - assertEquals(attached.size(), 1); - assertEquals(attached.get(0).getId(), volume.getId()); - } + List attached = env.virtualMachine.listAttachedVolumes(); + assertEquals(attached.size(), 1); + assertEquals(attached.get(0).getId(), volume.getId()); + } - @Test(dependsOnMethods = "testAttachVolumes") - public void detachVolume() - { - env.virtualMachine.detachVolumes(volume); - List attached = env.virtualMachine.listAttachedVolumes(); - assertTrue(attached.isEmpty()); - } + @Test(dependsOnMethods = "testAttachVolumes") + public void detachVolume() { + env.virtualMachine.detachVolumes(volume); + List attached = env.virtualMachine.listAttachedVolumes(); + assertTrue(attached.isEmpty()); + } - @Test(dependsOnMethods = "detachVolume") - public void detachAllVolumes() - { - // Since the virtual machine is not deployed, this should not generate a task - AsyncTask task = env.virtualMachine.attachVolumes(volume); - assertNull(task); + @Test(dependsOnMethods = "detachVolume") + public void detachAllVolumes() { + // Since the virtual machine is not deployed, this should not generate a + // task + AsyncTask task = env.virtualMachine.attachVolumes(volume); + assertNull(task); - env.virtualMachine.detachAllVolumes(); - List attached = env.virtualMachine.listAttachedVolumes(); - assertTrue(attached.isEmpty()); + env.virtualMachine.detachAllVolumes(); + List attached = env.virtualMachine.listAttachedVolumes(); + assertTrue(attached.isEmpty()); - deleteVolume(volume); - } + deleteVolume(volume); + } - public void testAttachHardDisks() - { - hardDisk = createHardDisk(); + public void testAttachHardDisks() { + hardDisk = createHardDisk(); - // Since the virtual machine is not deployed, this should not generate a task - AsyncTask task = env.virtualMachine.attachHardDisks(hardDisk); - assertNull(task); + // Since the virtual machine is not deployed, this should not generate a + // task + AsyncTask task = env.virtualMachine.attachHardDisks(hardDisk); + assertNull(task); - List attached = env.virtualMachine.listAttachedHardDisks(); - assertEquals(attached.size(), 1); - assertEquals(attached.get(0).getId(), hardDisk.getId()); - } + List attached = env.virtualMachine.listAttachedHardDisks(); + assertEquals(attached.size(), 1); + assertEquals(attached.get(0).getId(), hardDisk.getId()); + } - @Test(dependsOnMethods = "testAttachHardDisks") - public void detachHardDisk() - { - env.virtualMachine.detachHardDisks(hardDisk); - List attached = env.virtualMachine.listAttachedHardDisks(); - assertTrue(attached.isEmpty()); - } + @Test(dependsOnMethods = "testAttachHardDisks") + public void detachHardDisk() { + env.virtualMachine.detachHardDisks(hardDisk); + List attached = env.virtualMachine.listAttachedHardDisks(); + assertTrue(attached.isEmpty()); + } - @Test(dependsOnMethods = "detachHardDisk") - public void detachAllHardDisks() - { - // Since the virtual machine is not deployed, this should not generate a task - AsyncTask task = env.virtualMachine.attachHardDisks(hardDisk); - assertNull(task); + @Test(dependsOnMethods = "detachHardDisk") + public void detachAllHardDisks() { + // Since the virtual machine is not deployed, this should not generate a + // task + AsyncTask task = env.virtualMachine.attachHardDisks(hardDisk); + assertNull(task); - env.virtualMachine.detachAllHardDisks(); - List attached = env.virtualMachine.listAttachedHardDisks(); - assertTrue(attached.isEmpty()); + env.virtualMachine.detachAllHardDisks(); + List attached = env.virtualMachine.listAttachedHardDisks(); + assertTrue(attached.isEmpty()); - deleteHardDisk(hardDisk); - } + deleteHardDisk(hardDisk); + } - private Volume createVolume() - { - Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); + private Volume createVolume() { + Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); - Volume volume = - Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) - .name(PREFIX + "Hawaian volume").sizeInMb(32).build(); - volume.save(); + Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) + .name(PREFIX + "Hawaian volume").sizeInMb(32).build(); + volume.save(); - assertNotNull(volume.getId()); - assertNotNull(env.virtualDatacenter.getVolume(volume.getId())); + assertNotNull(volume.getId()); + assertNotNull(env.virtualDatacenter.getVolume(volume.getId())); - return volume; - } + return volume; + } - private void deleteVolume(final Volume volume) - { - Integer id = volume.getId(); - volume.delete(); - assertNull(env.virtualDatacenter.getVolume(id)); - } + private void deleteVolume(final Volume volume) { + Integer id = volume.getId(); + volume.delete(); + assertNull(env.virtualDatacenter.getVolume(id)); + } - private HardDisk createHardDisk() - { - HardDisk hardDisk = - HardDisk.builder(env.context.getApiContext(), env.virtualDatacenter).sizeInMb(64L) - .build(); - hardDisk.save(); + private HardDisk createHardDisk() { + HardDisk hardDisk = HardDisk.builder(env.context.getApiContext(), env.virtualDatacenter).sizeInMb(64L).build(); + hardDisk.save(); - assertNotNull(hardDisk.getId()); - assertNotNull(hardDisk.getSequence()); + assertNotNull(hardDisk.getId()); + assertNotNull(hardDisk.getSequence()); - return hardDisk; - } + return hardDisk; + } - private void deleteHardDisk(final HardDisk hardDisk) - { - Integer id = hardDisk.getId(); - hardDisk.delete(); - assertNull(env.virtualDatacenter.getHardDisk(id)); - } + private void deleteHardDisk(final HardDisk hardDisk) { + Integer id = hardDisk.getId(); + hardDisk.delete(); + assertNull(env.virtualDatacenter.getHardDisk(id)); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateLiveApiTest.java index 7391cf5421..1ed86cbf88 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VirtualMachineTemplateLiveApiTest.java @@ -38,34 +38,26 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "VirtualMachineTemplateLiveApiTest") -public class VirtualMachineTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class VirtualMachineTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testGetParent() - { - Datacenter datacenter = env.virtualMachine.getTemplate().getDatacenter(); - assertNotNull(datacenter); - assertEquals(datacenter.getId(), env.datacenter.getId()); - } + public void testGetParent() { + Datacenter datacenter = env.virtualMachine.getTemplate().getDatacenter(); + assertNotNull(datacenter); + assertEquals(datacenter.getId(), env.datacenter.getId()); + } - public void testGetCategory() - { - Category category = env.virtualMachine.getTemplate().getCategory(); - assertNotNull(category); - } + public void testGetCategory() { + Category category = env.virtualMachine.getTemplate().getCategory(); + assertNotNull(category); + } - public void testRequestConversionToSameFormat() - { - try - { - env.virtualMachine.getTemplate().requestConversion( - env.virtualMachine.getTemplate().getDiskFormatType()); - fail("Should not be able to create create a conversion to the base format"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "CONVERSION-3"); - } - } + public void testRequestConversionToSameFormat() { + try { + env.virtualMachine.getTemplate().requestConversion(env.virtualMachine.getTemplate().getDiskFormatType()); + fail("Should not be able to create create a conversion to the base format"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "CONVERSION-3"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java index 1a85ea0139..ccce353d67 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/cloud/VolumeLiveApiTest.java @@ -44,102 +44,87 @@ import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "VolumeLiveApiTest") -public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testCreateVolume() - { - // We need the vdc-relative tier - Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); +public class VolumeLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testCreateVolume() { + // We need the vdc-relative tier + Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); - Volume volume = - Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) - .name(PREFIX + "Hawaian volume").sizeInMb(32).build(); - volume.save(); + Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) + .name(PREFIX + "Hawaian volume").sizeInMb(32).build(); + volume.save(); - assertNotNull(volume.getId()); - assertNotNull(env.virtualDatacenter.getVolume(volume.getId())); - } + assertNotNull(volume.getId()); + assertNotNull(env.virtualDatacenter.getVolume(volume.getId())); + } - @Test(dependsOnMethods = "testCreateVolume") - public void testFilterVolumes() - { - VolumeOptions validOptions = VolumeOptions.builder().has("hawa").build(); - VolumeOptions invalidOptions = VolumeOptions.builder().has("cacatua").build(); + @Test(dependsOnMethods = "testCreateVolume") + public void testFilterVolumes() { + VolumeOptions validOptions = VolumeOptions.builder().has("hawa").build(); + VolumeOptions invalidOptions = VolumeOptions.builder().has("cacatua").build(); - List volumes = - env.cloudApi.listVolumes(env.virtualDatacenter.unwrap(), validOptions).getCollection(); + List volumes = env.cloudApi.listVolumes(env.virtualDatacenter.unwrap(), validOptions) + .getCollection(); - assertEquals(volumes.size(), 1); + assertEquals(volumes.size(), 1); - volumes = - env.cloudApi.listVolumes(env.virtualDatacenter.unwrap(), invalidOptions) - .getCollection(); + volumes = env.cloudApi.listVolumes(env.virtualDatacenter.unwrap(), invalidOptions).getCollection(); - assertEquals(volumes.size(), 0); - } + assertEquals(volumes.size(), 0); + } - @Test(dependsOnMethods = "testFilterVolumes") - public void testUpdateVolume() - { - Volume volume = - env.virtualDatacenter.findVolume(VolumePredicates.name(PREFIX + "Hawaian volume")); - assertNotNull(volume); + @Test(dependsOnMethods = "testFilterVolumes") + public void testUpdateVolume() { + Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name(PREFIX + "Hawaian volume")); + assertNotNull(volume); - volume.setName("Hawaian volume updated"); - AsyncTask task = volume.update(); - assertNull(task); + volume.setName("Hawaian volume updated"); + AsyncTask task = volume.update(); + assertNull(task); - // Reload the volume to check - Volume updated = env.virtualDatacenter.getVolume(volume.getId()); - assertEquals(updated.getName(), "Hawaian volume updated"); - } + // Reload the volume to check + Volume updated = env.virtualDatacenter.getVolume(volume.getId()); + assertEquals(updated.getName(), "Hawaian volume updated"); + } - @Test(dependsOnMethods = "testUpdateVolume") - public void testMoveVolume() - { - // Create the new virtual datacenter - PrivateNetwork network = - PrivateNetwork.builder(env.context.getApiContext()).name("DefaultNetwork") - .gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); + @Test(dependsOnMethods = "testUpdateVolume") + public void testMoveVolume() { + // Create the new virtual datacenter + PrivateNetwork network = PrivateNetwork.builder(env.context.getApiContext()).name("DefaultNetwork") + .gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); - VirtualDatacenter newVdc = - VirtualDatacenter.builder(env.context.getApiContext(), env.datacenter, env.enterprise) - .name("New VDC").network(network).hypervisorType(env.machine.getType()).build(); - newVdc.save(); - assertNotNull(newVdc.getId()); + VirtualDatacenter newVdc = VirtualDatacenter.builder(env.context.getApiContext(), env.datacenter, env.enterprise) + .name("New VDC").network(network).hypervisorType(env.machine.getType()).build(); + newVdc.save(); + assertNotNull(newVdc.getId()); - Volume volume = - env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated")); - assertNotNull(volume); + Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated")); + assertNotNull(volume); - volume.moveTo(newVdc); + volume.moveTo(newVdc); - // Check that the underlying Dto has been updated to the new VDC - assertTrue(volume.unwrap().getEditLink().getHref() - .startsWith(newVdc.unwrap().getEditLink().getHref())); + // Check that the underlying Dto has been updated to the new VDC + assertTrue(volume.unwrap().getEditLink().getHref().startsWith(newVdc.unwrap().getEditLink().getHref())); - // Move it back to the original VDC - volume.moveTo(env.virtualDatacenter); + // Move it back to the original VDC + volume.moveTo(env.virtualDatacenter); - // Check that the underlying Dto has been updated to the new VDC - assertTrue(volume.unwrap().getEditLink().getHref() + // Check that the underlying Dto has been updated to the new VDC + assertTrue(volume.unwrap().getEditLink().getHref() .startsWith(env.virtualDatacenter.unwrap().getEditLink().getHref())); - // Tear down the virtual datacenter - newVdc.delete(); - } + // Tear down the virtual datacenter + newVdc.delete(); + } - @Test(dependsOnMethods = "testMoveVolume") - public void testDeleteVolume() - { - Volume volume = - env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated")); - assertNotNull(volume); + @Test(dependsOnMethods = "testMoveVolume") + public void testDeleteVolume() { + Volume volume = env.virtualDatacenter.findVolume(VolumePredicates.name("Hawaian volume updated")); + assertNotNull(volume); - Integer id = volume.getId(); - volume.delete(); + Integer id = volume.getId(); + volume.delete(); - assertNull(env.virtualDatacenter.getVolume(id)); - } + assertNull(env.virtualDatacenter.getVolume(id)); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java index 6ce6d7db12..4cb31b829e 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CategoryLiveApiTest.java @@ -33,43 +33,37 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "CategoryLiveApiTest") -public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testCreateAndGet() - { - Category category = - Category.builder(env.context.getApiContext()).name(PREFIX + "-test-category").build(); - category.save(); +public class CategoryLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testCreateAndGet() { + Category category = Category.builder(env.context.getApiContext()).name(PREFIX + "-test-category").build(); + category.save(); - Category apiCategory = - env.context.getAdministrationService().findCategory( - CategoryPredicates.name(PREFIX + "-test-category")); - assertNotNull(apiCategory); - assertEquals(category.getName(), apiCategory.getName()); + Category apiCategory = env.context.getAdministrationService().findCategory( + CategoryPredicates.name(PREFIX + "-test-category")); + assertNotNull(apiCategory); + assertEquals(category.getName(), apiCategory.getName()); - apiCategory.delete(); - } + apiCategory.delete(); + } - @Test(dependsOnMethods = "testCreateAndGet") - public void testUpdate() - { - Iterable categories = env.context.getAdministrationService().listCategories(); - assertNotNull(categories); + @Test(dependsOnMethods = "testCreateAndGet") + public void testUpdate() { + Iterable categories = env.context.getAdministrationService().listCategories(); + assertNotNull(categories); - Category category = categories.iterator().next(); - String name = category.getName(); + Category category = categories.iterator().next(); + String name = category.getName(); - category.setName(PREFIX + "-test-category-updated"); - category.update(); + category.setName(PREFIX + "-test-category-updated"); + category.update(); - Category apiCategory = - env.context.getAdministrationService().findCategory( - CategoryPredicates.name(PREFIX + "-test-category-updated")); + Category apiCategory = env.context.getAdministrationService().findCategory( + CategoryPredicates.name(PREFIX + "-test-category-updated")); - assertNotNull(apiCategory); - assertEquals(PREFIX + "-test-category-updated", apiCategory.getName()); + assertNotNull(apiCategory); + assertEquals(PREFIX + "-test-category-updated", apiCategory.getName()); - category.setName(name); - category.update(); - } + category.setName(name); + category.update(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java index df6220a450..1de82a9386 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CostCodeLiveApiTest.java @@ -44,99 +44,85 @@ import org.testng.annotations.Test; * @author Susana Acedo */ @Test(groups = "api", testName = "CostCodeLiveApiTest") -public class CostCodeLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private CostCode costcode; +public class CostCodeLiveApiTest extends BaseAbiquoApiLiveApiTest { + private CostCode costcode; - private Currency currency; + private Currency currency; - private CostCodePrice costcodeprice; + private CostCodePrice costcodeprice; - private List defaultPrices; + private List defaultPrices; - @BeforeClass - public void setupCostCode() - { - currency = - Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency") - .symbol("test-$").digits(2).build(); - currency.save(); + @BeforeClass + public void setupCostCode() { + currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$") + .digits(2).build(); + currency.save(); - costcode = - CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode") - .description("description").build(); + costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode") + .description("description").build(); - costcode.save(); - } + costcode.save(); + } - @AfterClass - public void tearDownCostCode() - { - currency.delete(); - costcode.delete(); - } + @AfterClass + public void tearDownCostCode() { + currency.delete(); + costcode.delete(); + } - public void testCreateRepeated() - { - CostCode repeated = CostCode.Builder.fromCostCode(costcode).build(); + public void testCreateRepeated() { + CostCode repeated = CostCode.Builder.fromCostCode(costcode).build(); - try - { - repeated.save(); - fail("Should not be able to create costcodes with the same name"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "COSTCODE-2"); - } - } + try { + repeated.save(); + fail("Should not be able to create costcodes with the same name"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "COSTCODE-2"); + } + } - public void testUpdate() - { - costcode.setName(PREFIX + "costcode-updated"); - costcode.update(); + public void testUpdate() { + costcode.setName(PREFIX + "costcode-updated"); + costcode.update(); - CostCode apiCostCode = - env.context.getPricingService().findCostCode( - PricingPredicates.costCode(PREFIX + "costcode-updated")); + CostCode apiCostCode = env.context.getPricingService().findCostCode( + PricingPredicates.costCode(PREFIX + "costcode-updated")); - assertNotNull(apiCostCode); - assertEquals(PREFIX + "costcode-updated", apiCostCode.getName()); + assertNotNull(apiCostCode); + assertEquals(PREFIX + "costcode-updated", apiCostCode.getName()); - } + } - public void testCreateCostCodewithDefaultPrices() - { - CostCode costcode2 = - CostCode.builder(env.context.getApiContext()).name(PREFIX + "ccdefaultprice") - .description("description").build(); + public void testCreateCostCodewithDefaultPrices() { + CostCode costcode2 = CostCode.builder(env.context.getApiContext()).name(PREFIX + "ccdefaultprice") + .description("description").build(); - costcodeprice = new CostCodePrice(currency, new BigDecimal(100)); - this.defaultPrices = new ArrayList(); - defaultPrices.add(costcodeprice); - costcode2.setDefaultPrices(defaultPrices); - // When a cost code is created it is also created a costcodecurrency with price 0 and after - // that if a list of prices(CostCodePrice) has been sent this costcode is updated with the - // new price - costcode2.save(); + costcodeprice = new CostCodePrice(currency, new BigDecimal(100)); + this.defaultPrices = new ArrayList(); + defaultPrices.add(costcodeprice); + costcode2.setDefaultPrices(defaultPrices); + // When a cost code is created it is also created a costcodecurrency with + // price 0 and after + // that if a list of prices(CostCodePrice) has been sent this costcode is + // updated with the + // new price + costcode2.save(); - // check that costcode has been created - CostCode apiCostCode = - env.context.getPricingService().findCostCode( - PricingPredicates.costCode(PREFIX + "ccdefaultprice")); + // check that costcode has been created + CostCode apiCostCode = env.context.getPricingService().findCostCode( + PricingPredicates.costCode(PREFIX + "ccdefaultprice")); - assertNotNull(apiCostCode); - assertEquals(PREFIX + "ccdefaultprice", apiCostCode.getName()); + assertNotNull(apiCostCode); + assertEquals(PREFIX + "ccdefaultprice", apiCostCode.getName()); - // check that the price has been modified in the - Iterable costcodecurrencies = - env.context.getPricingService().getCostCodeCurrencies(costcode2.getId(), - currency.getId()); - for (CostCodeCurrency costcodecurrency : costcodecurrencies) - { - assertEquals(costcodecurrency.getPrice().compareTo(new BigDecimal(100)), 0); - } + // check that the price has been modified in the + Iterable costcodecurrencies = env.context.getPricingService().getCostCodeCurrencies( + costcode2.getId(), currency.getId()); + for (CostCodeCurrency costcodecurrency : costcodecurrencies) { + assertEquals(costcodecurrency.getPrice().compareTo(new BigDecimal(100)), 0); + } - costcode2.delete(); - } + costcode2.delete(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java index c7b6b1f573..c2626b1326 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/CurrencyLiveApiTest.java @@ -33,44 +33,38 @@ import org.testng.annotations.Test; * @author Susana Acedo */ @Test(groups = "api", testName = "CurrencyLiveApiTest") -public class CurrencyLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testCreateAndGet() - { - Currency currency = - Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency") - .symbol("test-$").digits(2).build(); - currency.save(); +public class CurrencyLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testCreateAndGet() { + Currency currency = Currency.builder(env.context.getApiContext()).name(PREFIX + "test-currency").symbol("test-$") + .digits(2).build(); + currency.save(); - Currency apiCurrency = - env.context.getPricingService().findCurrency( - PricingPredicates.currency(PREFIX + "test-currency")); - assertNotNull(apiCurrency); - assertEquals(currency.getName(), apiCurrency.getName()); + Currency apiCurrency = env.context.getPricingService().findCurrency( + PricingPredicates.currency(PREFIX + "test-currency")); + assertNotNull(apiCurrency); + assertEquals(currency.getName(), apiCurrency.getName()); - apiCurrency.delete(); - } + apiCurrency.delete(); + } - @Test(dependsOnMethods = "testCreateAndGet") - public void testUpdate() - { - Iterable currencies = env.context.getPricingService().listCurrencies(); - assertNotNull(currencies); + @Test(dependsOnMethods = "testCreateAndGet") + public void testUpdate() { + Iterable currencies = env.context.getPricingService().listCurrencies(); + assertNotNull(currencies); - Currency currency = currencies.iterator().next(); - String name = currency.getName(); + Currency currency = currencies.iterator().next(); + String name = currency.getName(); - currency.setName(PREFIX + "t-currency-upd"); - currency.update(); + currency.setName(PREFIX + "t-currency-upd"); + currency.update(); - Currency apiCurrency = - env.context.getPricingService().findCurrency( - PricingPredicates.currency(PREFIX + "t-currency-upd")); + Currency apiCurrency = env.context.getPricingService().findCurrency( + PricingPredicates.currency(PREFIX + "t-currency-upd")); - assertNotNull(apiCurrency); - assertEquals(PREFIX + "t-currency-upd", apiCurrency.getName()); + assertNotNull(apiCurrency); + assertEquals(PREFIX + "t-currency-upd", apiCurrency.getName()); - currency.setName(name); - currency.update(); - } + currency.setName(name); + currency.update(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/LicenseLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/LicenseLiveApiTest.java index 769412c28d..e10a123fa5 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/LicenseLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/LicenseLiveApiTest.java @@ -35,21 +35,16 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "LicenseLiveApiTest") -public class LicenseLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class LicenseLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testCreateRepeated() - { - License repeated = License.Builder.fromLicense(env.license).build(); + public void testCreateRepeated() { + License repeated = License.Builder.fromLicense(env.license).build(); - try - { - repeated.add(); - fail("Should not be able to create licenses with the same code"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "LICENSE-5"); - } - } + try { + repeated.add(); + fail("Should not be able to create licenses with the same code"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "LICENSE-5"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java index 026f5153fd..470f1d36b3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/PricingTemplateLiveApiTest.java @@ -46,101 +46,86 @@ import com.abiquo.model.enumerator.PricingPeriod; * @author Susana Acedo */ @Test(groups = "api", testName = "PricingTemplateLiveApiTest") -public class PricingTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private PricingTemplate pricingTemplate; +public class PricingTemplateLiveApiTest extends BaseAbiquoApiLiveApiTest { + private PricingTemplate pricingTemplate; - private Currency currency; + private Currency currency; - private CostCode costcode; + private CostCode costcode; - private BigDecimal zero = new BigDecimal(0); + private BigDecimal zero = new BigDecimal(0); - @BeforeClass - public void setupPricingTemplate() - { - Iterable currencies = env.context.getPricingService().listCurrencies(); - currency = currencies.iterator().next(); + @BeforeClass + public void setupPricingTemplate() { + Iterable currencies = env.context.getPricingService().listCurrencies(); + currency = currencies.iterator().next(); - costcode = - CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode") - .description("description").build(); + costcode = CostCode.builder(env.context.getApiContext()).name(PREFIX + "test-costcode") + .description("description").build(); - costcode.save(); + costcode.save(); - pricingTemplate = - PricingTemplate.builder(env.context.getApiContext(), currency).name("pricing_template") - .description("description").hdGB(zero).standingChargePeriod(zero).vlan(zero) - .chargingPeriod(PricingPeriod.MONTH).minimumChargePeriod(zero) - .showChangesBefore(true).showMinimumCharge(false).minimumCharge(PricingPeriod.WEEK) - .publicIp(zero).vcpu(zero).memoryGB(zero).defaultTemplate(true) - .lastUpdate(new Date()).build(); + pricingTemplate = PricingTemplate.builder(env.context.getApiContext(), currency).name("pricing_template") + .description("description").hdGB(zero).standingChargePeriod(zero).vlan(zero) + .chargingPeriod(PricingPeriod.MONTH).minimumChargePeriod(zero).showChangesBefore(true) + .showMinimumCharge(false).minimumCharge(PricingPeriod.WEEK).publicIp(zero).vcpu(zero).memoryGB(zero) + .defaultTemplate(true).lastUpdate(new Date()).build(); - pricingTemplate.save(); - } + pricingTemplate.save(); + } - @AfterClass - public void tearDownPricingTemplate() - { - pricingTemplate.delete(); - costcode.delete(); - } + @AfterClass + public void tearDownPricingTemplate() { + pricingTemplate.delete(); + costcode.delete(); + } - public void testCreateRepeated() - { - PricingTemplate repeated = - PricingTemplate.Builder.fromPricingTemplate(pricingTemplate).build(); + public void testCreateRepeated() { + PricingTemplate repeated = PricingTemplate.Builder.fromPricingTemplate(pricingTemplate).build(); - try - { - repeated.save(); - fail("Should not be able to create pricingtemplates with the same name"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "PRICINGTEMPLATE-2"); - } - } + try { + repeated.save(); + fail("Should not be able to create pricingtemplates with the same name"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "PRICINGTEMPLATE-2"); + } + } - public void testUpdate() - { - pricingTemplate.setName(PREFIX + "pt-updated"); - pricingTemplate.update(); + public void testUpdate() { + pricingTemplate.setName(PREFIX + "pt-updated"); + pricingTemplate.update(); - PricingTemplate apiPricingTemplate = - env.context.getPricingService().findPricingTemplate( - PricingPredicates.pricingTemplate(PREFIX + "pt-updated")); + PricingTemplate apiPricingTemplate = env.context.getPricingService().findPricingTemplate( + PricingPredicates.pricingTemplate(PREFIX + "pt-updated")); - assertNotNull(apiPricingTemplate); - assertEquals(PREFIX + "pt-updated", apiPricingTemplate.getName()); + assertNotNull(apiPricingTemplate); + assertEquals(PREFIX + "pt-updated", apiPricingTemplate.getName()); - } + } - // when a pricing template is created, pricing cost codes for each existent cost code are also - // created with price 0 - public void getPricingCostCodes() - { - Collection pricingCostCodes = - env.context.getPricingService().getPricingCostCodes(pricingTemplate.getId()); - assertEquals(pricingCostCodes.size(), 1); - assertNotNull(pricingCostCodes); - for (PricingCostCode pc : pricingCostCodes) - { - assertEquals(pc.getPrice().compareTo(zero), 0); - } - } + // when a pricing template is created, pricing cost codes for each existent + // cost code are also + // created with price 0 + public void getPricingCostCodes() { + Collection pricingCostCodes = env.context.getPricingService().getPricingCostCodes( + pricingTemplate.getId()); + assertEquals(pricingCostCodes.size(), 1); + assertNotNull(pricingCostCodes); + for (PricingCostCode pc : pricingCostCodes) { + assertEquals(pc.getPrice().compareTo(zero), 0); + } + } - // when a pricing template is created, pricing tiers are also created with price 0 - public void getPricingTiers() - { - Collection pricingTiers = + // when a pricing template is created, pricing tiers are also created with + // price 0 + public void getPricingTiers() { + Collection pricingTiers = - env.context.getPricingService().getPricingTiers(pricingTemplate.getId()); - assertEquals(pricingTiers.size(), 4); - assertNotNull(pricingTiers); - for (PricingTier pt : pricingTiers) - { - assertEquals(pt.getPrice().compareTo(zero), 0); - } - } + env.context.getPricingService().getPricingTiers(pricingTemplate.getId()); + assertEquals(pricingTiers.size(), 4); + assertNotNull(pricingTiers); + for (PricingTier pt : pricingTiers) { + assertEquals(pt.getPrice().compareTo(zero), 0); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/SystemPropertiesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/SystemPropertiesLiveApiTest.java index 96526653f5..6546d6730f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/SystemPropertiesLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/config/SystemPropertiesLiveApiTest.java @@ -31,24 +31,20 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "SystemPropertiesLiveApiTest") -public class SystemPropertiesLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testUpdate() - { - SystemProperty prop = - env.administrationService.getSystemProperty("client.dashboard.showStartUpAlert"); +public class SystemPropertiesLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testUpdate() { + SystemProperty prop = env.administrationService.getSystemProperty("client.dashboard.showStartUpAlert"); - String value = prop.getValue(); - prop.setValue("0"); - prop.update(); + String value = prop.getValue(); + prop.setValue("0"); + prop.update(); - // Recover the updated datacenter - SystemProperty updated = - env.administrationService.getSystemProperty("client.dashboard.showStartUpAlert"); + // Recover the updated datacenter + SystemProperty updated = env.administrationService.getSystemProperty("client.dashboard.showStartUpAlert"); - assertEquals(updated.getValue(), "0"); + assertEquals(updated.getValue(), "0"); - prop.setValue(value); - prop.update(); - } + prop.setValue(value); + prop.update(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterpriseLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterpriseLiveApiTest.java index 972c98ef8c..fdaa4d5cc4 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterpriseLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterpriseLiveApiTest.java @@ -50,141 +50,119 @@ import com.abiquo.server.core.enterprise.EnterpriseDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "EnterpriseLiveApiTest") -public class EnterpriseLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private Enterprise enterprise; +public class EnterpriseLiveApiTest extends BaseAbiquoApiLiveApiTest { + private Enterprise enterprise; - private Limits limits; + private Limits limits; - @BeforeClass - public void setupEnterprise() - { - enterprise = Enterprise.Builder.fromEnterprise(env.enterprise).build(); - enterprise.setName(PREFIX + "-enterprise-test"); - enterprise.save(); + @BeforeClass + public void setupEnterprise() { + enterprise = Enterprise.Builder.fromEnterprise(env.enterprise).build(); + enterprise.setName(PREFIX + "-enterprise-test"); + enterprise.save(); - limits = enterprise.allowDatacenter(env.datacenter); - assertNotNull(limits); + limits = enterprise.allowDatacenter(env.datacenter); + assertNotNull(limits); - DatacentersLimitsDto limitsDto = - env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); - assertNotNull(limitsDto); - assertEquals(limitsDto.getCollection().size(), 1); - } + DatacentersLimitsDto limitsDto = env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); + assertNotNull(limitsDto); + assertEquals(limitsDto.getCollection().size(), 1); + } - @AfterClass - public void tearDownEnterprise() - { - enterprise.prohibitDatacenter(env.datacenter); + @AfterClass + public void tearDownEnterprise() { + enterprise.prohibitDatacenter(env.datacenter); - try - { - // If a datacenter is not allowed, the limits for it can not be retrieved - env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "ENTERPRISE-10"); - } + try { + // If a datacenter is not allowed, the limits for it can not be + // retrieved + env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "ENTERPRISE-10"); + } - List allowed = enterprise.listAllowedDatacenters(); - assertNotNull(allowed); - assertTrue(allowed.isEmpty()); + List allowed = enterprise.listAllowedDatacenters(); + assertNotNull(allowed); + assertTrue(allowed.isEmpty()); - enterprise.delete(); - } + enterprise.delete(); + } - public void testUpdate() - { - enterprise.setName("Updated Enterprise"); - enterprise.update(); + public void testUpdate() { + enterprise.setName("Updated Enterprise"); + enterprise.update(); - // Recover the updated enterprise - EnterpriseDto updated = env.enterpriseApi.getEnterprise(enterprise.getId()); + // Recover the updated enterprise + EnterpriseDto updated = env.enterpriseApi.getEnterprise(enterprise.getId()); - assertEquals(updated.getName(), "Updated Enterprise"); - } + assertEquals(updated.getName(), "Updated Enterprise"); + } - public void testCreateRepeated() - { - Enterprise repeated = Builder.fromEnterprise(enterprise).build(); + public void testCreateRepeated() { + Enterprise repeated = Builder.fromEnterprise(enterprise).build(); - try - { - repeated.save(); - fail("Should not be able to create enterprises with the same name"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "ENTERPRISE-4"); - } - } + try { + repeated.save(); + fail("Should not be able to create enterprises with the same name"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "ENTERPRISE-4"); + } + } - public void testAllowTwiceWorks() - { - // Allow the datacenter again and check that the configuration has not changed - Limits limits = enterprise.allowDatacenter(env.datacenter); - assertNotNull(limits); + public void testAllowTwiceWorks() { + // Allow the datacenter again and check that the configuration has not + // changed + Limits limits = enterprise.allowDatacenter(env.datacenter); + assertNotNull(limits); - DatacentersLimitsDto limitsDto = - env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); - assertNotNull(limitsDto); - assertEquals(limitsDto.getCollection().size(), 1); - } + DatacentersLimitsDto limitsDto = env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); + assertNotNull(limitsDto); + assertEquals(limitsDto.getCollection().size(), 1); + } - public void testListLimits() - { - List allLimits = enterprise.listLimits(); - assertNotNull(allLimits); - assertEquals(allLimits.size(), 1); - } + public void testListLimits() { + List allLimits = enterprise.listLimits(); + assertNotNull(allLimits); + assertEquals(allLimits.size(), 1); + } - public void testUpdateInvalidLimits() - { - // CPU soft remains to 0 => conflict because hard is smaller - limits.setCpuCountHardLimit(2); + public void testUpdateInvalidLimits() { + // CPU soft remains to 0 => conflict because hard is smaller + limits.setCpuCountHardLimit(2); - try - { - limits.update(); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-LIMITRANGE"); - } - } + try { + limits.update(); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "CONSTR-LIMITRANGE"); + } + } - public void testUpdateLimits() - { - limits.setCpuCountLimits(4, 5); - limits.update(); + public void testUpdateLimits() { + limits.setCpuCountLimits(4, 5); + limits.update(); - DatacentersLimitsDto limitsDto = - env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); - assertNotNull(limitsDto); - assertEquals(limitsDto.getCollection().size(), 1); - assertEquals(limitsDto.getCollection().get(0).getCpuCountHardLimit(), 5); - assertEquals(limitsDto.getCollection().get(0).getCpuCountSoftLimit(), 4); - } + DatacentersLimitsDto limitsDto = env.enterpriseApi.getLimits(enterprise.unwrap(), env.datacenter.unwrap()); + assertNotNull(limitsDto); + assertEquals(limitsDto.getCollection().size(), 1); + assertEquals(limitsDto.getCollection().get(0).getCpuCountHardLimit(), 5); + assertEquals(limitsDto.getCollection().get(0).getCpuCountSoftLimit(), 4); + } - public void testListAllowedDatacenters() - { - List allowed = enterprise.listAllowedDatacenters(); + public void testListAllowedDatacenters() { + List allowed = enterprise.listAllowedDatacenters(); - assertNotNull(allowed); - assertFalse(allowed.isEmpty()); - assertEquals(allowed.get(0).getId(), env.datacenter.getId()); - } + assertNotNull(allowed); + assertFalse(allowed.isEmpty()); + assertEquals(allowed.get(0).getId(), env.datacenter.getId()); + } - public void testListVirtualMachines() - { - List machines = env.defaultEnterprise.listVirtualMachines(); - assertTrue(machines.size() > 0); - } + public void testListVirtualMachines() { + List machines = env.defaultEnterprise.listVirtualMachines(); + assertTrue(machines.size() > 0); + } - public void testListVirtualAppliances() - { - List vapps = env.defaultEnterprise.listVirtualAppliances(); - assertTrue(vapps.size() > 0); - } + public void testListVirtualAppliances() { + List vapps = env.defaultEnterprise.listVirtualAppliances(); + assertTrue(vapps.size() > 0); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterprisePropertiesLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterprisePropertiesLiveApiTest.java index 8b6d4d7403..9e3b4c45ed 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterprisePropertiesLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/EnterprisePropertiesLiveApiTest.java @@ -33,24 +33,20 @@ import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "EnterprisePropertiesLiveApiTest") -public class EnterprisePropertiesLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class EnterprisePropertiesLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - EnterpriseProperties properties = - env.administrationService.getEnterpriseProperties(env.enterprise); + public void testUpdate() { + EnterpriseProperties properties = env.administrationService.getEnterpriseProperties(env.enterprise); - Integer size = properties.getProperties().size(); - properties.getProperties().put("Prop", "Value"); - properties.update(); + Integer size = properties.getProperties().size(); + properties.getProperties().put("Prop", "Value"); + properties.update(); - // Recover the updated properties - EnterprisePropertiesDto updated = - env.enterpriseApi.getEnterpriseProperties(env.enterprise.unwrap()); + // Recover the updated properties + EnterprisePropertiesDto updated = env.enterpriseApi.getEnterpriseProperties(env.enterprise.unwrap()); - assertEquals(updated.getProperties().size(), size + 1); - assertTrue(updated.getProperties().containsKey("Prop")); - assertTrue(updated.getProperties().containsValue("Value")); - } + assertEquals(updated.getProperties().size(), size + 1); + assertTrue(updated.getProperties().containsKey("Prop")); + assertTrue(updated.getProperties().containsValue("Value")); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java index 4b16195d02..7be86b98a2 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionListLiveApiTest.java @@ -37,45 +37,38 @@ import org.testng.annotations.Test; * @author Francesc Montserrat */ @Test(groups = "api", testName = "TemplateDefinitionListLiveApiTest") -public class TemplateDefinitionListLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private TemplateDefinitionList list; +public class TemplateDefinitionListLiveApiTest extends BaseAbiquoApiLiveApiTest { + private TemplateDefinitionList list; - public void testUpdate() - { - list.setName(list.getName() + "Updated"); - list.update(); + public void testUpdate() { + list.setName(list.getName() + "Updated"); + list.update(); - List lists = - env.enterprise.listTemplateDefinitionLists(TemplateDefinitionListPredicates - .name("myListUpdated")); + List lists = env.enterprise.listTemplateDefinitionLists(TemplateDefinitionListPredicates + .name("myListUpdated")); - assertEquals(lists.size(), 1); - } + assertEquals(lists.size(), 1); + } - public void testListStates() - { - List states = list.listStatus(env.datacenter); - assertNotNull(states); - } + public void testListStates() { + List states = list.listStatus(env.datacenter); + assertNotNull(states); + } - @BeforeClass - public void setup() - { - list = - TemplateDefinitionList.builder(env.context.getApiContext(), env.enterprise) - .name("myList").url("http://virtualapp-repository.com/vapp1.ovf").build(); + @BeforeClass + public void setup() { + list = TemplateDefinitionList.builder(env.context.getApiContext(), env.enterprise).name("myList") + .url("http://virtualapp-repository.com/vapp1.ovf").build(); - list.save(); + list.save(); - assertNotNull(list.getId()); - } + assertNotNull(list.getId()); + } - @AfterClass - public void tearDown() - { - Integer idTemplateList = list.getId(); - list.delete(); - assertNull(env.enterprise.getTemplateDefinitionList(idTemplateList)); - } + @AfterClass + public void tearDown() { + Integer idTemplateList = list.getId(); + list.delete(); + assertNull(env.enterprise.getTemplateDefinitionList(idTemplateList)); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java index 57b524a513..88b096010d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/enterprise/UserLiveApiTest.java @@ -41,69 +41,60 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Test(groups = "api", testName = "UserLiveApiTest") -public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class UserLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - String username = env.user.getName(); - env.user.setName("Manolo"); - env.user.update(); + public void testUpdate() { + String username = env.user.getName(); + env.user.setName("Manolo"); + env.user.update(); - // Recover the updated user - UserDto updated = env.enterpriseApi.getUser(env.enterprise.unwrap(), env.user.getId()); + // Recover the updated user + UserDto updated = env.enterpriseApi.getUser(env.enterprise.unwrap(), env.user.getId()); - assertEquals(updated.getName(), "Manolo"); + assertEquals(updated.getName(), "Manolo"); - env.user.setName(username); - env.user.update(); - } + env.user.setName(username); + env.user.update(); + } - public void testCreateRepeated() - { - User repeated = User.Builder.fromUser(env.user).build(); + public void testCreateRepeated() { + User repeated = User.Builder.fromUser(env.user).build(); - try - { - repeated.save(); - fail("Should not be able to create users with the same nick"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "USER-4"); - } - } + try { + repeated.save(); + fail("Should not be able to create users with the same nick"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "USER-4"); + } + } - public void testChangeRoleAndUpdate() - { - env.user.setRole(env.anotherRole); - env.user.update(); + public void testChangeRoleAndUpdate() { + env.user.setRole(env.anotherRole); + env.user.update(); - Role role2 = env.enterprise.findUser(UserPredicates.nick(env.user.getNick())).getRole(); + Role role2 = env.enterprise.findUser(UserPredicates.nick(env.user.getNick())).getRole(); - assertEquals(env.anotherRole.getId(), role2.getId()); - assertEquals(role2.getName(), "Another role"); + assertEquals(env.anotherRole.getId(), role2.getId()); + assertEquals(role2.getName(), "Another role"); - env.user.setRole(env.role); - env.user.update(); - } + env.user.setRole(env.role); + env.user.update(); + } - public void testListUser() - { - Iterable users = env.enterprise.listUsers(); - assertEquals(Iterables.size(users), 2); + public void testListUser() { + Iterable users = env.enterprise.listUsers(); + assertEquals(Iterables.size(users), 2); - users = env.enterprise.listUsers(nick(env.user.getNick())); - assertEquals(Iterables.size(users), 1); + users = env.enterprise.listUsers(nick(env.user.getNick())); + assertEquals(Iterables.size(users), 1); - users = env.enterprise.listUsers(nick(env.user.getName() + "FAIL")); - assertEquals(Iterables.size(users), 0); - } + users = env.enterprise.listUsers(nick(env.user.getName() + "FAIL")); + assertEquals(Iterables.size(users), 0); + } - public void testGetCurrentUser() - { - User user = env.context.getAdministrationService().getCurrentUser(); - assertNotNull(user); - assertEquals(user.getNick(), env.context.getApiContext().getIdentity()); - } + public void testGetCurrentUser() { + User user = env.context.getAdministrationService().getCurrentUser(); + assertNotNull(user); + assertEquals(user.getNick(), env.context.getApiContext().getIdentity()); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java index a82bc2b2f8..91c22b0afc 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/event/EventLiveApiTest.java @@ -46,238 +46,199 @@ import com.google.common.collect.Iterables; * @author Vivien Mahé */ @Test(groups = "api", testName = "EventLiveApiTest") -public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testListEventsFilteredByDatacenter() - { - String name = randomName(); - env.datacenter.setName(name); - env.datacenter.update(); +public class EventLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testListEventsFilteredByDatacenter() { + String name = randomName(); + env.datacenter.setName(name); + env.datacenter.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).datacenterName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).datacenterName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByRack() - { - String name = randomName(); - env.rack.setName(name); - env.rack.update(); + public void testListEventsFilteredByRack() { + String name = randomName(); + env.rack.setName(name); + env.rack.update(); - EventOptions options = EventOptions.builder().dateFrom(new Date()).rackName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).rackName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByPM() - { - String name = randomName(); - env.machine.setName(name); - env.machine.update(); + public void testListEventsFilteredByPM() { + String name = randomName(); + env.machine.setName(name); + env.machine.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).physicalMachineName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).physicalMachineName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByStorageDevice() - { - String name = randomName(); - env.storageDevice.setName(name); - env.storageDevice.update(); + public void testListEventsFilteredByStorageDevice() { + String name = randomName(); + env.storageDevice.setName(name); + env.storageDevice.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).storageSystemName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).storageSystemName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByStoragePool() - { - Tier tier = env.datacenter.findTier(TierPredicates.name("Default Tier 2")); - assertNotNull(tier); + public void testListEventsFilteredByStoragePool() { + Tier tier = env.datacenter.findTier(TierPredicates.name("Default Tier 2")); + assertNotNull(tier); - try - { - env.storagePool.setTier(tier); - env.storagePool.update(); + try { + env.storagePool.setTier(tier); + env.storagePool.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()) - .storagePoolName(env.storagePool.getName()).build(); - assertEvents(options); - } - finally - { - // Restore the original tier - env.storagePool.setTier(env.tier); - env.storagePool.update(); - } - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).storagePoolName(env.storagePool.getName()) + .build(); + assertEvents(options); + } finally { + // Restore the original tier + env.storagePool.setTier(env.tier); + env.storagePool.update(); + } + } - public void testListEventsFilteredByEnterprise() - { - String entName = env.enterprise.getName(); - String name = randomName(); - env.enterprise.setName(name); - env.enterprise.update(); + public void testListEventsFilteredByEnterprise() { + String entName = env.enterprise.getName(); + String name = randomName(); + env.enterprise.setName(name); + env.enterprise.update(); - // Enterprise current = - // env.enterpriseAdminContext.getAdministrationService().getCurrentEnterprise(); - // current.setName("Enterprise updated"); - // current.update(); + // Enterprise current = + // env.enterpriseAdminContext.getAdministrationService().getCurrentEnterprise(); + // current.setName("Enterprise updated"); + // current.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).enterpriseName(name).build(); - assertEvents(options); + EventOptions options = EventOptions.builder().dateFrom(new Date()).enterpriseName(name).build(); + assertEvents(options); - env.enterprise.setName(entName); - env.enterprise.update(); - } + env.enterprise.setName(entName); + env.enterprise.update(); + } - /** - * TODO: Using the painUserContext, modifying the user returns this error: HTTP/1.1 401 - * Unauthorized - **/ - @Test(enabled = false) - public void testListEventsFilteredByUser() - { - User current = env.plainUserContext.getAdministrationService().getCurrentUser(); - current.setEmail("test@test.com"); - current.update(); + /** + * TODO: Using the painUserContext, modifying the user returns this error: + * HTTP/1.1 401 Unauthorized + **/ + @Test(enabled = false) + public void testListEventsFilteredByUser() { + User current = env.plainUserContext.getAdministrationService().getCurrentUser(); + current.setEmail("test@test.com"); + current.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).userName(current.getName()).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).userName(current.getName()).build(); + assertEvents(options); + } - public void testListEventsFilteredByVDC() - { - String name = randomName(); - env.virtualDatacenter.setName(name); - env.virtualDatacenter.update(); + public void testListEventsFilteredByVDC() { + String name = randomName(); + env.virtualDatacenter.setName(name); + env.virtualDatacenter.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualDatacenterName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualDatacenterName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByVapp() - { - String name = randomName(); - env.virtualAppliance.setName(name); - env.virtualAppliance.update(); + public void testListEventsFilteredByVapp() { + String name = randomName(); + env.virtualAppliance.setName(name); + env.virtualAppliance.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualAppName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredByVM() - { - VirtualMachine vm = createVirtualMachine(); - vm.delete(); + public void testListEventsFilteredByVM() { + VirtualMachine vm = createVirtualMachine(); + vm.delete(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).actionPerformed(EventType.VM_DELETE) - .build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).actionPerformed(EventType.VM_DELETE).build(); + assertEvents(options); + } - public void testListEventsFilteredByVolume() - { - String name = randomName(); - Volume volume = createVolume(); - volume.setName(name); - volume.update(); - volume.delete(); // We don't need it any more. events already exist + public void testListEventsFilteredByVolume() { + String name = randomName(); + Volume volume = createVolume(); + volume.setName(name); + volume.update(); + volume.delete(); // We don't need it any more. events already exist - EventOptions options = EventOptions.builder().dateFrom(new Date()).volumeName(name).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).volumeName(name).build(); + assertEvents(options); + } - public void testListEventsFilteredBySeverity() - { - String name = randomName(); - env.virtualAppliance.setName(name); - env.virtualAppliance.update(); + public void testListEventsFilteredBySeverity() { + String name = randomName(); + env.virtualAppliance.setName(name); + env.virtualAppliance.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualAppName(name) - .severity(SeverityType.INFO).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name) + .severity(SeverityType.INFO).build(); + assertEvents(options); + } - public void testListEventsFilteredByActionPerformed() - { - String name = randomName(); - env.virtualAppliance.setName(name); - env.virtualAppliance.update(); + public void testListEventsFilteredByActionPerformed() { + String name = randomName(); + env.virtualAppliance.setName(name); + env.virtualAppliance.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualAppName(name) - .actionPerformed(EventType.VAPP_MODIFY).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name) + .actionPerformed(EventType.VAPP_MODIFY).build(); + assertEvents(options); + } - public void testListEventsFilteredByComponent() - { - String name = randomName(); - env.virtualAppliance.setName(name); - env.virtualAppliance.update(); + public void testListEventsFilteredByComponent() { + String name = randomName(); + env.virtualAppliance.setName(name); + env.virtualAppliance.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualAppName(name) - .component(ComponentType.VIRTUAL_APPLIANCE).build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name) + .component(ComponentType.VIRTUAL_APPLIANCE).build(); + assertEvents(options); + } - public void testListEventsFilteredByDescription() - { - String name = randomName(); - env.virtualAppliance.setName(name); - env.virtualAppliance.update(); + public void testListEventsFilteredByDescription() { + String name = randomName(); + env.virtualAppliance.setName(name); + env.virtualAppliance.update(); - EventOptions options = - EventOptions.builder().dateFrom(new Date()).virtualAppName(name) - .description("Virtual appliance '" + name + "' has been modified.").build(); - assertEvents(options); - } + EventOptions options = EventOptions.builder().dateFrom(new Date()).virtualAppName(name) + .description("Virtual appliance '" + name + "' has been modified.").build(); + assertEvents(options); + } - // Helpers + // Helpers - private void assertEvents(final EventOptions options) - { - Iterable events = env.eventService.listEvents(options); - assertTrue(Iterables.size(events) >= 1); - } + private void assertEvents(final EventOptions options) { + Iterable events = env.eventService.listEvents(options); + assertTrue(Iterables.size(events) >= 1); + } - private Volume createVolume() - { - Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); - Volume volume = - Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) - .name(PREFIX + "Event vol").sizeInMb(32).build(); + private Volume createVolume() { + Tier tier = env.virtualDatacenter.findStorageTier(TierPredicates.name(env.tier.getName())); + Volume volume = Volume.builder(env.context.getApiContext(), env.virtualDatacenter, tier) + .name(PREFIX + "Event vol").sizeInMb(32).build(); - volume.save(); - assertNotNull(volume.getId()); + volume.save(); + assertNotNull(volume.getId()); - return volume; - } + return volume; + } - private VirtualMachine createVirtualMachine() - { - VirtualMachine virtualMachine = - VirtualMachine.builder(env.context.getApiContext(), env.virtualAppliance, env.template) - .cpu(2).ram(128).build(); + private VirtualMachine createVirtualMachine() { + VirtualMachine virtualMachine = VirtualMachine + .builder(env.context.getApiContext(), env.virtualAppliance, env.template).cpu(2).ram(128).build(); - virtualMachine.save(); - assertNotNull(virtualMachine.getId()); + virtualMachine.save(); + assertNotNull(virtualMachine.getId()); - return virtualMachine; - } + return virtualMachine; + } - private static String randomName() - { - return PREFIX + UUID.randomUUID().toString().substring(0, 12); - } + private static String randomName() { + return PREFIX + UUID.randomUUID().toString().substring(0, 12); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java index 18aa3e98ba..77d2a828f1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/BladeLiveUcsTest.java @@ -35,57 +35,49 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Test(groups = "ucs", testName = "BladeLiveUcsTest") -public class BladeLiveUcsTest extends BaseAbiquoApiLiveApiTest -{ - Blade blade; +public class BladeLiveUcsTest extends BaseAbiquoApiLiveApiTest { + Blade blade; - public void testFindAvailableVirtualSwitch() - { - String vswitch = blade.getAvailableVirtualSwitches().get(0); - String found = blade.findAvailableVirtualSwitch(vswitch); - assertEquals(found, vswitch); - } + public void testFindAvailableVirtualSwitch() { + String vswitch = blade.getAvailableVirtualSwitches().get(0); + String found = blade.findAvailableVirtualSwitch(vswitch); + assertEquals(found, vswitch); + } - public void testGetRack() - { - ManagedRack rack = blade.getRack(); - assertNotNull(rack); - assertEquals(rack.getId(), env.ucsRack.getId()); - } + public void testGetRack() { + ManagedRack rack = blade.getRack(); + assertNotNull(rack); + assertEquals(rack.getId(), env.ucsRack.getId()); + } - public void testListBlades() - { - Iterable blades = env.ucsRack.listMachines(); - assertTrue(Iterables.size(blades) > 0); - } + public void testListBlades() { + Iterable blades = env.ucsRack.listMachines(); + assertTrue(Iterables.size(blades) > 0); + } - public void testGetLogicServer() - { - LogicServer logicServer = blade.getLogicServer(); - assertNotNull(logicServer); - assertNotNull(logicServer.getName()); - } + public void testGetLogicServer() { + LogicServer logicServer = blade.getLogicServer(); + assertNotNull(logicServer); + assertNotNull(logicServer.getName()); + } - public void testLedOn() - { - blade.ledOn(); - BladeLocatorLed led = blade.getLocatorLed(); - assertNotNull(led); - assertEquals(led.getAdminStatus(), "on"); - } + public void testLedOn() { + blade.ledOn(); + BladeLocatorLed led = blade.getLocatorLed(); + assertNotNull(led); + assertEquals(led.getAdminStatus(), "on"); + } - public void testLedOff() - { - blade.ledOff(); - BladeLocatorLed led = blade.getLocatorLed(); - assertNotNull(led); - assertEquals(led.getAdminStatus(), "off"); - } + public void testLedOff() { + blade.ledOff(); + BladeLocatorLed led = blade.getLocatorLed(); + assertNotNull(led); + assertEquals(led.getAdminStatus(), "off"); + } - @BeforeClass - public void setup() - { - blade = env.ucsRack.listMachines().get(0); - assertNotNull(blade); - } + @BeforeClass + public void setup() { + blade = env.ucsRack.listMachines().get(0); + assertNotNull(blade); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/DatacenterLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/DatacenterLiveApiTest.java index 650960dd56..af6cbe49a0 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/DatacenterLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/DatacenterLiveApiTest.java @@ -44,47 +44,39 @@ import com.abiquo.server.core.infrastructure.DatacenterDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "DatacenterLiveApiTest") -public class DatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class DatacenterLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - env.datacenter.setLocation("New York"); - env.datacenter.update(); + public void testUpdate() { + env.datacenter.setLocation("New York"); + env.datacenter.update(); - // Recover the updated datacenter - DatacenterDto updated = env.infrastructureApi.getDatacenter(env.datacenter.getId()); + // Recover the updated datacenter + DatacenterDto updated = env.infrastructureApi.getDatacenter(env.datacenter.getId()); - assertEquals(updated.getLocation(), "New York"); - } + assertEquals(updated.getLocation(), "New York"); + } - public void testCheckHypervisorType() - { - HypervisorType type = env.datacenter.getHypervisorType(env.machine.getIp()); + public void testCheckHypervisorType() { + HypervisorType type = env.datacenter.getHypervisorType(env.machine.getIp()); - assertEquals(env.machine.getType(), type); - } + assertEquals(env.machine.getType(), type); + } - public void testCreateRepeated() - { - Datacenter repeated = Builder.fromDatacenter(env.datacenter).build(); + public void testCreateRepeated() { + Datacenter repeated = Builder.fromDatacenter(env.datacenter).build(); - try - { - repeated.save(); - fail("Should not be able to create datacenters with the same name"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "DC-3"); - } - } + try { + repeated.save(); + fail("Should not be able to create datacenters with the same name"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "DC-3"); + } + } - public void testListLimits() - { - List limits = env.datacenter.listLimits(); - assertNotNull(limits); - assertTrue(limits.size() > 0); - } + public void testListLimits() { + List limits = env.datacenter.listLimits(); + assertNotNull(limits); + assertTrue(limits.size() > 0); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java index 67c1d7403d..6864088de8 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/MachineLiveApiTest.java @@ -50,122 +50,103 @@ import com.abiquo.server.core.infrastructure.MachineDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "MachineLiveApiTest") -public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testDiscoverMachineWithouRemoteService() - { - // Delete node collector - RemoteService nc = - env.datacenter.findRemoteService(RemoteServicePredicates - .type(RemoteServiceType.NODE_COLLECTOR)); - nc.delete(); +public class MachineLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testDiscoverMachineWithouRemoteService() { + // Delete node collector + RemoteService nc = env.datacenter.findRemoteService(RemoteServicePredicates + .type(RemoteServiceType.NODE_COLLECTOR)); + nc.delete(); - try - { - String ip = Config.get("abiquo.hypervisor.address"); - HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); - String user = Config.get("abiquo.hypervisor.user"); - String pass = Config.get("abiquo.hypervisor.pass"); + try { + String ip = Config.get("abiquo.hypervisor.address"); + HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); + String user = Config.get("abiquo.hypervisor.user"); + String pass = Config.get("abiquo.hypervisor.pass"); - env.datacenter.discoverSingleMachine(ip, type, user, pass); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.NOT_FOUND, "RS-2"); - } + env.datacenter.discoverSingleMachine(ip, type, user, pass); + } catch (AbiquoException ex) { + assertHasError(ex, Status.NOT_FOUND, "RS-2"); + } - URI endpoint = URI.create(env.context.getApiContext().getProviderMetadata().getEndpoint()); + URI endpoint = URI.create(env.context.getApiContext().getProviderMetadata().getEndpoint()); - // Restore rs - nc = - RemoteService.builder(env.context.getApiContext(), env.datacenter) - .type(RemoteServiceType.NODE_COLLECTOR).ip(endpoint.getHost()).build(); - nc.save(); - } + // Restore rs + nc = RemoteService.builder(env.context.getApiContext(), env.datacenter).type(RemoteServiceType.NODE_COLLECTOR) + .ip(endpoint.getHost()).build(); + nc.save(); + } - public void testUpdate() - { - env.machine.setName("API Machine"); - env.machine.update(); + public void testUpdate() { + env.machine.setName("API Machine"); + env.machine.update(); - // Recover the updated machine - MachineDto updated = - env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); - assertEquals(updated.getName(), "API Machine"); - } + // Recover the updated machine + MachineDto updated = env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); + assertEquals(updated.getName(), "API Machine"); + } - public void testCheck() - { - MachineState state = env.machine.check(); + public void testCheck() { + MachineState state = env.machine.check(); - // Recover the machine with same state that has been returned - MachineDto machine = - env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); - assertEquals(machine.getState(), state); - } + // Recover the machine with same state that has been returned + MachineDto machine = env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); + assertEquals(machine.getState(), state); + } - public void testCheckFromDatacenter() - { - String ip = Config.get("abiquo.hypervisor.address"); - HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); - String user = Config.get("abiquo.hypervisor.user"); - String pass = Config.get("abiquo.hypervisor.pass"); + public void testCheckFromDatacenter() { + String ip = Config.get("abiquo.hypervisor.address"); + HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); + String user = Config.get("abiquo.hypervisor.user"); + String pass = Config.get("abiquo.hypervisor.pass"); - MachineState state = env.datacenter.checkMachineState(ip, type, user, pass); + MachineState state = env.datacenter.checkMachineState(ip, type, user, pass); - // Recover the same machine and compare states - MachineDto machine = - env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); - assertEquals(machine.getState(), state); - } + // Recover the same machine and compare states + MachineDto machine = env.infrastructureApi.getMachine(env.rack.unwrap(), env.machine.getId()); + assertEquals(machine.getState(), state); + } - public void testFindDatastore() - { - Datastore datastore = env.machine.getDatastores().get(0); - Datastore found = env.machine.findDatastore(datastore.getName()); - assertEquals(found.getName(), datastore.getName()); - } + public void testFindDatastore() { + Datastore datastore = env.machine.getDatastores().get(0); + Datastore found = env.machine.findDatastore(datastore.getName()); + assertEquals(found.getName(), datastore.getName()); + } - public void testFindAvailableVirtualSwitch() - { - String vswitch = env.machine.getAvailableVirtualSwitches().get(0); - String found = env.machine.findAvailableVirtualSwitch(vswitch); - assertEquals(found, vswitch); - } + public void testFindAvailableVirtualSwitch() { + String vswitch = env.machine.getAvailableVirtualSwitches().get(0); + String found = env.machine.findAvailableVirtualSwitch(vswitch); + assertEquals(found, vswitch); + } - public void testGetRack() - { - Rack rack = env.machine.getRack(); - assertNotNull(rack); - assertEquals(rack.getId(), env.rack.getId()); - } + public void testGetRack() { + Rack rack = env.machine.getRack(); + assertNotNull(rack); + assertEquals(rack.getId(), env.rack.getId()); + } - public void testListVirtualMachines() - { - List machines = env.machine.listRemoteVirtualMachines(); - assertNotNull(machines); - assertTrue(machines.size() >= 0); - } + public void testListVirtualMachines() { + List machines = env.machine.listRemoteVirtualMachines(); + assertNotNull(machines); + assertTrue(machines.size() >= 0); + } - public void testReserveMachine() - { - assertFalse(env.machine.isReserved()); + public void testReserveMachine() { + assertFalse(env.machine.isReserved()); - env.machine.reserveFor(env.enterprise); - assertTrue(env.machine.isReserved()); + env.machine.reserveFor(env.enterprise); + assertTrue(env.machine.isReserved()); - Enterprise owner = env.machine.getOwnerEnterprise(); - assertNotNull(owner); - assertEquals(owner.getId(), env.enterprise.getId()); - } + Enterprise owner = env.machine.getOwnerEnterprise(); + assertNotNull(owner); + assertEquals(owner.getId(), env.enterprise.getId()); + } - @Test(dependsOnMethods = "testReserveMachine") - public void testCancelReservation() - { - env.machine.cancelReservationFor(env.enterprise); - assertFalse(env.machine.isReserved()); + @Test(dependsOnMethods = "testReserveMachine") + public void testCancelReservation() { + env.machine.cancelReservationFor(env.enterprise); + assertFalse(env.machine.isReserved()); - Enterprise owner = env.machine.getOwnerEnterprise(); - assertNull(owner); - } + Enterprise owner = env.machine.getOwnerEnterprise(); + assertNull(owner); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java index 75ca5eb220..cf0ce82818 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/ManagedRackLiveUcsTest.java @@ -40,84 +40,72 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Test(groups = "ucs", testName = "ManagedRackLiveUcsTest") -public class ManagedRackLiveUcsTest extends BaseAbiquoApiLiveApiTest -{ - private LogicServer logicServer; +public class ManagedRackLiveUcsTest extends BaseAbiquoApiLiveApiTest { + private LogicServer logicServer; - private Organization organization; + private Organization organization; - public void testUpdate() - { - env.ucsRack.setShortDescription("Updated description"); - env.ucsRack.update(); + public void testUpdate() { + env.ucsRack.setShortDescription("Updated description"); + env.ucsRack.update(); - // Recover the updated rack - UcsRackDto updated = - env.infrastructureApi.getManagedRack(env.datacenter.unwrap(), env.ucsRack.getId()); + // Recover the updated rack + UcsRackDto updated = env.infrastructureApi.getManagedRack(env.datacenter.unwrap(), env.ucsRack.getId()); - assertEquals(updated.getShortDescription(), "Updated description"); - } + assertEquals(updated.getShortDescription(), "Updated description"); + } - public void testListManagedRacks() - { - Iterable racks = env.datacenter.listManagedRacks(); - assertEquals(Iterables.size(racks), 1); + public void testListManagedRacks() { + Iterable racks = env.datacenter.listManagedRacks(); + assertEquals(Iterables.size(racks), 1); - racks = env.datacenter.listManagedRacks(ManagedRackPredicates.name(env.ucsRack.getName())); - assertEquals(Iterables.size(racks), 1); - } + racks = env.datacenter.listManagedRacks(ManagedRackPredicates.name(env.ucsRack.getName())); + assertEquals(Iterables.size(racks), 1); + } - public void testFindRack() - { - ManagedRack rack = - env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName())); - assertNotNull(rack); + public void testFindRack() { + ManagedRack rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName())); + assertNotNull(rack); - rack = - env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName() - + "FAIL")); - assertNull(rack); - } + rack = env.datacenter.findManagedRack(ManagedRackPredicates.name(env.ucsRack.getName() + "FAIL")); + assertNull(rack); + } - public void testCloneLogicServer() - { - List originals = env.ucsRack.listServiceProfiles(); - assertNotNull(originals); - assertTrue(originals.size() > 0); - LogicServer original = originals.get(0); + public void testCloneLogicServer() { + List originals = env.ucsRack.listServiceProfiles(); + assertNotNull(originals); + assertTrue(originals.size() > 0); + LogicServer original = originals.get(0); - List organizations = env.ucsRack.listOrganizations(); - assertNotNull(organizations); - assertTrue(organizations.size() > 0); - organization = organizations.get(0); + List organizations = env.ucsRack.listOrganizations(); + assertNotNull(organizations); + assertTrue(organizations.size() > 0); + organization = organizations.get(0); - env.ucsRack.cloneLogicServer(original, organization, "jclouds"); + env.ucsRack.cloneLogicServer(original, organization, "jclouds"); - logicServer = - env.ucsRack.findServiceProfile(LogicServerPredicates.name(organization.getDn() + "/" - + "ls-jclouds")); - assertNotNull(logicServer); + logicServer = env.ucsRack + .findServiceProfile(LogicServerPredicates.name(organization.getDn() + "/" + "ls-jclouds")); + assertNotNull(logicServer); - String name = logicServer.getName(); - assertEquals(name.substring(name.length() - 7, name.length()), "jclouds"); - } + String name = logicServer.getName(); + assertEquals(name.substring(name.length() - 7, name.length()), "jclouds"); + } - @Test(dependsOnMethods = "testCloneLogicServer") - public void testListFsms() - { - List fsms = env.ucsRack.listFsm(logicServer.getName()); - assertNotNull(fsms); - assertTrue(fsms.size() > 0); - } + @Test(dependsOnMethods = "testCloneLogicServer") + public void testListFsms() { + List fsms = env.ucsRack.listFsm(logicServer.getName()); + assertNotNull(fsms); + assertTrue(fsms.size() > 0); + } - @Test(dependsOnMethods = {"testCloneLogicServer", "testListFsms"}) - public void testDeleteLogicServer() - { - String name = logicServer.getName(); + @Test(dependsOnMethods = { "testCloneLogicServer", "testListFsms" }) + public void testDeleteLogicServer() { + String name = logicServer.getName(); - env.ucsRack.deleteLogicServer(logicServer); + env.ucsRack.deleteLogicServer(logicServer); - LogicServer profile = env.ucsRack.findServiceProfile(LogicServerPredicates.name(name)); - assertNull(profile); - } + LogicServer profile = env.ucsRack.findServiceProfile(LogicServerPredicates.name(name)); + assertNull(profile); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java index 0961998b02..23c3c76eb0 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RackLiveApiTest.java @@ -36,39 +36,35 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Test(groups = "api", testName = "RackLiveApiTest") -public class RackLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class RackLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - env.rack.setName("Updated rack"); - env.rack.update(); + public void testUpdate() { + env.rack.setName("Updated rack"); + env.rack.update(); - // Recover the updated rack - RackDto updated = env.infrastructureApi.getRack(env.datacenter.unwrap(), env.rack.getId()); + // Recover the updated rack + RackDto updated = env.infrastructureApi.getRack(env.datacenter.unwrap(), env.rack.getId()); - assertEquals(updated.getName(), "Updated rack"); - } + assertEquals(updated.getName(), "Updated rack"); + } - public void testListRacks() - { - Iterable racks = env.datacenter.listRacks(); - assertEquals(Iterables.size(racks), 1); + public void testListRacks() { + Iterable racks = env.datacenter.listRacks(); + assertEquals(Iterables.size(racks), 1); - racks = env.datacenter.listRacks(name(env.rack.getName())); - assertEquals(Iterables.size(racks), 1); + racks = env.datacenter.listRacks(name(env.rack.getName())); + assertEquals(Iterables.size(racks), 1); - racks = env.datacenter.listRacks(name(env.rack.getName() + "FAIL")); - assertEquals(Iterables.size(racks), 0); - } + racks = env.datacenter.listRacks(name(env.rack.getName() + "FAIL")); + assertEquals(Iterables.size(racks), 0); + } - public void testFindRack() - { - Rack rack = env.datacenter.findRack(name(env.rack.getName())); - assertNotNull(rack); + public void testFindRack() { + Rack rack = env.datacenter.findRack(name(env.rack.getName())); + assertNotNull(rack); - rack = env.datacenter.findRack(name(env.rack.getName() + "FAIL")); - assertNull(rack); - } + rack = env.datacenter.findRack(name(env.rack.getName() + "FAIL")); + assertNull(rack); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java index 7cb1d1d3ec..95060e704a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/RemoteServiceLiveApiTest.java @@ -46,86 +46,70 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Test(groups = "api", testName = "RemoteServiceLiveApiTest") -public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testUpdate() - { - // Update the remote service - RemoteService rs = - env.datacenter.findRemoteService(type(RemoteServiceType.VIRTUAL_FACTORY)); - rs.setUri(rs.getUri()); - rs.update(); +public class RemoteServiceLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testUpdate() { + // Update the remote service + RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.VIRTUAL_FACTORY)); + rs.setUri(rs.getUri()); + rs.update(); - // Recover the updated remote service - RemoteServiceDto updated = - env.infrastructureApi.getRemoteService(env.datacenter.unwrap(), - RemoteServiceType.VIRTUAL_FACTORY); + // Recover the updated remote service + RemoteServiceDto updated = env.infrastructureApi.getRemoteService(env.datacenter.unwrap(), + RemoteServiceType.VIRTUAL_FACTORY); - assertEquals(updated.getUri(), rs.getUri()); - } + assertEquals(updated.getUri(), rs.getUri()); + } - public void testDelete() - { - RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.BPM_SERVICE)); - rs.delete(); + public void testDelete() { + RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.BPM_SERVICE)); + rs.delete(); - // Recover the deleted remote service - RemoteServiceDto deleted = - env.infrastructureApi.getRemoteService(env.datacenter.unwrap(), - RemoteServiceType.BPM_SERVICE); + // Recover the deleted remote service + RemoteServiceDto deleted = env.infrastructureApi.getRemoteService(env.datacenter.unwrap(), + RemoteServiceType.BPM_SERVICE); - assertNull(deleted); + assertNull(deleted); - URI endpoint = URI.create(env.context.getApiContext().getProviderMetadata().getEndpoint()); + URI endpoint = URI.create(env.context.getApiContext().getProviderMetadata().getEndpoint()); - // Restore rs - RemoteService bpm = - RemoteService.builder(env.context.getApiContext(), env.datacenter) - .type(RemoteServiceType.BPM_SERVICE).ip(endpoint.getHost()).build(); - bpm.save(); - } + // Restore rs + RemoteService bpm = RemoteService.builder(env.context.getApiContext(), env.datacenter) + .type(RemoteServiceType.BPM_SERVICE).ip(endpoint.getHost()).build(); + bpm.save(); + } - public void testIsAvailableNonCheckeable() - { - RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.DHCP_SERVICE)); - assertTrue(rs.isAvailable()); - } + public void testIsAvailableNonCheckeable() { + RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.DHCP_SERVICE)); + assertTrue(rs.isAvailable()); + } - public void testIsAvailable() - { - RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR)); - assertTrue(rs.isAvailable()); - } + public void testIsAvailable() { + RemoteService rs = env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR)); + assertTrue(rs.isAvailable()); + } - public void testCreateRepeated() - { - RemoteService repeated = Builder.fromRemoteService(env.remoteServices.get(1)).build(); + public void testCreateRepeated() { + RemoteService repeated = Builder.fromRemoteService(env.remoteServices.get(1)).build(); - try - { - repeated.save(); - fail("Should not be able to create duplicated remote services in the datacenter"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "RS-6"); - } - } + try { + repeated.save(); + fail("Should not be able to create duplicated remote services in the datacenter"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "RS-6"); + } + } - public void testListRemoteServices() - { - Iterable remoteServices = env.datacenter.listRemoteServices(); - assertEquals(Iterables.size(remoteServices), env.remoteServices.size()); + public void testListRemoteServices() { + Iterable remoteServices = env.datacenter.listRemoteServices(); + assertEquals(Iterables.size(remoteServices), env.remoteServices.size()); - remoteServices = env.datacenter.listRemoteServices(type(RemoteServiceType.NODE_COLLECTOR)); - assertEquals(Iterables.size(remoteServices), 1); - } + remoteServices = env.datacenter.listRemoteServices(type(RemoteServiceType.NODE_COLLECTOR)); + assertEquals(Iterables.size(remoteServices), 1); + } - public void testFindRemoteService() - { - RemoteService remoteService = - env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR)); - assertNotNull(remoteService); - } + public void testFindRemoteService() { + RemoteService remoteService = env.datacenter.findRemoteService(type(RemoteServiceType.NODE_COLLECTOR)); + assertNotNull(remoteService); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java index 4b3cf4ce4f..179c5ef739 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StorageDeviceLiveApiTest.java @@ -37,49 +37,39 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Test(groups = "api", testName = "StorageDeviceLiveApiTest") -public class StorageDeviceLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class StorageDeviceLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - env.storageDevice.setName("Updated storage device"); - env.storageDevice.update(); + public void testUpdate() { + env.storageDevice.setName("Updated storage device"); + env.storageDevice.update(); - // Recover the updated storage device - StorageDeviceDto updated = - env.infrastructureApi.getStorageDevice(env.datacenter.unwrap(), - env.storageDevice.getId()); + // Recover the updated storage device + StorageDeviceDto updated = env.infrastructureApi.getStorageDevice(env.datacenter.unwrap(), + env.storageDevice.getId()); - assertEquals(updated.getName(), "Updated storage device"); - } + assertEquals(updated.getName(), "Updated storage device"); + } - public void testListStorageDevices() - { - Iterable storageDevices = env.datacenter.listStorageDevices(); - assertEquals(Iterables.size(storageDevices), 1); + public void testListStorageDevices() { + Iterable storageDevices = env.datacenter.listStorageDevices(); + assertEquals(Iterables.size(storageDevices), 1); - storageDevices = - env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice - .getName())); - assertEquals(Iterables.size(storageDevices), 1); + storageDevices = env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice.getName())); + assertEquals(Iterables.size(storageDevices), 1); - storageDevices = - env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice - .getName() + "FAIL")); - assertEquals(Iterables.size(storageDevices), 0); - } + storageDevices = env.datacenter.listStorageDevices(StorageDevicePredicates.name(env.storageDevice.getName() + + "FAIL")); + assertEquals(Iterables.size(storageDevices), 0); + } - public void testFindStorageDevice() - { - StorageDevice storageDevice = - env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice - .getName())); - assertNotNull(storageDevice); + public void testFindStorageDevice() { + StorageDevice storageDevice = env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice + .getName())); + assertNotNull(storageDevice); - storageDevice = - env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice - .getName() + "FAIL")); - assertNull(storageDevice); - } + storageDevice = env.datacenter.findStorageDevice(StorageDevicePredicates.name(env.storageDevice.getName() + + "FAIL")); + assertNull(storageDevice); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java index 4bfa7951aa..303e4598ce 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/StoragePoolLiveApiTest.java @@ -37,67 +37,51 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Test(groups = "api", testName = "StoragePoolLiveApiTest") -public class StoragePoolLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testGetDevice() - { - StorageDevice device = env.storagePool.getStorageDevice(); - assertNotNull(device); - assertEquals(device.getId(), env.storageDevice.getId()); - } +public class StoragePoolLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testGetDevice() { + StorageDevice device = env.storagePool.getStorageDevice(); + assertNotNull(device); + assertEquals(device.getId(), env.storageDevice.getId()); + } - public void testUpdate() - { - try - { - Tier tier3 = env.datacenter.findTier(TierPredicates.name("Default Tier 3")); - assertNotNull(tier3); - env.storagePool.setTier(tier3); - env.storagePool.update(); + public void testUpdate() { + try { + Tier tier3 = env.datacenter.findTier(TierPredicates.name("Default Tier 3")); + assertNotNull(tier3); + env.storagePool.setTier(tier3); + env.storagePool.update(); - assertEquals(env.storagePool.getTier().getName(), "Default Tier 3"); - } - finally - { - // Restore the original tier - env.storagePool.setTier(env.tier); - env.storagePool.update(); - assertEquals(env.storagePool.getTier().getId(), env.tier.getId()); - } - } + assertEquals(env.storagePool.getTier().getName(), "Default Tier 3"); + } finally { + // Restore the original tier + env.storagePool.setTier(env.tier); + env.storagePool.update(); + assertEquals(env.storagePool.getTier().getId(), env.tier.getId()); + } + } - public void testListStoragePool() - { - Iterable storagePools = env.storageDevice.listStoragePools(); - assertEquals(Iterables.size(storagePools), 1); + public void testListStoragePool() { + Iterable storagePools = env.storageDevice.listStoragePools(); + assertEquals(Iterables.size(storagePools), 1); - storagePools = - env.storageDevice - .listStoragePools(StoragePoolPredicates.name(env.storagePool.getName())); - assertEquals(Iterables.size(storagePools), 1); + storagePools = env.storageDevice.listStoragePools(StoragePoolPredicates.name(env.storagePool.getName())); + assertEquals(Iterables.size(storagePools), 1); - storagePools = - env.storageDevice.listStoragePools(StoragePoolPredicates.name(env.storagePool.getName() - + "FAIL")); - assertEquals(Iterables.size(storagePools), 0); - } + storagePools = env.storageDevice.listStoragePools(StoragePoolPredicates.name(env.storagePool.getName() + "FAIL")); + assertEquals(Iterables.size(storagePools), 0); + } - public void testFindStoragePool() - { - StoragePool storagePool = - env.storageDevice - .findStoragePool(StoragePoolPredicates.name(env.storagePool.getName())); - assertNotNull(storagePool); + public void testFindStoragePool() { + StoragePool storagePool = env.storageDevice + .findStoragePool(StoragePoolPredicates.name(env.storagePool.getName())); + assertNotNull(storagePool); - storagePool = - env.storageDevice.findStoragePool(StoragePoolPredicates.name(env.storagePool.getName() - + "FAIL")); - assertNull(storagePool); - } + storagePool = env.storageDevice.findStoragePool(StoragePoolPredicates.name(env.storagePool.getName() + "FAIL")); + assertNull(storagePool); + } - public void testRefreshStoragePool() - { - env.storagePool.refresh(); - } + public void testRefreshStoragePool() { + env.storagePool.refresh(); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java index 1599452536..96ea1aee1d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/infrastructure/TierLiveApiTest.java @@ -35,33 +35,30 @@ import com.google.common.collect.Iterables; * @author Francesc Montserrat */ @Test(groups = "api", testName = "TierLiveApiTest") -public class TierLiveApiTest extends BaseAbiquoApiLiveApiTest -{ +public class TierLiveApiTest extends BaseAbiquoApiLiveApiTest { - public void testUpdate() - { - Tier tier = env.datacenter.listTiers().get(0); - assertNotNull(tier); + public void testUpdate() { + Tier tier = env.datacenter.listTiers().get(0); + assertNotNull(tier); - String previousName = tier.getName(); - tier.setName("Updated tier"); - tier.update(); + String previousName = tier.getName(); + tier.setName("Updated tier"); + tier.update(); - // Recover the updated tier - Tier updated = env.datacenter.findTier(TierPredicates.name("Updated tier")); - assertEquals(updated.getName(), "Updated tier"); + // Recover the updated tier + Tier updated = env.datacenter.findTier(TierPredicates.name("Updated tier")); + assertEquals(updated.getName(), "Updated tier"); - // Set original name - tier.setName(previousName); - tier.update(); - } + // Set original name + tier.setName(previousName); + tier.update(); + } - public void testListTiers() - { - Iterable tiers = env.datacenter.listTiers(); - assertEquals(Iterables.size(tiers), 4); + public void testListTiers() { + Iterable tiers = env.datacenter.listTiers(); + assertEquals(Iterables.size(tiers), 4); - tiers = env.datacenter.listTiers(TierPredicates.name("FAIL")); - assertEquals(Iterables.size(tiers), 0); - } + tiers = env.datacenter.listTiers(TierPredicates.name("FAIL")); + assertEquals(Iterables.size(tiers), 0); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java index 5c0c0454cb..013bd93684 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/ExternalNetworkLiveApiTest.java @@ -46,141 +46,115 @@ import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ExternalNetworkLiveApiTest") -public class ExternalNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private ExternalNetwork externalNetwork; +public class ExternalNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { + private ExternalNetwork externalNetwork; - @BeforeClass - public void setupNetwork() - { - externalNetwork = createNetwork(env.externalNetwork, PREFIX + "-externalnetwork-test"); - } + @BeforeClass + public void setupNetwork() { + externalNetwork = createNetwork(env.externalNetwork, PREFIX + "-externalnetwork-test"); + } - @AfterClass - public void tearDownNetwork() - { - externalNetwork.delete(); - } + @AfterClass + public void tearDownNetwork() { + externalNetwork.delete(); + } - public void testListIps() - { - ExternalIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listExternalIps(externalNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListIps() { + ExternalIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listExternalIps(externalNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = externalNetwork.listIps(); + List ips = externalNetwork.listIps(); - assertEquals(ips.size(), totalIps); - } + assertEquals(ips.size(), totalIps); + } - public void testListIpsWithOptions() - { - List ips = externalNetwork.listIps(IpOptions.builder().limit(5).build()); - assertEquals(ips.size(), 5); - } + public void testListIpsWithOptions() { + List ips = externalNetwork.listIps(IpOptions.builder().limit(5).build()); + assertEquals(ips.size(), 5); + } - public void testListUnusedIps() - { - ExternalIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listExternalIps(externalNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListUnusedIps() { + ExternalIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listExternalIps(externalNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = externalNetwork.listUnusedIps(); - assertEquals(ips.size(), totalIps); - } + List ips = externalNetwork.listUnusedIps(); + assertEquals(ips.size(), totalIps); + } - public void testUpdateBasicInfo() - { - externalNetwork.setName("External network Updated"); - externalNetwork.setPrimaryDNS("8.8.8.8"); - externalNetwork.setSecondaryDNS("8.8.8.8"); - externalNetwork.update(); + public void testUpdateBasicInfo() { + externalNetwork.setName("External network Updated"); + externalNetwork.setPrimaryDNS("8.8.8.8"); + externalNetwork.setSecondaryDNS("8.8.8.8"); + externalNetwork.update(); - assertEquals(externalNetwork.getName(), "External network Updated"); - assertEquals(externalNetwork.getPrimaryDNS(), "8.8.8.8"); - assertEquals(externalNetwork.getSecondaryDNS(), "8.8.8.8"); + assertEquals(externalNetwork.getName(), "External network Updated"); + assertEquals(externalNetwork.getPrimaryDNS(), "8.8.8.8"); + assertEquals(externalNetwork.getSecondaryDNS(), "8.8.8.8"); - // Refresh the external network - ExternalNetwork en = - env.enterprise.findExternalNetwork(env.datacenter, - NetworkPredicates. name(externalNetwork.getName())); + // Refresh the external network + ExternalNetwork en = env.enterprise.findExternalNetwork(env.datacenter, + NetworkPredicates. name(externalNetwork.getName())); - assertEquals(en.getId(), externalNetwork.getId()); - assertEquals(en.getName(), "External network Updated"); - assertEquals(en.getPrimaryDNS(), "8.8.8.8"); - assertEquals(en.getSecondaryDNS(), "8.8.8.8"); - } + assertEquals(en.getId(), externalNetwork.getId()); + assertEquals(en.getName(), "External network Updated"); + assertEquals(en.getPrimaryDNS(), "8.8.8.8"); + assertEquals(en.getSecondaryDNS(), "8.8.8.8"); + } - public void testUpdateReadOnlyFields() - { - ExternalNetwork toUpdate = createNetwork(externalNetwork, PREFIX + "-exttoupdate-test"); + public void testUpdateReadOnlyFields() { + ExternalNetwork toUpdate = createNetwork(externalNetwork, PREFIX + "-exttoupdate-test"); - try - { - toUpdate.setTag(20); - toUpdate.setAddress("10.1.0.0"); - toUpdate.setMask(16); - toUpdate.update(); + try { + toUpdate.setTag(20); + toUpdate.setAddress("10.1.0.0"); + toUpdate.setMask(16); + toUpdate.update(); - fail("Tag field should not be editable"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "VLAN-19"); - } - finally - { - toUpdate.delete(); - } - } + fail("Tag field should not be editable"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "VLAN-19"); + } finally { + toUpdate.delete(); + } + } - public void testUpdateWithInvalidValues() - { - ExternalNetwork toUpdate = createNetwork(externalNetwork, PREFIX + "-exttoupdate-test"); + public void testUpdateWithInvalidValues() { + ExternalNetwork toUpdate = createNetwork(externalNetwork, PREFIX + "-exttoupdate-test"); - try - { - toUpdate.setMask(60); - toUpdate.update(); + try { + toUpdate.setMask(60); + toUpdate.update(); - fail("Invalid mask value"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); - } - finally - { - toUpdate.delete(); - } - } + fail("Invalid mask value"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); + } finally { + toUpdate.delete(); + } + } - public void testGetEnterprise() - { - assertEquals(externalNetwork.getEnterprise().getId(), env.enterprise.getId()); - } + public void testGetEnterprise() { + assertEquals(externalNetwork.getEnterprise().getId(), env.enterprise.getId()); + } - public void testGetDatacenter() - { - assertEquals(externalNetwork.getDatacenter().getId(), env.datacenter.getId()); - } + public void testGetDatacenter() { + assertEquals(externalNetwork.getDatacenter().getId(), env.datacenter.getId()); + } - public void testGetNetworkFromIp() - { - ExternalIp ip = externalNetwork.findIp(IpPredicates. notUsed()); - ExternalNetwork network = ip.getNetwork(); + public void testGetNetworkFromIp() { + ExternalIp ip = externalNetwork.findIp(IpPredicates. notUsed()); + ExternalNetwork network = ip.getNetwork(); - assertEquals(network.getId(), externalNetwork.getId()); - } + assertEquals(network.getId(), externalNetwork.getId()); + } - private ExternalNetwork createNetwork(final ExternalNetwork from, final String name) - { - ExternalNetwork network = ExternalNetwork.Builder.fromExternalNetwork(from).build(); - network.setName(name); - network.save(); - assertNotNull(network.getId()); - return network; - } + private ExternalNetwork createNetwork(final ExternalNetwork from, final String name) { + ExternalNetwork network = ExternalNetwork.Builder.fromExternalNetwork(from).build(); + network.setName(name); + network.save(); + assertNotNull(network.getId()); + return network; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/GenericNetworkLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/GenericNetworkLiveApiTest.java index 411af0ff30..1d80e2ed89 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/GenericNetworkLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/GenericNetworkLiveApiTest.java @@ -39,55 +39,46 @@ import com.abiquo.model.enumerator.NetworkType; * @author Ignasi Barrera */ @Test(groups = "api", testName = "GenericNetworkLiveApiTest") -public class GenericNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - public void testListDatacenterNetworks() - { - // Make sure all network types are listed - List> networks = env.datacenter.listNetworks(); - assertNotNull(networks); - assertEquals(networks.size(), 3); - } +public class GenericNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { + public void testListDatacenterNetworks() { + // Make sure all network types are listed + List> networks = env.datacenter.listNetworks(); + assertNotNull(networks); + assertEquals(networks.size(), 3); + } - public void testListPublicNetworks() - { - List> networks = env.datacenter.listNetworks(NetworkType.PUBLIC); - assertNotNull(networks); - assertEquals(networks.size(), 1); + public void testListPublicNetworks() { + List> networks = env.datacenter.listNetworks(NetworkType.PUBLIC); + assertNotNull(networks); + assertEquals(networks.size(), 1); - // Make sure it can be converted - networks.get(0).toPublicNetwork(); - } + // Make sure it can be converted + networks.get(0).toPublicNetwork(); + } - public void testListExternaletworks() - { - List> networks = env.datacenter.listNetworks(NetworkType.EXTERNAL); - assertNotNull(networks); - assertEquals(networks.size(), 1); + public void testListExternaletworks() { + List> networks = env.datacenter.listNetworks(NetworkType.EXTERNAL); + assertNotNull(networks); + assertEquals(networks.size(), 1); - // Make sure it can be converted - networks.get(0).toExternalNetwork(); - } + // Make sure it can be converted + networks.get(0).toExternalNetwork(); + } - public void testListUnmanagedNetworks() - { - List> networks = env.datacenter.listNetworks(NetworkType.UNMANAGED); - assertNotNull(networks); - assertEquals(networks.size(), 1); + public void testListUnmanagedNetworks() { + List> networks = env.datacenter.listNetworks(NetworkType.UNMANAGED); + assertNotNull(networks); + assertEquals(networks.size(), 1); - // Make sure it can be converted - networks.get(0).toUnmanagedNetwork(); - } + // Make sure it can be converted + networks.get(0).toUnmanagedNetwork(); + } - public void testListPrivateNetworks() - { - try - { - env.datacenter.listNetworks(NetworkType.INTERNAL); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "QUERY-1"); - } - } + public void testListPrivateNetworks() { + try { + env.datacenter.listNetworks(NetworkType.INTERNAL); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "QUERY-1"); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java index ca6bbff464..f17881f8b4 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PrivateNetworkLiveApiTest.java @@ -46,142 +46,105 @@ import com.abiquo.server.core.infrastructure.network.PrivateIpsDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "PrivateNetworkLiveApiTest") -public class PrivateNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private PrivateNetwork privateNetwork; +public class PrivateNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { + private PrivateNetwork privateNetwork; - @BeforeClass - public void setupNetwork() - { - privateNetwork = - createNetwork(env.virtualDatacenter, env.privateNetwork, PREFIX - + "-privatenetwork-test"); - } + @BeforeClass + public void setupNetwork() { + privateNetwork = createNetwork(env.virtualDatacenter, env.privateNetwork, PREFIX + "-privatenetwork-test"); + } - @AfterClass - public void tearDownNetwork() - { - privateNetwork.delete(); - } + @AfterClass + public void tearDownNetwork() { + privateNetwork.delete(); + } - public void testListIps() - { - PrivateIpsDto ipsDto = - env.context - .getApiContext() - .getApi() - .getCloudApi() - .listPrivateNetworkIps(privateNetwork.unwrap(), - IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListIps() { + PrivateIpsDto ipsDto = env.context.getApiContext().getApi().getCloudApi() + .listPrivateNetworkIps(privateNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = privateNetwork.listIps(); + List ips = privateNetwork.listIps(); - assertEquals(ips.size(), totalIps); - } + assertEquals(ips.size(), totalIps); + } - public void testListIpsWithOptions() - { - List ips = privateNetwork.listIps(IpOptions.builder().limit(5).build()); - assertEquals(ips.size(), 5); - } + public void testListIpsWithOptions() { + List ips = privateNetwork.listIps(IpOptions.builder().limit(5).build()); + assertEquals(ips.size(), 5); + } - public void testListUnusedIps() - { - PrivateIpsDto ipsDto = - env.context - .getApiContext() - .getApi() - .getCloudApi() - .listPrivateNetworkIps(privateNetwork.unwrap(), - IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListUnusedIps() { + PrivateIpsDto ipsDto = env.context.getApiContext().getApi().getCloudApi() + .listPrivateNetworkIps(privateNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = privateNetwork.listUnusedIps(); - assertEquals(ips.size(), totalIps); - } + List ips = privateNetwork.listUnusedIps(); + assertEquals(ips.size(), totalIps); + } - public void testUpdateBasicInfo() - { - privateNetwork.setName("Private network Updated"); - privateNetwork.setPrimaryDNS("8.8.8.8"); - privateNetwork.setSecondaryDNS("8.8.8.8"); - privateNetwork.update(); + public void testUpdateBasicInfo() { + privateNetwork.setName("Private network Updated"); + privateNetwork.setPrimaryDNS("8.8.8.8"); + privateNetwork.setSecondaryDNS("8.8.8.8"); + privateNetwork.update(); - assertEquals(privateNetwork.getName(), "Private network Updated"); - assertEquals(privateNetwork.getPrimaryDNS(), "8.8.8.8"); - assertEquals(privateNetwork.getSecondaryDNS(), "8.8.8.8"); + assertEquals(privateNetwork.getName(), "Private network Updated"); + assertEquals(privateNetwork.getPrimaryDNS(), "8.8.8.8"); + assertEquals(privateNetwork.getSecondaryDNS(), "8.8.8.8"); - // Refresh the private network - PrivateNetwork pn = env.virtualDatacenter.getPrivateNetwork(privateNetwork.getId()); + // Refresh the private network + PrivateNetwork pn = env.virtualDatacenter.getPrivateNetwork(privateNetwork.getId()); - assertEquals(pn.getName(), "Private network Updated"); - assertEquals(pn.getPrimaryDNS(), "8.8.8.8"); - assertEquals(pn.getSecondaryDNS(), "8.8.8.8"); - } + assertEquals(pn.getName(), "Private network Updated"); + assertEquals(pn.getPrimaryDNS(), "8.8.8.8"); + assertEquals(pn.getSecondaryDNS(), "8.8.8.8"); + } - public void testUpdateReadOnlyFields() - { - PrivateNetwork toUpdate = - createNetwork(env.virtualDatacenter, privateNetwork, PREFIX + "-privtoupdate-test"); + public void testUpdateReadOnlyFields() { + PrivateNetwork toUpdate = createNetwork(env.virtualDatacenter, privateNetwork, PREFIX + "-privtoupdate-test"); - try - { - toUpdate.setTag(20); - toUpdate.setAddress("10.1.1.0"); - toUpdate.setMask(16); - toUpdate.update(); + try { + toUpdate.setTag(20); + toUpdate.setAddress("10.1.1.0"); + toUpdate.setMask(16); + toUpdate.update(); - fail("Tag field should not be editable"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "VLAN-10"); - } - finally - { - toUpdate.delete(); - } - } + fail("Tag field should not be editable"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "VLAN-10"); + } finally { + toUpdate.delete(); + } + } - public void testUpdateWithInvalidValues() - { - PrivateNetwork toUpdate = - createNetwork(env.virtualDatacenter, privateNetwork, PREFIX + "-privtoupdate-test"); + public void testUpdateWithInvalidValues() { + PrivateNetwork toUpdate = createNetwork(env.virtualDatacenter, privateNetwork, PREFIX + "-privtoupdate-test"); - try - { - toUpdate.setMask(60); - toUpdate.update(); + try { + toUpdate.setMask(60); + toUpdate.update(); - fail("Invalid mask value"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); - } - finally - { - toUpdate.delete(); - } - } + fail("Invalid mask value"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); + } finally { + toUpdate.delete(); + } + } - public void testGetNetworkFromIp() - { - PrivateIp ip = privateNetwork.findIp(IpPredicates. notUsed()); - PrivateNetwork network = ip.getNetwork(); + public void testGetNetworkFromIp() { + PrivateIp ip = privateNetwork.findIp(IpPredicates. notUsed()); + PrivateNetwork network = ip.getNetwork(); - assertEquals(network.getId(), privateNetwork.getId()); - } + assertEquals(network.getId(), privateNetwork.getId()); + } - private PrivateNetwork createNetwork(final VirtualDatacenter vdc, final PrivateNetwork from, - final String name) - { - PrivateNetwork network = - PrivateNetwork.Builder.fromPrivateNetwork(from).virtualDatacenter(vdc).build(); - network.setName(name); - network.save(); - assertNotNull(network.getId()); - return network; - } + private PrivateNetwork createNetwork(final VirtualDatacenter vdc, final PrivateNetwork from, final String name) { + PrivateNetwork network = PrivateNetwork.Builder.fromPrivateNetwork(from).virtualDatacenter(vdc).build(); + network.setName(name); + network.save(); + assertNotNull(network.getId()); + return network; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java index 4456a1bc21..94200fc268 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/PublicNetworkLiveApiTest.java @@ -45,134 +45,110 @@ import com.abiquo.server.core.infrastructure.network.PublicIpsDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "PublicNetworkLiveApiTest") -public class PublicNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private PublicNetwork publicNetwork; +public class PublicNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { + private PublicNetwork publicNetwork; - @BeforeClass - public void setupNetwork() - { - publicNetwork = createNetwork(env.publicNetwork, PREFIX + "-publicnetwork-test"); - } + @BeforeClass + public void setupNetwork() { + publicNetwork = createNetwork(env.publicNetwork, PREFIX + "-publicnetwork-test"); + } - @AfterClass - public void tearDownNetwork() - { - publicNetwork.delete(); - } + @AfterClass + public void tearDownNetwork() { + publicNetwork.delete(); + } - public void testListIps() - { - PublicIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listPublicIps(publicNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListIps() { + PublicIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listPublicIps(publicNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = publicNetwork.listIps(); + List ips = publicNetwork.listIps(); - assertEquals(ips.size(), totalIps); - } + assertEquals(ips.size(), totalIps); + } - public void testListIpsWithOptions() - { - List ips = publicNetwork.listIps(IpOptions.builder().limit(5).build()); - assertEquals(ips.size(), 5); - } + public void testListIpsWithOptions() { + List ips = publicNetwork.listIps(IpOptions.builder().limit(5).build()); + assertEquals(ips.size(), 5); + } - public void testListUnusedIps() - { - PublicIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listPublicIps(publicNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListUnusedIps() { + PublicIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listPublicIps(publicNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = publicNetwork.listUnusedIps(); - assertEquals(ips.size(), totalIps); - } + List ips = publicNetwork.listUnusedIps(); + assertEquals(ips.size(), totalIps); + } - public void testUpdateBasicInfo() - { - publicNetwork.setName("Public network Updated"); - publicNetwork.setPrimaryDNS("8.8.8.8"); - publicNetwork.setSecondaryDNS("8.8.8.8"); - publicNetwork.update(); + public void testUpdateBasicInfo() { + publicNetwork.setName("Public network Updated"); + publicNetwork.setPrimaryDNS("8.8.8.8"); + publicNetwork.setSecondaryDNS("8.8.8.8"); + publicNetwork.update(); - assertEquals(publicNetwork.getName(), "Public network Updated"); - assertEquals(publicNetwork.getPrimaryDNS(), "8.8.8.8"); - assertEquals(publicNetwork.getSecondaryDNS(), "8.8.8.8"); + assertEquals(publicNetwork.getName(), "Public network Updated"); + assertEquals(publicNetwork.getPrimaryDNS(), "8.8.8.8"); + assertEquals(publicNetwork.getSecondaryDNS(), "8.8.8.8"); - // Refresh the public network - PublicNetwork pn = env.datacenter.getNetwork(publicNetwork.getId()).toPublicNetwork(); + // Refresh the public network + PublicNetwork pn = env.datacenter.getNetwork(publicNetwork.getId()).toPublicNetwork(); - assertEquals(pn.getId(), publicNetwork.getId()); - assertEquals(pn.getName(), "Public network Updated"); - assertEquals(pn.getPrimaryDNS(), "8.8.8.8"); - assertEquals(pn.getSecondaryDNS(), "8.8.8.8"); - } + assertEquals(pn.getId(), publicNetwork.getId()); + assertEquals(pn.getName(), "Public network Updated"); + assertEquals(pn.getPrimaryDNS(), "8.8.8.8"); + assertEquals(pn.getSecondaryDNS(), "8.8.8.8"); + } - public void testUpdateReadOnlyFields() - { - PublicNetwork toUpdate = createNetwork(publicNetwork, PREFIX + "-pubtoupdate-test"); + public void testUpdateReadOnlyFields() { + PublicNetwork toUpdate = createNetwork(publicNetwork, PREFIX + "-pubtoupdate-test"); - try - { - toUpdate.setTag(20); - toUpdate.setAddress("80.81.81.0"); - toUpdate.setMask(16); - toUpdate.update(); + try { + toUpdate.setTag(20); + toUpdate.setAddress("80.81.81.0"); + toUpdate.setMask(16); + toUpdate.update(); - fail("Tag field should not be editable"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "VLAN-19"); - } - finally - { - toUpdate.delete(); - } - } + fail("Tag field should not be editable"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "VLAN-19"); + } finally { + toUpdate.delete(); + } + } - public void testUpdateWithInvalidValues() - { - PublicNetwork toUpdate = createNetwork(publicNetwork, PREFIX + "-pubtoupdate-test"); + public void testUpdateWithInvalidValues() { + PublicNetwork toUpdate = createNetwork(publicNetwork, PREFIX + "-pubtoupdate-test"); - try - { - toUpdate.setMask(60); - toUpdate.update(); + try { + toUpdate.setMask(60); + toUpdate.update(); - fail("Invalid mask value"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); - } - finally - { - toUpdate.delete(); - } - } + fail("Invalid mask value"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); + } finally { + toUpdate.delete(); + } + } - public void testGetDatacenter() - { - assertEquals(publicNetwork.getDatacenter().getId(), env.datacenter.getId()); - } + public void testGetDatacenter() { + assertEquals(publicNetwork.getDatacenter().getId(), env.datacenter.getId()); + } - public void testGetNetworkFromIp() - { - PublicIp ip = publicNetwork.findIp(IpPredicates. notUsed()); - PublicNetwork network = ip.getNetwork(); + public void testGetNetworkFromIp() { + PublicIp ip = publicNetwork.findIp(IpPredicates. notUsed()); + PublicNetwork network = ip.getNetwork(); - assertEquals(network.getId(), publicNetwork.getId()); - } + assertEquals(network.getId(), publicNetwork.getId()); + } - private PublicNetwork createNetwork(final PublicNetwork from, final String name) - { - PublicNetwork network = PublicNetwork.Builder.fromPublicNetwork(from).build(); - network.setName(name); - network.save(); - assertNotNull(network.getId()); - return network; - } + private PublicNetwork createNetwork(final PublicNetwork from, final String name) { + PublicNetwork network = PublicNetwork.Builder.fromPublicNetwork(from).build(); + network.setName(name); + network.save(); + assertNotNull(network.getId()); + return network; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java index 596e54d719..cf2ebf77bb 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/domain/network/UnmanagedNetworkLiveApiTest.java @@ -47,141 +47,115 @@ import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; * @author Ignasi Barrera */ @Test(groups = "api", testName = "UnmanagedNetworkLiveApiTest") -public class UnmanagedNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - private UnmanagedNetwork unmanagedNetwork; +public class UnmanagedNetworkLiveApiTest extends BaseAbiquoApiLiveApiTest { + private UnmanagedNetwork unmanagedNetwork; - @BeforeClass - public void setupNetwork() - { - unmanagedNetwork = createNetwork(env.unmanagedNetwork, PREFIX + "-unmanagednetwork-test"); - } + @BeforeClass + public void setupNetwork() { + unmanagedNetwork = createNetwork(env.unmanagedNetwork, PREFIX + "-unmanagednetwork-test"); + } - @AfterClass - public void tearDownNetwork() - { - unmanagedNetwork.delete(); - } + @AfterClass + public void tearDownNetwork() { + unmanagedNetwork.delete(); + } - public void testListIps() - { - UnmanagedIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listUnmanagedIps(unmanagedNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListIps() { + UnmanagedIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listUnmanagedIps(unmanagedNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = unmanagedNetwork.listIps(); + List ips = unmanagedNetwork.listIps(); - assertEquals(ips.size(), totalIps); - } + assertEquals(ips.size(), totalIps); + } - public void testListIpsWithOptions() - { - List ips = unmanagedNetwork.listIps(IpOptions.builder().limit(5).build()); - // Unmanaged networks do not have IPs until attached to VMs - assertEquals(ips.size(), 0); - } + public void testListIpsWithOptions() { + List ips = unmanagedNetwork.listIps(IpOptions.builder().limit(5).build()); + // Unmanaged networks do not have IPs until attached to VMs + assertEquals(ips.size(), 0); + } - public void testListUnusedIps() - { - UnmanagedIpsDto ipsDto = - env.context.getApiContext().getApi().getInfrastructureApi() - .listUnmanagedIps(unmanagedNetwork.unwrap(), IpOptions.builder().limit(1).build()); - int totalIps = ipsDto.getTotalSize(); + public void testListUnusedIps() { + UnmanagedIpsDto ipsDto = env.context.getApiContext().getApi().getInfrastructureApi() + .listUnmanagedIps(unmanagedNetwork.unwrap(), IpOptions.builder().limit(1).build()); + int totalIps = ipsDto.getTotalSize(); - List ips = unmanagedNetwork.listUnusedIps(); - assertEquals(ips.size(), totalIps); - } + List ips = unmanagedNetwork.listUnusedIps(); + assertEquals(ips.size(), totalIps); + } - public void testUpdateBasicInfo() - { - unmanagedNetwork.setName("Unmanaged network Updated"); - unmanagedNetwork.setPrimaryDNS("8.8.8.8"); - unmanagedNetwork.setSecondaryDNS("8.8.8.8"); - unmanagedNetwork.update(); + public void testUpdateBasicInfo() { + unmanagedNetwork.setName("Unmanaged network Updated"); + unmanagedNetwork.setPrimaryDNS("8.8.8.8"); + unmanagedNetwork.setSecondaryDNS("8.8.8.8"); + unmanagedNetwork.update(); - assertEquals(unmanagedNetwork.getName(), "Unmanaged network Updated"); - assertEquals(unmanagedNetwork.getPrimaryDNS(), "8.8.8.8"); - assertEquals(unmanagedNetwork.getSecondaryDNS(), "8.8.8.8"); + assertEquals(unmanagedNetwork.getName(), "Unmanaged network Updated"); + assertEquals(unmanagedNetwork.getPrimaryDNS(), "8.8.8.8"); + assertEquals(unmanagedNetwork.getSecondaryDNS(), "8.8.8.8"); - // Refresh the unmanaged network - UnmanagedNetwork en = - env.enterprise.findUnmanagedNetwork(env.datacenter, - NetworkPredicates. name(unmanagedNetwork.getName())); + // Refresh the unmanaged network + UnmanagedNetwork en = env.enterprise.findUnmanagedNetwork(env.datacenter, + NetworkPredicates. name(unmanagedNetwork.getName())); - assertEquals(en.getId(), unmanagedNetwork.getId()); - assertEquals(en.getName(), "Unmanaged network Updated"); - assertEquals(en.getPrimaryDNS(), "8.8.8.8"); - assertEquals(en.getSecondaryDNS(), "8.8.8.8"); - } + assertEquals(en.getId(), unmanagedNetwork.getId()); + assertEquals(en.getName(), "Unmanaged network Updated"); + assertEquals(en.getPrimaryDNS(), "8.8.8.8"); + assertEquals(en.getSecondaryDNS(), "8.8.8.8"); + } - public void testUpdateReadOnlyFields() - { - UnmanagedNetwork toUpdate = createNetwork(unmanagedNetwork, PREFIX + "-umtoupdate-test"); + public void testUpdateReadOnlyFields() { + UnmanagedNetwork toUpdate = createNetwork(unmanagedNetwork, PREFIX + "-umtoupdate-test"); - try - { - toUpdate.setTag(20); - toUpdate.setAddress("10.2.0.0"); - toUpdate.setMask(16); - toUpdate.update(); + try { + toUpdate.setTag(20); + toUpdate.setAddress("10.2.0.0"); + toUpdate.setMask(16); + toUpdate.update(); - fail("Tag field should not be editable"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.CONFLICT, "VLAN-19"); - } - finally - { - toUpdate.delete(); - } - } + fail("Tag field should not be editable"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.CONFLICT, "VLAN-19"); + } finally { + toUpdate.delete(); + } + } - public void testUpdateWithInvalidValues() - { - UnmanagedNetwork toUpdate = createNetwork(unmanagedNetwork, PREFIX + "-umtoupdate-test"); + public void testUpdateWithInvalidValues() { + UnmanagedNetwork toUpdate = createNetwork(unmanagedNetwork, PREFIX + "-umtoupdate-test"); - try - { - toUpdate.setMask(60); - toUpdate.update(); + try { + toUpdate.setMask(60); + toUpdate.update(); - fail("Invalid mask value"); - } - catch (AbiquoException ex) - { - assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); - } - finally - { - toUpdate.delete(); - } - } + fail("Invalid mask value"); + } catch (AbiquoException ex) { + assertHasError(ex, Status.BAD_REQUEST, "CONSTR-MAX"); + } finally { + toUpdate.delete(); + } + } - public void testGetEnterprise() - { - assertEquals(unmanagedNetwork.getEnterprise().getId(), env.enterprise.getId()); - } + public void testGetEnterprise() { + assertEquals(unmanagedNetwork.getEnterprise().getId(), env.enterprise.getId()); + } - public void testGetDatacenter() - { - assertEquals(unmanagedNetwork.getDatacenter().getId(), env.datacenter.getId()); - } + public void testGetDatacenter() { + assertEquals(unmanagedNetwork.getDatacenter().getId(), env.datacenter.getId()); + } - public void testGetNetworkFromIp() - { - UnmanagedIp ip = unmanagedNetwork.findIp(IpPredicates. notUsed()); - // Unmanaged networks do not have IPs until attached to VMs - assertNull(ip); - } + public void testGetNetworkFromIp() { + UnmanagedIp ip = unmanagedNetwork.findIp(IpPredicates. notUsed()); + // Unmanaged networks do not have IPs until attached to VMs + assertNull(ip); + } - private UnmanagedNetwork createNetwork(final UnmanagedNetwork from, final String name) - { - UnmanagedNetwork network = UnmanagedNetwork.Builder.fromUnmanagedNetwork(from).build(); - network.setName(name); - network.save(); - assertNotNull(network.getId()); - return network; - } + private UnmanagedNetwork createNetwork(final UnmanagedNetwork from, final String name) { + UnmanagedNetwork network = UnmanagedNetwork.Builder.fromUnmanagedNetwork(from).build(); + network.setName(name); + network.save(); + assertNotNull(network.getId()); + return network; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java index 263f4aeeac..dbfc244367 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/CloudTestEnvironment.java @@ -51,200 +51,170 @@ import com.google.common.primitives.Longs; * * @author Francesc Montserrat */ -public class CloudTestEnvironment extends InfrastructureTestEnvironment -{ +public class CloudTestEnvironment extends InfrastructureTestEnvironment { - // Environment data made public so tests can use them easily - public CloudApi cloudApi; + // Environment data made public so tests can use them easily + public CloudApi cloudApi; - public EventService eventService; + public EventService eventService; - public VirtualDatacenter virtualDatacenter; + public VirtualDatacenter virtualDatacenter; - public VirtualAppliance virtualAppliance; + public VirtualAppliance virtualAppliance; - public VirtualMachine virtualMachine; + public VirtualMachine virtualMachine; - public VirtualMachineTemplate template; + public VirtualMachineTemplate template; - public PrivateNetwork privateNetwork; + public PrivateNetwork privateNetwork; - public Enterprise defaultEnterprise; + public Enterprise defaultEnterprise; - public AbiquoContext plainUserContext; + public AbiquoContext plainUserContext; - public AbiquoContext enterpriseAdminContext; + public AbiquoContext enterpriseAdminContext; - public CloudTestEnvironment(final AbiquoContext context) - { - super(context); - this.cloudApi = context.getApiContext().getApi().getCloudApi(); - this.eventService = context.getEventService(); - } + public CloudTestEnvironment(final AbiquoContext context) { + super(context); + this.cloudApi = context.getApiContext().getApi().getCloudApi(); + this.eventService = context.getEventService(); + } - @Override - public void setup() throws Exception - { - // Create base infrastructure - super.setup(); + @Override + public void setup() throws Exception { + // Create base infrastructure + super.setup(); - createUserContext(); - createEnterpriseAdminContext(); + createUserContext(); + createEnterpriseAdminContext(); - findDefaultEnterprise(); - createVirtualDatacenter(); - createVirtualAppliance(); - refreshTemplateRepository(); - createVirtualMachine(); - } + findDefaultEnterprise(); + createVirtualDatacenter(); + createVirtualAppliance(); + refreshTemplateRepository(); + createVirtualMachine(); + } - @Override - public void tearDown() throws Exception - { - closeEnterpriseAdminContext(); - closeUserContext(); + @Override + public void tearDown() throws Exception { + closeEnterpriseAdminContext(); + closeUserContext(); - deleteVirtualMachine(); - deleteVirtualAppliance(); - deleteVirtualDatacenter(); + deleteVirtualMachine(); + deleteVirtualAppliance(); + deleteVirtualDatacenter(); - // Delete base infrastructure - super.tearDown(); - } + // Delete base infrastructure + super.tearDown(); + } - // Setup + // Setup - private void createUserContext() - { - String endpoint = - checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); + private void createUserContext() { + String endpoint = checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); - plainUserContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + plainUserContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .endpoint(endpoint) // .credentials("abiquo", "jclouds") // .build(AbiquoContext.class); - } + } - private void createEnterpriseAdminContext() - { - String endpoint = - checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); + private void createEnterpriseAdminContext() { + String endpoint = checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); - enterpriseAdminContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + enterpriseAdminContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .endpoint(endpoint) // .credentials("jclouds-admin", "admin") // .build(AbiquoContext.class); - } + } - protected void findDefaultEnterprise() - { - defaultEnterprise = - context.getAdministrationService().findEnterprise(EnterprisePredicates.name("Abiquo")); - } + protected void findDefaultEnterprise() { + defaultEnterprise = context.getAdministrationService().findEnterprise(EnterprisePredicates.name("Abiquo")); + } - protected void createVirtualDatacenter() - { - privateNetwork = - PrivateNetwork.builder(context.getApiContext()).name("DefaultNetwork") - .gateway("192.168.1.1").address("192.168.1.0").mask(24).build(); + protected void createVirtualDatacenter() { + privateNetwork = PrivateNetwork.builder(context.getApiContext()).name("DefaultNetwork").gateway("192.168.1.1") + .address("192.168.1.0").mask(24).build(); - virtualDatacenter = - VirtualDatacenter.builder(context.getApiContext(), datacenter, defaultEnterprise) - .name(PREFIX + "Virtual Aloha").cpuCountLimits(18, 20) - .hdLimitsInMb(279172872, 279172872).publicIpsLimits(2, 3).ramLimits(19456, 20480) - .storageLimits(289910292, 322122547).vlansLimits(3, 4) - .hypervisorType(machine.getType()).network(privateNetwork).build(); + virtualDatacenter = VirtualDatacenter.builder(context.getApiContext(), datacenter, defaultEnterprise) + .name(PREFIX + "Virtual Aloha").cpuCountLimits(18, 20).hdLimitsInMb(279172872, 279172872) + .publicIpsLimits(2, 3).ramLimits(19456, 20480).storageLimits(289910292, 322122547).vlansLimits(3, 4) + .hypervisorType(machine.getType()).network(privateNetwork).build(); - virtualDatacenter.save(); - assertNotNull(virtualDatacenter.getId()); + virtualDatacenter.save(); + assertNotNull(virtualDatacenter.getId()); - privateNetwork = - virtualDatacenter.findPrivateNetwork(NetworkPredicates. name(privateNetwork - .getName())); - } + privateNetwork = virtualDatacenter + .findPrivateNetwork(NetworkPredicates. name(privateNetwork.getName())); + } - protected void createVirtualAppliance() - { - virtualAppliance = - VirtualAppliance.builder(context.getApiContext(), virtualDatacenter) - .name(PREFIX + "Virtual AppAloha").build(); + protected void createVirtualAppliance() { + virtualAppliance = VirtualAppliance.builder(context.getApiContext(), virtualDatacenter) + .name(PREFIX + "Virtual AppAloha").build(); - virtualAppliance.save(); - assertNotNull(virtualAppliance.getId()); - } + virtualAppliance.save(); + assertNotNull(virtualAppliance.getId()); + } - protected void createVirtualMachine() - { - List templates = virtualDatacenter.listAvailableTemplates(); - assertFalse(templates.isEmpty()); + protected void createVirtualMachine() { + List templates = virtualDatacenter.listAvailableTemplates(); + assertFalse(templates.isEmpty()); - // Sort by size to use the smallest one - Collections.sort(templates, new Ordering() - { - @Override - public int compare(final VirtualMachineTemplate left, final VirtualMachineTemplate right) - { - return Longs.compare(left.getDiskFileSize(), right.getDiskFileSize()); - } - }); + // Sort by size to use the smallest one + Collections.sort(templates, new Ordering() { + @Override + public int compare(final VirtualMachineTemplate left, final VirtualMachineTemplate right) { + return Longs.compare(left.getDiskFileSize(), right.getDiskFileSize()); + } + }); - template = templates.get(0); + template = templates.get(0); - virtualMachine = - VirtualMachine.builder(context.getApiContext(), virtualAppliance, template).cpu(2) - .nameLabel(PREFIX + "VM Aloha").ram(128).build(); + virtualMachine = VirtualMachine.builder(context.getApiContext(), virtualAppliance, template).cpu(2) + .nameLabel(PREFIX + "VM Aloha").ram(128).build(); - virtualMachine.save(); - assertNotNull(virtualMachine.getId()); + virtualMachine.save(); + assertNotNull(virtualMachine.getId()); - } + } - protected void refreshTemplateRepository() - { - defaultEnterprise.refreshTemplateRepository(datacenter); - } + protected void refreshTemplateRepository() { + defaultEnterprise.refreshTemplateRepository(datacenter); + } - // Tear down + // Tear down - private void closeUserContext() - { - plainUserContext.close(); - } + private void closeUserContext() { + plainUserContext.close(); + } - private void closeEnterpriseAdminContext() - { - enterpriseAdminContext.close(); - } + private void closeEnterpriseAdminContext() { + enterpriseAdminContext.close(); + } - protected void deleteVirtualDatacenter() - { - if (virtualDatacenter != null && enterprise != null && datacenter != null) - { - Integer idVirtualDatacenter = virtualDatacenter.getId(); - virtualDatacenter.delete(); - assertNull(cloudApi.getVirtualDatacenter(idVirtualDatacenter)); - } - } + protected void deleteVirtualDatacenter() { + if (virtualDatacenter != null && enterprise != null && datacenter != null) { + Integer idVirtualDatacenter = virtualDatacenter.getId(); + virtualDatacenter.delete(); + assertNull(cloudApi.getVirtualDatacenter(idVirtualDatacenter)); + } + } - protected void deleteVirtualAppliance() - { - if (virtualAppliance != null && virtualDatacenter != null) - { - Integer idVirtualAppliance = virtualAppliance.getId(); - virtualAppliance.delete(); - assertNull(cloudApi.getVirtualAppliance(virtualDatacenter.unwrap(), idVirtualAppliance)); - } - } + protected void deleteVirtualAppliance() { + if (virtualAppliance != null && virtualDatacenter != null) { + Integer idVirtualAppliance = virtualAppliance.getId(); + virtualAppliance.delete(); + assertNull(cloudApi.getVirtualAppliance(virtualDatacenter.unwrap(), idVirtualAppliance)); + } + } - protected void deleteVirtualMachine() - { - if (virtualMachine != null && virtualAppliance != null && virtualDatacenter != null) - { - Integer idVirtualMachine = virtualMachine.getId(); - virtualMachine.delete(); - assertNull(cloudApi.getVirtualMachine(virtualAppliance.unwrap(), idVirtualMachine)); - } + protected void deleteVirtualMachine() { + if (virtualMachine != null && virtualAppliance != null && virtualDatacenter != null) { + Integer idVirtualMachine = virtualMachine.getId(); + virtualMachine.delete(); + assertNull(cloudApi.getVirtualMachine(virtualAppliance.unwrap(), idVirtualMachine)); + } - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java index 17d9db6efa..2a68d3154b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/InfrastructureTestEnvironment.java @@ -75,198 +75,184 @@ import com.google.common.io.Resources; * * @author Ignasi Barrera */ -public class InfrastructureTestEnvironment implements TestEnvironment -{ - /** The rest context. */ - public AbiquoContext context; +public class InfrastructureTestEnvironment implements TestEnvironment { + /** The rest context. */ + public AbiquoContext context; - // Environment data made public so tests can use them easily + // Environment data made public so tests can use them easily - public AdministrationService administrationService; + public AdministrationService administrationService; - public InfrastructureApi infrastructureApi; + public InfrastructureApi infrastructureApi; - public EnterpriseApi enterpriseApi; + public EnterpriseApi enterpriseApi; - public AdminApi adminApi; + public AdminApi adminApi; - public ConfigApi configApi; + public ConfigApi configApi; - // Resources + // Resources - public License license; + public License license; - public Datacenter datacenter; + public Datacenter datacenter; - public PublicNetwork publicNetwork; + public PublicNetwork publicNetwork; - public ExternalNetwork externalNetwork; + public ExternalNetwork externalNetwork; - public UnmanagedNetwork unmanagedNetwork; + public UnmanagedNetwork unmanagedNetwork; - public List remoteServices; + public List remoteServices; - public Rack rack; + public Rack rack; - public Machine machine; + public Machine machine; - public Enterprise enterprise; + public Enterprise enterprise; - public StorageDevice storageDevice; + public StorageDevice storageDevice; - public StoragePool storagePool; + public StoragePool storagePool; - public Tier tier; + public Tier tier; - public User user; + public User user; - public User enterpriseAdmin; + public User enterpriseAdmin; - public Role role; + public Role role; - public Role anotherRole; + public Role anotherRole; - public ManagedRack ucsRack; + public ManagedRack ucsRack; - public InfrastructureTestEnvironment(final AbiquoContext context) - { - super(); - this.context = context; - this.administrationService = context.getAdministrationService(); - this.context = context; - this.enterpriseApi = context.getApiContext().getApi().getEnterpriseApi(); - this.infrastructureApi = context.getApiContext().getApi().getInfrastructureApi(); - this.adminApi = context.getApiContext().getApi().getAdminApi(); - this.configApi = context.getApiContext().getApi().getConfigApi(); - } + public InfrastructureTestEnvironment(final AbiquoContext context) { + super(); + this.context = context; + this.administrationService = context.getAdministrationService(); + this.context = context; + this.enterpriseApi = context.getApiContext().getApi().getEnterpriseApi(); + this.infrastructureApi = context.getApiContext().getApi().getInfrastructureApi(); + this.adminApi = context.getApiContext().getApi().getAdminApi(); + this.configApi = context.getApiContext().getApi().getConfigApi(); + } - @Override - public void setup() throws Exception - { - // Configuration - createLicense(); + @Override + public void setup() throws Exception { + // Configuration + createLicense(); - // Intrastructure - createDatacenter(); - createRack(); - createMachine(); - createStorageDevice(); - createStoragePool(); - createPublicNetwork(); + // Intrastructure + createDatacenter(); + createRack(); + createMachine(); + createStorageDevice(); + createStoragePool(); + createPublicNetwork(); - // Enterprise - createEnterprise(); - createRoles(); - createUsers(); + // Enterprise + createEnterprise(); + createRoles(); + createUsers(); - // Networking - createExternalNetwork(); - createUnmanagedNetwork(); - } + // Networking + createExternalNetwork(); + createUnmanagedNetwork(); + } - @Override - public void tearDown() throws Exception - { - deleteUsers(); + @Override + public void tearDown() throws Exception { + deleteUsers(); - deleteRole(role); - deleteRole(anotherRole); + deleteRole(role); + deleteRole(anotherRole); - deleteUnmanagedNetwork(); - deleteExternalNetwork(); - deletePublicNetwork(); - deleteStoragePool(); - deleteStorageDevice(); - deleteMachine(); - deleteUcsRack(); - deleteRack(); - deleteDatacenter(); - deleteEnterprise(); + deleteUnmanagedNetwork(); + deleteExternalNetwork(); + deletePublicNetwork(); + deleteStoragePool(); + deleteStorageDevice(); + deleteMachine(); + deleteUcsRack(); + deleteRack(); + deleteDatacenter(); + deleteEnterprise(); - deleteLicense(); - } + deleteLicense(); + } - // Setup + // Setup - protected void createLicense() throws IOException - { - license = License.builder(context.getApiContext(), readLicense()).build(); + protected void createLicense() throws IOException { + license = License.builder(context.getApiContext(), readLicense()).build(); - license.add(); - assertNotNull(license.getId()); - } + license.add(); + assertNotNull(license.getId()); + } - protected void createDatacenter() - { - // Assume a monolithic install - URI endpoint = URI.create(context.getApiContext().getProviderMetadata().getEndpoint()); - String remoteServicesAddress = endpoint.getHost(); + protected void createDatacenter() { + // Assume a monolithic install + URI endpoint = URI.create(context.getApiContext().getProviderMetadata().getEndpoint()); + String remoteServicesAddress = endpoint.getHost(); - datacenter = - Datacenter.builder(context.getApiContext()).name(randomName()).location("Honolulu") - .remoteServices(remoteServicesAddress, AbiquoEdition.ENTERPRISE).build(); - datacenter.save(); - assertNotNull(datacenter.getId()); + datacenter = Datacenter.builder(context.getApiContext()).name(randomName()).location("Honolulu") + .remoteServices(remoteServicesAddress, AbiquoEdition.ENTERPRISE).build(); + datacenter.save(); + assertNotNull(datacenter.getId()); - remoteServices = datacenter.listRemoteServices(); - assertEquals(remoteServices.size(), 7); - } + remoteServices = datacenter.listRemoteServices(); + assertEquals(remoteServices.size(), 7); + } - protected void createMachine() - { - String ip = Config.get("abiquo.hypervisor.address"); - HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); - String user = Config.get("abiquo.hypervisor.user"); - String pass = Config.get("abiquo.hypervisor.pass"); + protected void createMachine() { + String ip = Config.get("abiquo.hypervisor.address"); + HypervisorType type = HypervisorType.valueOf(Config.get("abiquo.hypervisor.type")); + String user = Config.get("abiquo.hypervisor.user"); + String pass = Config.get("abiquo.hypervisor.pass"); - machine = datacenter.discoverSingleMachine(ip, type, user, pass); + machine = datacenter.discoverSingleMachine(ip, type, user, pass); - String vswitch = - machine.findAvailableVirtualSwitch(Config.get("abiquo.hypervisor.vswitch")); - machine.setVirtualSwitch(vswitch); + String vswitch = machine.findAvailableVirtualSwitch(Config.get("abiquo.hypervisor.vswitch")); + machine.setVirtualSwitch(vswitch); - Datastore datastore = machine.findDatastore(Config.get("abiquo.hypervisor.datastore")); - datastore.setEnabled(true); + Datastore datastore = machine.findDatastore(Config.get("abiquo.hypervisor.datastore")); + datastore.setEnabled(true); - machine.setRack(rack); - machine.save(); - assertNotNull(machine.getId()); - } + machine.setRack(rack); + machine.save(); + assertNotNull(machine.getId()); + } - protected void createRack() - { - rack = Rack.builder(context.getApiContext(), datacenter).name(PREFIX + "Aloha").build(); - rack.save(); - assertNotNull(rack.getId()); - } + protected void createRack() { + rack = Rack.builder(context.getApiContext(), datacenter).name(PREFIX + "Aloha").build(); + rack.save(); + assertNotNull(rack.getId()); + } - public void createUcsRack() - { - String ip = Config.get("abiquo.ucs.address"); - Integer port = Integer.parseInt(Config.get("abiquo.ucs.port")); - String user = Config.get("abiquo.ucs.user"); - String pass = Config.get("abiquo.ucs.pass"); + public void createUcsRack() { + String ip = Config.get("abiquo.ucs.address"); + Integer port = Integer.parseInt(Config.get("abiquo.ucs.port")); + String user = Config.get("abiquo.ucs.user"); + String pass = Config.get("abiquo.ucs.pass"); - ucsRack = - ManagedRack.builder(context.getApiContext(), datacenter).ipAddress(ip).port(port) - .user(user).name("ucs rack").password(pass).build(); + ucsRack = ManagedRack.builder(context.getApiContext(), datacenter).ipAddress(ip).port(port).user(user) + .name("ucs rack").password(pass).build(); - ucsRack.save(); - assertNotNull(ucsRack.getId()); - } + ucsRack.save(); + assertNotNull(ucsRack.getId()); + } - protected void createStorageDevice() - { - String ip = Config.get("abiquo.storage.address"); - String type = Config.get("abiquo.storage.type"); - String user = Config.get("abiquo.storage.user"); - String pass = Config.get("abiquo.storage.pass"); + protected void createStorageDevice() { + String ip = Config.get("abiquo.storage.address"); + String type = Config.get("abiquo.storage.type"); + String user = Config.get("abiquo.storage.user"); + String pass = Config.get("abiquo.storage.pass"); - List devices = datacenter.listSupportedStorageDevices(); - StorageDeviceMetadata metadata = - Iterables.find(devices, StorageDeviceMetadataPredicates.type(type)); + List devices = datacenter.listSupportedStorageDevices(); + StorageDeviceMetadata metadata = Iterables.find(devices, StorageDeviceMetadataPredicates.type(type)); - storageDevice = StorageDevice.builder(context.getApiContext(), datacenter) // + storageDevice = StorageDevice.builder(context.getApiContext(), datacenter) // .name(PREFIX + "Storage Device")// .type(type)// .managementIp(ip).managementPort(metadata.getDefaultManagementPort())// @@ -275,257 +261,211 @@ public class InfrastructureTestEnvironment implements TestEnvironment .password(pass) // .build(); - storageDevice.save(); - assertNotNull(storageDevice.getId()); - } + storageDevice.save(); + assertNotNull(storageDevice.getId()); + } - protected void createStoragePool() - { - String pool = Config.get("abiquo.storage.pool"); + protected void createStoragePool() { + String pool = Config.get("abiquo.storage.pool"); - storagePool = storageDevice.findRemoteStoragePool(StoragePoolPredicates.name(pool)); - tier = datacenter.findTier(TierPredicates.name("Default Tier 1")); + storagePool = storageDevice.findRemoteStoragePool(StoragePoolPredicates.name(pool)); + tier = datacenter.findTier(TierPredicates.name("Default Tier 1")); - storagePool.setTier(tier); - storagePool.save(); + storagePool.setTier(tier); + storagePool.save(); - assertNotNull(storagePool.getUUID()); - } + assertNotNull(storagePool.getUUID()); + } - protected void createUsers() - { - Role userRole = administrationService.findRole(RolePredicates.name("USER")); - Role enterpriseAdminRole = - administrationService.findRole(RolePredicates.name("ENTERPRISE_ADMIN")); + protected void createUsers() { + Role userRole = administrationService.findRole(RolePredicates.name("USER")); + Role enterpriseAdminRole = administrationService.findRole(RolePredicates.name("ENTERPRISE_ADMIN")); - user = - User.builder(context.getApiContext(), enterprise, userRole) - .name(randomName(), randomName()).nick("jclouds").authType("ABIQUO") - .description(randomName()).email(randomName() + "@abiquo.com").locale("en_US") - .password("user").build(); + user = User.builder(context.getApiContext(), enterprise, userRole).name(randomName(), randomName()) + .nick("jclouds").authType("ABIQUO").description(randomName()).email(randomName() + "@abiquo.com") + .locale("en_US").password("user").build(); - user.save(); - assertNotNull(user.getId()); - assertEquals(userRole.getId(), user.getRole().getId()); + user.save(); + assertNotNull(user.getId()); + assertEquals(userRole.getId(), user.getRole().getId()); - enterpriseAdmin = - User.builder(context.getApiContext(), enterprise, enterpriseAdminRole) - .name(randomName(), randomName()).nick("jclouds-admin").authType("ABIQUO") - .description(randomName()).email(randomName() + "@abiquo.com").locale("en_US") - .password("admin").build(); + enterpriseAdmin = User.builder(context.getApiContext(), enterprise, enterpriseAdminRole) + .name(randomName(), randomName()).nick("jclouds-admin").authType("ABIQUO").description(randomName()) + .email(randomName() + "@abiquo.com").locale("en_US").password("admin").build(); - enterpriseAdmin.save(); - assertNotNull(enterpriseAdmin.getId()); - assertEquals(enterpriseAdminRole.getId(), enterpriseAdmin.getRole().getId()); - } + enterpriseAdmin.save(); + assertNotNull(enterpriseAdmin.getId()); + assertEquals(enterpriseAdminRole.getId(), enterpriseAdmin.getRole().getId()); + } - protected void createRoles() - { - role = Role.builder(context.getApiContext()).name(randomName()).blocked(false).build(); - role.save(); + protected void createRoles() { + role = Role.builder(context.getApiContext()).name(randomName()).blocked(false).build(); + role.save(); - anotherRole = Role.Builder.fromRole(role).build(); - anotherRole.setName("Another role"); - anotherRole.save(); + anotherRole = Role.Builder.fromRole(role).build(); + anotherRole.setName("Another role"); + anotherRole.save(); - assertNotNull(role.getId()); - assertNotNull(anotherRole.getId()); - } + assertNotNull(role.getId()); + assertNotNull(anotherRole.getId()); + } - protected void createEnterprise() - { - enterprise = Enterprise.builder(context.getApiContext()).name(randomName()).build(); - enterprise.save(); - assertNotNull(enterprise.getId()); - Limits limits = enterprise.allowDatacenter(datacenter); - assertNotNull(limits); - } + protected void createEnterprise() { + enterprise = Enterprise.builder(context.getApiContext()).name(randomName()).build(); + enterprise.save(); + assertNotNull(enterprise.getId()); + Limits limits = enterprise.allowDatacenter(datacenter); + assertNotNull(limits); + } - protected void createPublicNetwork() - { - publicNetwork = - PublicNetwork.builder(context.getApiContext(), datacenter).name("PublicNetwork") - .gateway("80.80.80.1").address("80.80.80.0").mask(24).tag(5).build(); - publicNetwork.save(); - assertNotNull(publicNetwork.getId()); - } + protected void createPublicNetwork() { + publicNetwork = PublicNetwork.builder(context.getApiContext(), datacenter).name("PublicNetwork") + .gateway("80.80.80.1").address("80.80.80.0").mask(24).tag(5).build(); + publicNetwork.save(); + assertNotNull(publicNetwork.getId()); + } - protected void createExternalNetwork() - { - externalNetwork = - ExternalNetwork.builder(context.getApiContext(), datacenter, enterprise) - .name("ExternalNetwork").gateway("10.0.0.1").address("10.0.0.0").mask(24).tag(7) - .build(); - externalNetwork.save(); - assertNotNull(externalNetwork.getId()); - } + protected void createExternalNetwork() { + externalNetwork = ExternalNetwork.builder(context.getApiContext(), datacenter, enterprise) + .name("ExternalNetwork").gateway("10.0.0.1").address("10.0.0.0").mask(24).tag(7).build(); + externalNetwork.save(); + assertNotNull(externalNetwork.getId()); + } - protected void createUnmanagedNetwork() - { - unmanagedNetwork = - UnmanagedNetwork.builder(context.getApiContext(), datacenter, enterprise) - .name("UnmanagedNetwork").gateway("10.0.1.1").address("10.0.1.0").mask(24).tag(8) - .build(); - unmanagedNetwork.save(); - assertNotNull(unmanagedNetwork.getId()); - } + protected void createUnmanagedNetwork() { + unmanagedNetwork = UnmanagedNetwork.builder(context.getApiContext(), datacenter, enterprise) + .name("UnmanagedNetwork").gateway("10.0.1.1").address("10.0.1.0").mask(24).tag(8).build(); + unmanagedNetwork.save(); + assertNotNull(unmanagedNetwork.getId()); + } - // Tear down + // Tear down - protected void deleteUnmanagedNetwork() - { - if (unmanagedNetwork != null) - { - Integer id = unmanagedNetwork.getId(); - unmanagedNetwork.delete(); - assertNull(datacenter.getNetwork(id)); - } - } + protected void deleteUnmanagedNetwork() { + if (unmanagedNetwork != null) { + Integer id = unmanagedNetwork.getId(); + unmanagedNetwork.delete(); + assertNull(datacenter.getNetwork(id)); + } + } - protected void deleteExternalNetwork() - { - if (externalNetwork != null) - { - Integer id = externalNetwork.getId(); - externalNetwork.delete(); - assertNull(datacenter.getNetwork(id)); - } - } + protected void deleteExternalNetwork() { + if (externalNetwork != null) { + Integer id = externalNetwork.getId(); + externalNetwork.delete(); + assertNull(datacenter.getNetwork(id)); + } + } - protected void deletePublicNetwork() - { - if (publicNetwork != null) - { - Integer id = publicNetwork.getId(); - publicNetwork.delete(); - assertNull(datacenter.getNetwork(id)); - } - } + protected void deletePublicNetwork() { + if (publicNetwork != null) { + Integer id = publicNetwork.getId(); + publicNetwork.delete(); + assertNull(datacenter.getNetwork(id)); + } + } - protected void deleteUsers() - { - if (user != null) - { - String nick = user.getNick(); - user.delete(); - // Nick is unique in an enterprise - assertNull(enterprise.findUser(UserPredicates.nick(nick))); - } + protected void deleteUsers() { + if (user != null) { + String nick = user.getNick(); + user.delete(); + // Nick is unique in an enterprise + assertNull(enterprise.findUser(UserPredicates.nick(nick))); + } - if (enterpriseAdmin != null) - { - String nick = enterpriseAdmin.getNick(); - enterpriseAdmin.delete(); - // Nick is unique in an enterprise - assertNull(enterprise.findUser(UserPredicates.nick(nick))); - } - } + if (enterpriseAdmin != null) { + String nick = enterpriseAdmin.getNick(); + enterpriseAdmin.delete(); + // Nick is unique in an enterprise + assertNull(enterprise.findUser(UserPredicates.nick(nick))); + } + } - protected void deleteRole(final Role role) - { - if (role != null) - { - Integer roleId = role.getId(); - role.delete(); - assertNull(adminApi.getRole(roleId)); - } - } + protected void deleteRole(final Role role) { + if (role != null) { + Integer roleId = role.getId(); + role.delete(); + assertNull(adminApi.getRole(roleId)); + } + } - protected void deleteStoragePool() - { - if (storagePool != null) - { - String idStoragePool = storagePool.getUUID(); - storagePool.delete(); - assertNull(infrastructureApi.getStoragePool(storageDevice.unwrap(), idStoragePool)); - } + protected void deleteStoragePool() { + if (storagePool != null) { + String idStoragePool = storagePool.getUUID(); + storagePool.delete(); + assertNull(infrastructureApi.getStoragePool(storageDevice.unwrap(), idStoragePool)); + } - } + } - protected void deleteStorageDevice() - { - if (storageDevice != null) - { - Integer idStorageDevice = storageDevice.getId(); - storageDevice.delete(); - assertNull(infrastructureApi.getStorageDevice(datacenter.unwrap(), idStorageDevice)); - } - } + protected void deleteStorageDevice() { + if (storageDevice != null) { + Integer idStorageDevice = storageDevice.getId(); + storageDevice.delete(); + assertNull(infrastructureApi.getStorageDevice(datacenter.unwrap(), idStorageDevice)); + } + } - protected void deleteMachine() - { - if (machine != null && rack != null) - { - Integer idMachine = machine.getId(); - machine.delete(); - assertNull(infrastructureApi.getMachine(rack.unwrap(), idMachine)); - } - } + protected void deleteMachine() { + if (machine != null && rack != null) { + Integer idMachine = machine.getId(); + machine.delete(); + assertNull(infrastructureApi.getMachine(rack.unwrap(), idMachine)); + } + } - protected void deleteRack() - { - if (rack != null && datacenter != null) - { - Integer idRack = rack.getId(); - rack.delete(); - assertNull(infrastructureApi.getRack(datacenter.unwrap(), idRack)); - } - } + protected void deleteRack() { + if (rack != null && datacenter != null) { + Integer idRack = rack.getId(); + rack.delete(); + assertNull(infrastructureApi.getRack(datacenter.unwrap(), idRack)); + } + } - protected void deleteUcsRack() - { - if (ucsRack != null && datacenter != null) - { - Integer idRack = ucsRack.getId(); - ucsRack.delete(); - assertNull(infrastructureApi.getManagedRack(datacenter.unwrap(), idRack)); - } - } + protected void deleteUcsRack() { + if (ucsRack != null && datacenter != null) { + Integer idRack = ucsRack.getId(); + ucsRack.delete(); + assertNull(infrastructureApi.getManagedRack(datacenter.unwrap(), idRack)); + } + } - protected void deleteDatacenter() - { - if (datacenter != null) - { - // Remove limits first - enterprise.prohibitDatacenter(datacenter); + protected void deleteDatacenter() { + if (datacenter != null) { + // Remove limits first + enterprise.prohibitDatacenter(datacenter); - Integer idDatacenter = datacenter.getId(); - datacenter.delete(); // Abiquo API will delete remote services too - assertNull(infrastructureApi.getDatacenter(idDatacenter)); - } - } + Integer idDatacenter = datacenter.getId(); + datacenter.delete(); // Abiquo API will delete remote services too + assertNull(infrastructureApi.getDatacenter(idDatacenter)); + } + } - protected void deleteEnterprise() - { - if (enterprise != null) - { - Integer idEnterprise = enterprise.getId(); - enterprise.delete(); - assertNull(enterpriseApi.getEnterprise(idEnterprise)); - } - } + protected void deleteEnterprise() { + if (enterprise != null) { + Integer idEnterprise = enterprise.getId(); + enterprise.delete(); + assertNull(enterpriseApi.getEnterprise(idEnterprise)); + } + } - protected void deleteLicense() - { - license.remove(); - } + protected void deleteLicense() { + license.remove(); + } - protected static String randomName() - { - return PREFIX + UUID.randomUUID().toString().substring(0, 12); - } + protected static String randomName() { + return PREFIX + UUID.randomUUID().toString().substring(0, 12); + } - // Utility methods + // Utility methods - public static String readLicense() throws IOException - { - URL url = CloudTestEnvironment.class.getResource("/license/expired"); + public static String readLicense() throws IOException { + URL url = CloudTestEnvironment.class.getResource("/license/expired"); - return Resources.toString(url, Charset.defaultCharset()); - } + return Resources.toString(url, Charset.defaultCharset()); + } - public RemoteService findRemoteService(final RemoteServiceType type) - { - return find(remoteServices, RemoteServicePredicates.type(type)); - } + public RemoteService findRemoteService(final RemoteServiceType type) { + return find(remoteServices, RemoteServicePredicates.type(type)); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/TestEnvironment.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/TestEnvironment.java index 5f74ddb479..53426fa32e 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/TestEnvironment.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/environment/TestEnvironment.java @@ -22,19 +22,19 @@ package org.jclouds.abiquo.environment; /** * Base class fot test environment populators. *

- * This class should be used to populate and clean the test environment used in live tests. + * This class should be used to populate and clean the test environment used in + * live tests. * * @author Ignasi Barrera */ -public interface TestEnvironment -{ - /** - * Builds the test environment. - */ - public void setup() throws Exception; +public interface TestEnvironment { + /** + * Builds the test environment. + */ + public void setup() throws Exception; - /** - * Cleans the test environment. - */ - public void tearDown() throws Exception; + /** + * Cleans the test environment. + */ + public void tearDown() throws Exception; } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java index 181157ff49..87f45229eb 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/events/handlers/BlockingEventHandlerTest.java @@ -36,90 +36,77 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BlockingEventHandlerTest") -public class BlockingEventHandlerTest -{ - @Test(expectedExceptions = IllegalArgumentException.class) - public void testConstructorWithoutObjects() - { - new BlockingEventHandler(); - } +public class BlockingEventHandlerTest { + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithoutObjects() { + new BlockingEventHandler(); + } - @Test(expectedExceptions = NullPointerException.class) - public void testConstructorWithNullObjects() - { - new BlockingEventHandler((Object[]) null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testConstructorWithNullObjects() { + new BlockingEventHandler((Object[]) null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testConstructorWithtEmptyObjects() - { - new BlockingEventHandler(new Object[] {}); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithtEmptyObjects() { + new BlockingEventHandler(new Object[] {}); + } - public void testHandles() - { - Object object = new Object(); - BlockingEventHandler handler = new BlockingEventHandler(object); + public void testHandles() { + Object object = new Object(); + BlockingEventHandler handler = new BlockingEventHandler(object); - assertTrue(handler.handles(new MonitorEvent(Type.COMPLETED, object))); - assertFalse(handler.handles(new MonitorEvent(Type.COMPLETED, new Object()))); - } + assertTrue(handler.handles(new MonitorEvent(Type.COMPLETED, object))); + assertFalse(handler.handles(new MonitorEvent(Type.COMPLETED, new Object()))); + } - public void testReleaseDoesNothingIfNotLocked() - { - Object object = new Object(); - BlockingEventHandler handler = new BlockingEventHandler(object); - handler.release(object); - } + public void testReleaseDoesNothingIfNotLocked() { + Object object = new Object(); + BlockingEventHandler handler = new BlockingEventHandler(object); + handler.release(object); + } - public void testRelease() - { - final Object object = new Object(); - final BlockingEventHandler handler = new BlockingEventHandler(object); + public void testRelease() { + final Object object = new Object(); + final BlockingEventHandler handler = new BlockingEventHandler(object); - // Unlock the handler (in a separate thread) after a certain delay - Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() - { - @Override - public void run() - { - handler.release(object); - assertTrue(handler.lockedObjects.isEmpty()); - } + // Unlock the handler (in a separate thread) after a certain delay + Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { + @Override + public void run() { + handler.release(object); + assertTrue(handler.lockedObjects.isEmpty()); + } - }, 500L, TimeUnit.MILLISECONDS); + }, 500L, TimeUnit.MILLISECONDS); - handler.lock(); - } + handler.lock(); + } - public void testHandle() - { - final Object object = new Object(); - final BlockingEventHandler handler = new BlockingEventHandler(object); + public void testHandle() { + final Object object = new Object(); + final BlockingEventHandler handler = new BlockingEventHandler(object); - // Unlock the handler (in a separate thread) after a certain delay - Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() - { - @Override - public void run() - { - handler.handle(new MonitorEvent(Type.COMPLETED, object)); - assertTrue(handler.lockedObjects.isEmpty()); - } + // Unlock the handler (in a separate thread) after a certain delay + Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() { + @Override + public void run() { + handler.handle(new MonitorEvent(Type.COMPLETED, object)); + assertTrue(handler.lockedObjects.isEmpty()); + } - }, 500L, TimeUnit.MILLISECONDS); + }, 500L, TimeUnit.MILLISECONDS); - handler.lock(); - } + handler.lock(); + } - public void testLockDoesNothingIfNoObjects() - { - Object object = new Object(); - BlockingEventHandler handler = new BlockingEventHandler(object); - handler.lockedObjects.clear(); + public void testLockDoesNothingIfNoObjects() { + Object object = new Object(); + BlockingEventHandler handler = new BlockingEventHandler(object); + handler.lockedObjects.clear(); - handler.lock(); // Lock should do nothing + handler.lock(); // Lock should do nothing - assertNull(handler.completeSignal); - } + assertNull(handler.completeSignal); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java index 03021b6d0e..a1be6aa19f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java @@ -46,151 +46,137 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "AdminAsyncApiTest") -public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Role ***********************/ +public class AdminAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Role ***********************/ - public void testListRoles() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("listRoles"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListRoles() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("listRoles"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/admin/roles HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RolesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/roles HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RolesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetRoleFromUser() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("getRole", UserDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.userPut()); + public void testGetRoleFromUser() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("getRole", UserDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut()); - assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("createRole", RoleDto.class); - GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePost()); + public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("createRole", RoleDto.class); + GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePost()); - assertRequestLineEquals(request, "POST http://localhost/api/admin/roles HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(AdminResources.rolePostPayload()), RoleDto.class, + assertRequestLineEquals(request, "POST http://localhost/api/admin/roles HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(AdminResources.rolePostPayload()), RoleDto.class, RoleDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteRole() throws SecurityException, NoSuchMethodException - { - Method method = AdminAsyncApi.class.getMethod("deleteRole", RoleDto.class); - GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); + public void testDeleteRole() throws SecurityException, NoSuchMethodException { + Method method = AdminAsyncApi.class.getMethod("deleteRole", RoleDto.class); + GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); - assertRequestLineEquals(request, "DELETE http://localhost/api/admin/roles/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/roles/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("updateRole", RoleDto.class); - GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); + public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("updateRole", RoleDto.class); + GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); - assertRequestLineEquals(request, "PUT http://localhost/api/admin/roles/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(AdminResources.rolePutPayload()), RoleDto.class, - RoleDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/roles/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(AdminResources.rolePutPayload()), RoleDto.class, RoleDto.BASE_MEDIA_TYPE, + false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetRoleById() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("getRole", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetRoleById() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("getRole", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RoleDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListPrivilegesByRoles() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = AdminAsyncApi.class.getMethod("listPrivileges", RoleDto.class); - GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); + public void testListPrivilegesByRoles() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("listPrivileges", RoleDto.class); + GeneratedHttpRequest request = processor.createRequest(method, AdminResources.rolePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/roles/1/action/privileges HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/roles/1/action/privileges HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Current User **********************/ + /*********************** Current User **********************/ - public void testGetCurrentUser() throws SecurityException, NoSuchMethodException, IOException - { - Method method = AdminAsyncApi.class.getMethod("getCurrentUser"); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetCurrentUser() throws SecurityException, NoSuchMethodException, IOException { + Method method = AdminAsyncApi.class.getMethod("getCurrentUser"); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/login HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/login HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoAsyncApiTest.java index 9308fbbbb5..561418f602 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/BaseAbiquoAsyncApiTest.java @@ -44,57 +44,49 @@ import com.google.inject.Module; * * @author Ignasi Barrera */ -public abstract class BaseAbiquoAsyncApiTest extends BaseAsyncClientTest -{ - private XMLParser xml; +public abstract class BaseAbiquoAsyncApiTest extends BaseAsyncClientTest { + private XMLParser xml; - @BeforeClass - @Override - protected void setupFactory() throws IOException - { - super.setupFactory(); - xml = injector.getInstance(XMLParser.class); - } + @BeforeClass + @Override + protected void setupFactory() throws IOException { + super.setupFactory(); + xml = injector.getInstance(XMLParser.class); + } - @Override - protected void checkFilters(final HttpRequest request) - { - assertEquals(request.getFilters().size(), 2); - assertEquals(request.getFilters().get(0).getClass(), AbiquoAuthentication.class); - assertEquals(request.getFilters().get(1).getClass(), AppendApiVersionToMediaType.class); - } + @Override + protected void checkFilters(final HttpRequest request) { + assertEquals(request.getFilters().size(), 2); + assertEquals(request.getFilters().get(0).getClass(), AbiquoAuthentication.class); + assertEquals(request.getFilters().get(1).getClass(), AppendApiVersionToMediaType.class); + } - @Override - protected Module createModule() - { - return new AbiquoRestClientModule(); - } + @Override + protected Module createModule() { + return new AbiquoRestClientModule(); + } - @Override - protected ProviderMetadata createProviderMetadata() - { - return AnonymousProviderMetadata.forApiWithEndpoint(new AbiquoApiMetadata(), - "http://localhost/api"); - } + @Override + protected ProviderMetadata createProviderMetadata() { + return AnonymousProviderMetadata.forApiWithEndpoint(new AbiquoApiMetadata(), "http://localhost/api"); + } - @Override - protected Properties setupProperties() - { - Properties props = super.setupProperties(); - // Do not pretty print payloads in tests - props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "false"); - return props; - } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + // Do not pretty print payloads in tests + props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "false"); + return props; + } - protected void assertPayloadEquals(final HttpRequest request, final String toMatch, - final Class< ? extends SingleResourceTransportDto> entityClass, final String contentType, - final boolean contentMD5) throws IOException - { - // Make sure we don't have formatting issues - SingleResourceTransportDto entity = xml.fromXML(toMatch, entityClass); - String stringToMatch = xml.toXML(entity, entityClass); + protected void assertPayloadEquals(final HttpRequest request, final String toMatch, + final Class entityClass, final String contentType, + final boolean contentMD5) throws IOException { + // Make sure we don't have formatting issues + SingleResourceTransportDto entity = xml.fromXML(toMatch, entityClass); + String stringToMatch = xml.toXML(entity, entityClass); - super.assertPayloadEquals(request, stringToMatch, contentType, contentMD5); - } + super.assertPayloadEquals(request, stringToMatch, contentType, contentMD5); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java index 13fc5b93bd..9405b0b908 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java @@ -87,1509 +87,1176 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "CloudAsyncApiTest") -public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Virtual Datacenter ***********************/ +public class CloudAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Virtual Datacenter ***********************/ - public void testListVirtualDatacentersParams() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, VirtualDatacenterOptions.builder().datacenterId(1) - .enterpriseId(1).build()); + public void testListVirtualDatacentersParams() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, VirtualDatacenterOptions.builder().datacenterId(1) + .enterpriseId(1).build()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters?datacenter=1&enterprise=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualDatacentersNoParams() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, VirtualDatacenterOptions.builder().build()); + public void testListVirtualDatacentersNoParams() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVirtualDatacenters", VirtualDatacenterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, VirtualDatacenterOptions.builder().build()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateVirtualDatacenter() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("createVirtualDatacenter", VirtualDatacenterDto.class, - DatacenterDto.class, EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPost(), - InfrastructureResources.datacenterPut(), EnterpriseResources.enterprisePut()); + public void testCreateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createVirtualDatacenter", VirtualDatacenterDto.class, + DatacenterDto.class, EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPost(), + InfrastructureResources.datacenterPut(), EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters?enterprise=1&datacenter=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterPostPayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterPostPayload()), VirtualDatacenterDto.class, VirtualDatacenterDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualDatacenter() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = CloudAsyncApi.class.getMethod("getVirtualDatacenter", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualDatacenter", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVirtualDatacenter() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("updateVirtualDatacenter", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testUpdateVirtualDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updateVirtualDatacenter", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterPutPayload()), + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterPutPayload()), VirtualDatacenterDto.class, VirtualDatacenterDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteVirtualDatacenter() throws SecurityException, NoSuchMethodException - { - Method method = - CloudAsyncApi.class.getMethod("deleteVirtualDatacenter", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testDeleteVirtualDatacenter() throws SecurityException, NoSuchMethodException { + Method method = CloudAsyncApi.class.getMethod("deleteVirtualDatacenter", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Ips ***********************/ + /*********************** Ips ***********************/ - public void testListAvailablePublicIpsWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - IpOptions options = IpOptions.builder().limit(5).build(); - Method method = - CloudAsyncApi.class.getMethod("listAvailablePublicIps", VirtualDatacenterDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), options); + public void testListAvailablePublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().limit(5).build(); + Method method = CloudAsyncApi.class.getMethod("listAvailablePublicIps", VirtualDatacenterDto.class, + IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/publicips/topurchase?limit=5 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListPurchasedPublicIpsWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - IpOptions options = IpOptions.builder().limit(5).build(); - Method method = - CloudAsyncApi.class.getMethod("listPurchasedPublicIps", VirtualDatacenterDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), options); + public void testListPurchasedPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().limit(5).build(); + Method method = CloudAsyncApi.class.getMethod("listPurchasedPublicIps", VirtualDatacenterDto.class, + IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/publicips/purchased?limit=5 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testPurchasePublicIp() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("purchasePublicIp", PublicIpDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicIpToPurchase()); + public void testPurchasePublicIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("purchasePublicIp", PublicIpDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicIpToPurchase()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/5/publicips/purchased/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testReleasePublicIp() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("releasePublicIp", PublicIpDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicIpToRelease()); + public void testReleasePublicIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("releasePublicIp", PublicIpDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicIpToRelease()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/5/publicips/topurchase/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Available templates ***********************/ + /*********************** Available templates ***********************/ - public void testListAvailableTemplates() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListAvailableTemplates() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListAvailableTemplatesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class, - VirtualMachineTemplateOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - VirtualMachineTemplateOptions.builder().hypervisorType(HypervisorType.XENSERVER) - .categoryName("Firewalls").idTemplate(1).build()); + public void testListAvailableTemplatesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listAvailableTemplates", VirtualDatacenterDto.class, + VirtualMachineTemplateOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + VirtualMachineTemplateOptions.builder().hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls") + .idTemplate(1).build()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates" - + "?hypervisorTypeName=XENSERVER&categoryName=Firewalls&idTemplate=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/action/templates" + + "?hypervisorTypeName=XENSERVER&categoryName=Firewalls&idTemplate=1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Storage Tiers ***********************/ + /*********************** Storage Tiers ***********************/ - public void testListStorageTiers() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("listStorageTiers", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListStorageTiers() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listStorageTiers", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/tiers HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TiersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + TiersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetStorageTier() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("getStorageTier", VirtualDatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); + public void testGetStorageTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getStorageTier", VirtualDatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/tiers/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/tiers/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testGetDefaultNetwork() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getDefaultNetwork", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testGetDefaultNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getDefaultNetwork", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testSetDefaultNetworkInternal() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - NetworkResources.privateNetworkPut()); + public void testSetDefaultNetworkInternal() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + NetworkResources.privateNetworkPut()); - RESTLink netLink = NetworkResources.privateNetworkPut().getEditLink(); + RESTLink netLink = NetworkResources.privateNetworkPut().getEditLink(); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/action/defaultvlan HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, - false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testSetDefaultNetworkExternal() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - NetworkResources.externalNetworkPut()); + public void testSetDefaultNetworkExternal() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("setDefaultNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + NetworkResources.externalNetworkPut()); - RESTLink netLink = NetworkResources.externalNetworkPut().getEditLink(); + RESTLink netLink = NetworkResources.externalNetworkPut().getEditLink(); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/action/defaultvlan HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, - false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Private Network ***********************/ + /*********************** Private Network ***********************/ - public void testListPrivateNetworks() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listPrivateNetworks", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListPrivateNetworks() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listPrivateNetworks", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPrivateNetwork() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getPrivateNetwork", VirtualDatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); + public void testGetPrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getPrivateNetwork", VirtualDatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreatePrivateNetwork() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("createPrivateNetwork", VirtualDatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - NetworkResources.vlanPost()); + public void testCreatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createPrivateNetwork", VirtualDatacenterDto.class, + VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + NetworkResources.vlanPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(NetworkResources.vlanNetworkPostPayload()), - VLANNetworkDto.class, VLANNetworkDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/privatenetworks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(NetworkResources.vlanNetworkPostPayload()), VLANNetworkDto.class, + VLANNetworkDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdatePrivateNetwork() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = CloudAsyncApi.class.getMethod("updatePrivateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.privateNetworkPut()); + public void testUpdatePrivateNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updatePrivateNetwork", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(NetworkResources.privateNetworkPutPayload()), - VLANNetworkDto.class, VLANNetworkDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(NetworkResources.privateNetworkPutPayload()), VLANNetworkDto.class, + VLANNetworkDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeletePrivateNetwork() throws SecurityException, NoSuchMethodException - { - Method method = CloudAsyncApi.class.getMethod("deletePrivateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.privateNetworkPut()); + public void testDeletePrivateNetwork() throws SecurityException, NoSuchMethodException { + Method method = CloudAsyncApi.class.getMethod("deletePrivateNetwork", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Private Network IPs ***********************/ + /*********************** Private Network IPs ***********************/ - public void testListPrivateNetworkIps() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.privateNetworkPut()); + public void testListPrivateNetworkIps() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListPrivateNetworkIpsWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - IpOptions options = IpOptions.builder().startWith(10).build(); - Method method = - CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.privateNetworkPut(), options); + public void testListPrivateNetworkIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().startWith(10).build(); + Method method = CloudAsyncApi.class.getMethod("listPrivateNetworkIps", VLANNetworkDto.class, IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips?startwith=10 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPrivateNetworkIp() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getPrivateNetworkIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.privateNetworkPut(), 1); + public void testGetPrivateNetworkIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getPrivateNetworkIp", VLANNetworkDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.privateNetworkPut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/privatenetworks/1/ips/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivateIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Virtual Appliance ***********************/ + /*********************** Virtual Appliance ***********************/ - public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVirtualAppliances", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVirtualAppliances", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualAppliance() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualAppliance", VirtualDatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); + public void testGetVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualAppliance", VirtualDatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualApplianceState() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualApplianceState", VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut()); + public void testGetVirtualApplianceState() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualApplianceState", VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/state HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceStateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateVirtualAppliance() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("createVirtualAppliance", VirtualDatacenterDto.class, - VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - CloudResources.virtualAppliancePost()); + public void testCreateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createVirtualAppliance", VirtualDatacenterDto.class, + VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + CloudResources.virtualAppliancePost()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualAppliancePostPayload()), - VirtualApplianceDto.class, VirtualApplianceDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualAppliancePostPayload()), VirtualApplianceDto.class, + VirtualApplianceDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVirtualAppliance() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("updateVirtualAppliance", VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut()); + public void testUpdateVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updateVirtualAppliance", VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualAppliancePutPayload()), - VirtualApplianceDto.class, VirtualApplianceDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualApplianceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualAppliancePutPayload()), VirtualApplianceDto.class, + VirtualApplianceDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteVirtualAppliance() throws SecurityException, NoSuchMethodException - { - Method method = - CloudAsyncApi.class.getMethod("deleteVirtualAppliance", VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut()); + public void testDeleteVirtualAppliance() throws SecurityException, NoSuchMethodException { + Method method = CloudAsyncApi.class.getMethod("deleteVirtualAppliance", VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeployVirtualAppliance() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("deployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut(), - CloudResources.deployOptions()); + public void testDeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("deployVirtualAppliance", VirtualApplianceDto.class, + VirtualMachineTaskDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), + CloudResources.deployOptions()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.deployPayload()), - VirtualMachineTaskDto.class, VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.deployPayload()), VirtualMachineTaskDto.class, + VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUndeployVirtualAppliance() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("undeployVirtualAppliance", VirtualApplianceDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut(), - CloudResources.undeployOptions()); + public void testUndeployVirtualAppliance() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("undeployVirtualAppliance", VirtualApplianceDto.class, + VirtualMachineTaskDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), + CloudResources.undeployOptions()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.undeployPayload()), - VirtualMachineTaskDto.class, VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.undeployPayload()), VirtualMachineTaskDto.class, + VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualAppliancePrice() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualAppliancePrice", VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut()); + public void testGetVirtualAppliancePrice() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualAppliancePrice", VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/action/price HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MediaType.TEXT_PLAIN + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + MediaType.TEXT_PLAIN + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Virtual Machine ***********************/ + /*********************** Virtual Machine ***********************/ - public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut()); + public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualMachinesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class, - VirtualMachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut(), - VirtualMachineOptions.builder().disablePagination().build()); + public void testListVirtualMachinesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVirtualMachines", VirtualApplianceDto.class, + VirtualMachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), + VirtualMachineOptions.builder().disablePagination().build()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines?limit=0 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualMachine", VirtualApplianceDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut(), 1); + public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualMachine", VirtualApplianceDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), 1); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("createVirtualMachine", VirtualApplianceDto.class, - VirtualMachineWithNodeExtendedDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualAppliancePut(), - CloudResources.virtualMachinePost()); + public void testCreateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createVirtualMachine", VirtualApplianceDto.class, + VirtualMachineWithNodeExtendedDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualAppliancePut(), + CloudResources.virtualMachinePost()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePostPayload()), - VirtualMachineWithNodeExtendedDto.class, - VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePostPayload()), + VirtualMachineWithNodeExtendedDto.class, VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("updateVirtualMachine", - VirtualMachineWithNodeExtendedDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePutPayload()), - VirtualMachineWithNodeExtendedDto.class, - VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePutPayload()), + VirtualMachineWithNodeExtendedDto.class, VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVirtualMachineWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("updateVirtualMachine", - VirtualMachineWithNodeExtendedDto.class, VirtualMachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - VirtualMachineOptions.builder().force(true).build()); + public void testUpdateVirtualMachineWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updateVirtualMachine", VirtualMachineWithNodeExtendedDto.class, + VirtualMachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + VirtualMachineOptions.builder().force(true).build()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1?force=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePutPayload()), - VirtualMachineWithNodeExtendedDto.class, - VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualMachinePutPayload()), + VirtualMachineWithNodeExtendedDto.class, VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testChangeVirtualMachineState() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("changeVirtualMachineState", VirtualMachineDto.class, - VirtualMachineStateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - CloudResources.virtualMachineState()); + public void testChangeVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("changeVirtualMachineState", VirtualMachineDto.class, + VirtualMachineStateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + CloudResources.virtualMachineState()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualMachineStatePayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualMachineStatePayload()), VirtualMachineStateDto.class, VirtualMachineStateDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteVirtualMachine() throws SecurityException, NoSuchMethodException - { - Method method = - CloudAsyncApi.class.getMethod("deleteVirtualMachine", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testDeleteVirtualMachine() throws SecurityException, NoSuchMethodException { + Method method = CloudAsyncApi.class.getMethod("deleteVirtualMachine", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualMachineState() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualMachineState", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testGetVirtualMachineState() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualMachineState", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/state HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineStateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("deployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - CloudResources.deployOptions()); + public void testDeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("deployVirtualMachine", VirtualMachineDto.class, + VirtualMachineTaskDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + CloudResources.deployOptions()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.deployPayload()), - VirtualMachineTaskDto.class, VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.deployPayload()), VirtualMachineTaskDto.class, + VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUndeployVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("undeployVirtualMachine", VirtualMachineDto.class, - VirtualMachineTaskDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - CloudResources.undeployOptions()); + public void testUndeployVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("undeployVirtualMachine", VirtualMachineDto.class, + VirtualMachineTaskDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + CloudResources.undeployOptions()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.undeployPayload()), - VirtualMachineTaskDto.class, VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.undeployPayload()), VirtualMachineTaskDto.class, + VirtualMachineTaskDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("rebootVirtualMachine", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("rebootVirtualMachine", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/action/reset HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListNetworkConfigurations() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listNetworkConfigurations", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testListNetworkConfigurations() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listNetworkConfigurations", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( + assertRequestLineEquals( request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VMNetworkConfigurationsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VMNetworkConfigurationsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("setGatewayNetwork", VirtualMachineDto.class, - VLANNetworkDto.class); + public void testSetGatewayNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("setGatewayNetwork", VirtualMachineDto.class, VLANNetworkDto.class); - VirtualMachineDto vm = CloudResources.virtualMachinePut(); - VLANNetworkDto network = NetworkResources.privateNetworkPut(); + VirtualMachineDto vm = CloudResources.virtualMachinePut(); + VLANNetworkDto network = NetworkResources.privateNetworkPut(); - GeneratedHttpRequest request = processor.createRequest(method, vm, network); + GeneratedHttpRequest request = processor.createRequest(method, vm, network); - String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId(); + String configLink = vm.searchLink("configurations").getHref() + "/" + network.getId(); - assertRequestLineEquals( + assertRequestLineEquals( request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/network/configurations HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, withHeader(""), LinksDto.class, - LinksDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Virtual Machine Template ***********************/ + /*********************** Virtual Machine Template ***********************/ - public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVirtualMachineTemplate", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVirtualMachineTemplate", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListAttachedVolumes() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listAttachedVolumes", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testListAttachedVolumes() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listAttachedVolumes", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDetachAllVolumes() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("detachAllVolumes", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testDetachAllVolumes() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("detachAllVolumes", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testReplaceVolumes() throws SecurityException, NoSuchMethodException, IOException - { - VolumeManagementDto first = CloudResources.volumePut(); - VolumeManagementDto second = CloudResources.volumePut(); - second.getEditLink().setHref(second.getEditLink().getHref() + "second"); + public void testReplaceVolumes() throws SecurityException, NoSuchMethodException, IOException { + VolumeManagementDto first = CloudResources.volumePut(); + VolumeManagementDto second = CloudResources.volumePut(); + second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - Method method = - CloudAsyncApi.class.getMethod("replaceVolumes", VirtualMachineDto.class, - VirtualMachineOptions.class, VolumeManagementDto[].class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - VirtualMachineOptions.builder().force(true).build(), new VolumeManagementDto[] { - first, second}); + Method method = CloudAsyncApi.class.getMethod("replaceVolumes", VirtualMachineDto.class, + VirtualMachineOptions.class, VolumeManagementDto[].class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + VirtualMachineOptions.builder().force(true).build(), new VolumeManagementDto[] { first, second }); - String editLink = CloudResources.volumePut().getEditLink().getHref(); - assertRequestLineEquals( + String editLink = CloudResources.volumePut().getEditLink().getHref(); + assertRequestLineEquals( request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/volumes?force=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(""), - LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListAttachedHardDisks() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listAttachedHardDisks", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testListAttachedHardDisks() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listAttachedHardDisks", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DisksManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + DisksManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDetachAllHardDisks() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("detachAllHardDisks", VirtualMachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testDetachAllHardDisks() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("detachAllHardDisks", VirtualMachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testReplaceHardDisks() throws SecurityException, NoSuchMethodException, IOException - { - DiskManagementDto first = CloudResources.hardDiskPut(); - DiskManagementDto second = CloudResources.hardDiskPut(); - second.getEditLink().setHref(second.getEditLink().getHref() + "second"); + public void testReplaceHardDisks() throws SecurityException, NoSuchMethodException, IOException { + DiskManagementDto first = CloudResources.hardDiskPut(); + DiskManagementDto second = CloudResources.hardDiskPut(); + second.getEditLink().setHref(second.getEditLink().getHref() + "second"); - Method method = - CloudAsyncApi.class.getMethod("replaceHardDisks", VirtualMachineDto.class, - DiskManagementDto[].class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut(), - new DiskManagementDto[] {first, second}); + Method method = CloudAsyncApi.class.getMethod("replaceHardDisks", VirtualMachineDto.class, + DiskManagementDto[].class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut(), + new DiskManagementDto[] { first, second }); - String editLink = CloudResources.hardDiskPut().getEditLink().getHref(); - assertRequestLineEquals( - request, + String editLink = CloudResources.hardDiskPut().getEditLink().getHref(); + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/storage/disks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(""), - LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(""), LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Hard disks ***********************/ + /*********************** Hard disks ***********************/ - public void testListHardDisks() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("listHardDisks", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListHardDisks() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listHardDisks", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DisksManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DisksManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetHardDisk() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("getHardDisk", VirtualDatacenterDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); + public void testGetHardDisk() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getHardDisk", VirtualDatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateHardDisk() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("createHardDisk", VirtualDatacenterDto.class, - DiskManagementDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - CloudResources.hardDiskPost()); + public void testCreateHardDisk() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createHardDisk", VirtualDatacenterDto.class, + DiskManagementDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + CloudResources.hardDiskPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.hardDiskPostPayload()), - DiskManagementDto.class, DiskManagementDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/disks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DiskManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.hardDiskPostPayload()), DiskManagementDto.class, + DiskManagementDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteHardDisk() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("deleteHardDisk", DiskManagementDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.hardDiskPut()); + public void testDeleteHardDisk() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("deleteHardDisk", DiskManagementDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.hardDiskPut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/disks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Volumes ***********************/ + /*********************** Volumes ***********************/ - public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut()); + public void testListVolumes() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVolumesWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, - VolumeOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), VolumeOptions - .builder().onlyAvailable(true).build()); + public void testListVolumesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + VolumeOptions.builder().onlyAvailable(true).build()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes?available=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVolumesWithFilterOptions() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, - VolumeOptions.class); + public void testListVolumesWithFilterOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("listVolumes", VirtualDatacenterDto.class, VolumeOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), VolumeOptions - .builder().has("vol").orderBy(OrderBy.NAME).ascendant(true).build()); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + VolumeOptions.builder().has("vol").orderBy(OrderBy.NAME).ascendant(true).build()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes?has=vol&by=name&asc=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumesManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("getVolume", VirtualDatacenterDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); + public void testGetVolume() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("getVolume", VirtualDatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("createVolume", VirtualDatacenterDto.class, - VolumeManagementDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualDatacenterPut(), - CloudResources.volumePost()); + public void testCreateVolume() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("createVolume", VirtualDatacenterDto.class, + VolumeManagementDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualDatacenterPut(), + CloudResources.volumePost()); - assertRequestLineEquals(request, - "POST http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.volumePostPayload()), - VolumeManagementDto.class, VolumeManagementDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/volumes HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VolumeManagementDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.volumePostPayload()), VolumeManagementDto.class, + VolumeManagementDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVolume() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("updateVolume", VolumeManagementDto.class); - GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut()); + public void testUpdateVolume() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("updateVolume", VolumeManagementDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.volumePutPayload()), - VolumeManagementDto.class, VolumeManagementDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.volumePutPayload()), VolumeManagementDto.class, + VolumeManagementDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException - { - Method method = CloudAsyncApi.class.getMethod("deleteVolume", VolumeManagementDto.class); - GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut()); + public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class.getMethod("deleteVolume", VolumeManagementDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/cloud/virtualdatacenters/1/volumes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testMoveVolume() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - CloudAsyncApi.class.getMethod("moveVolume", VolumeManagementDto.class, - VirtualDatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.volumePut(), - CloudResources.virtualDatacenterPut()); + public void testMoveVolume() throws SecurityException, NoSuchMethodException, IOException { + Method method = CloudAsyncApi.class + .getMethod("moveVolume", VolumeManagementDto.class, VirtualDatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.volumePut(), + CloudResources.virtualDatacenterPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/cloud/virtualdatacenters/1/volumes/1/action/move HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MovedVolumeDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterRefPayload()), - LinksDto.class, LinksDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + MovedVolumeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(CloudResources.virtualDatacenterRefPayload()), LinksDto.class, + LinksDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnMovedVolume.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnMovedVolume.class); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java index 0352472bc1..816bd59dee 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java @@ -51,267 +51,233 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "ConfigAsyncApiTest") -public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** License ***********************/ +public class ConfigAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** License ***********************/ - public void testListLicenses() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("listLicenses"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListLicenses() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listLicenses"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/config/licenses HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/licenses HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListLicenseWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = ConfigAsyncApi.class.getMethod("listLicenses", LicenseOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, LicenseOptions.builder().active(true).build()); + public void testListLicenseWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listLicenses", LicenseOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, LicenseOptions.builder().active(true).build()); - assertRequestLineEquals(request, - "GET http://localhost/api/config/licenses?active=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/licenses?active=true HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + LicensesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testAddLicense() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("addLicense", LicenseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.licensePost()); + public void testAddLicense() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("addLicense", LicenseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.licensePost()); - assertRequestLineEquals(request, "POST http://localhost/api/config/licenses HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LicenseDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(ConfigResources.licensePostPayload()), - LicenseDto.class, LicenseDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/config/licenses HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + LicenseDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(ConfigResources.licensePostPayload()), LicenseDto.class, + LicenseDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testRemoveLicense() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("removeLicense", LicenseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.licensePut()); + public void testRemoveLicense() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("removeLicense", LicenseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.licensePut()); - assertRequestLineEquals(request, "DELETE http://localhost/api/config/licenses/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/config/licenses/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Privilege ***********************/ + /*********************** Privilege ***********************/ - public void testListPrivileges() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("listPrivileges"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListPrivileges() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listPrivileges"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/config/privileges HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/privileges HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPrivilege() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("getPrivilege", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetPrivilege() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("getPrivilege", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/config/privileges/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegeDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/privileges/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PrivilegeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - /*********************** System Properties ***********************/ + /*********************** System Properties ***********************/ - public void testListSystemProperties() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = ConfigAsyncApi.class.getMethod("listSystemProperties"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListSystemProperties() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listSystemProperties"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/config/properties HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/properties HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListSystemPropertiesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - ConfigAsyncApi.class.getMethod("listSystemProperties", PropertyOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, PropertyOptions.builder().component("api").build()); + public void testListSystemPropertiesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listSystemProperties", PropertyOptions.class); + GeneratedHttpRequest request = processor + .createRequest(method, PropertyOptions.builder().component("api").build()); - assertRequestLineEquals(request, - "GET http://localhost/api/config/properties?component=api HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/properties?component=api HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertiesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateSystemProperty() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - ConfigAsyncApi.class.getMethod("updateSystemProperty", SystemPropertyDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.propertyPut()); + public void testUpdateSystemProperty() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("updateSystemProperty", SystemPropertyDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.propertyPut()); - assertRequestLineEquals(request, "PUT http://localhost/api/config/properties/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertyDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(ConfigResources.propertyPutPayload()), - SystemPropertyDto.class, SystemPropertyDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/config/properties/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + SystemPropertyDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(ConfigResources.propertyPutPayload()), SystemPropertyDto.class, + SystemPropertyDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Category ***********************/ + /*********************** Category ***********************/ - public void testListCategories() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("listCategories"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListCategories() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("listCategories"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/config/categories HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CategoriesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/categories HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CategoriesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetCategory() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("getCategory", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetCategory() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("getCategory", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/config/categories/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/categories/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateCategory() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("createCategory", CategoryDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.categoryPost()); + public void testCreateCategory() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("createCategory", CategoryDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPost()); - assertRequestLineEquals(request, "POST http://localhost/api/config/categories HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(ConfigResources.categoryPostPayload()), - CategoryDto.class, CategoryDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/config/categories HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(ConfigResources.categoryPostPayload()), CategoryDto.class, + CategoryDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateCategory() throws SecurityException, NoSuchMethodException, IOException - { - Method method = ConfigAsyncApi.class.getMethod("updateCategory", CategoryDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.categoryPut()); + public void testUpdateCategory() throws SecurityException, NoSuchMethodException, IOException { + Method method = ConfigAsyncApi.class.getMethod("updateCategory", CategoryDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPut()); - assertRequestLineEquals(request, "PUT http://localhost/api/config/categories/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(ConfigResources.categoryPutPayload()), - CategoryDto.class, CategoryDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/config/categories/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CategoryDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(ConfigResources.categoryPutPayload()), CategoryDto.class, + CategoryDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteCategory() throws SecurityException, NoSuchMethodException - { - Method method = ConfigAsyncApi.class.getMethod("deleteCategory", CategoryDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, ConfigResources.categoryPut()); + public void testDeleteCategory() throws SecurityException, NoSuchMethodException { + Method method = ConfigAsyncApi.class.getMethod("deleteCategory", CategoryDto.class); + GeneratedHttpRequest request = processor.createRequest(method, ConfigResources.categoryPut()); - assertRequestLineEquals(request, "DELETE http://localhost/api/config/categories/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/config/categories/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java index 2a6a79caf9..a38cbc7c32 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java @@ -63,745 +63,599 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "EnterpriseAsyncApiTest") -public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Enterprise ********************** */ +public class EnterpriseAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Enterprise ********************** */ - public void testListEnterprises() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListEnterprises() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListEnterprisesWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - EnterpriseOptions options = - EnterpriseOptions.builder().has("abi").orderBy(OrderBy.NAME).ascendant(true).build(); + public void testListEnterprisesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseOptions options = EnterpriseOptions.builder().has("abi").orderBy(OrderBy.NAME).ascendant(true).build(); - Method method = - EnterpriseAsyncApi.class.getMethod("listEnterprises", EnterpriseOptions.class); - GeneratedHttpRequest request = processor.createRequest(method, options); + Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises", EnterpriseOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, options); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises?has=abi&by=name&asc=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises?has=abi&by=name&asc=true HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListEnterprisesByDatacenter() throws SecurityException, NoSuchMethodException, - IOException - { - EnterpriseOptions options = - EnterpriseOptions.builder().startWith(0).limit(25).network(true).build(); + public void testListEnterprisesByDatacenter() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseOptions options = EnterpriseOptions.builder().startWith(0).limit(25).network(true).build(); - Method method = - EnterpriseAsyncApi.class.getMethod("listEnterprises", DatacenterDto.class, - EnterpriseOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), options); + Method method = EnterpriseAsyncApi.class.getMethod("listEnterprises", DatacenterDto.class, + EnterpriseOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), options); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/action/enterprises?network=true&startwith=0&limit=25 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateEnterprise() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("createEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePost()); + public void testCreateEnterprise() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("createEnterprise", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePost()); - assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.enterprisePostPayload()), - EnterpriseDto.class, EnterpriseDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.enterprisePostPayload()), EnterpriseDto.class, + EnterpriseDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetEnterprise() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("getEnterprise", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetEnterprise() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("getEnterprise", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateEnterprise() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("updateEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testUpdateEnterprise() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("updateEnterprise", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.enterprisePutPayload()), - EnterpriseDto.class, EnterpriseDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterpriseDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.enterprisePutPayload()), EnterpriseDto.class, + EnterpriseDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteEnterprise() throws SecurityException, NoSuchMethodException - { - Method method = EnterpriseAsyncApi.class.getMethod("deleteEnterprise", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testDeleteEnterprise() throws SecurityException, NoSuchMethodException { + Method method = EnterpriseAsyncApi.class.getMethod("deleteEnterprise", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListAllowedDatacenters() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("listAllowedDatacenters", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testListAllowedDatacenters() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listAllowedDatacenters", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters?idEnterprise=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters?idEnterprise=1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualDatacentersFromEnterprise() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listVirtualDatacenters", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListVirtualDatacentersFromEnterprise() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listVirtualDatacenters", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualdatacenters HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualDatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Enterprise Properties ********************** */ + /*********************** Enterprise Properties ********************** */ - public void testGetEnterpriseProperties() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("getEnterpriseProperties", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testGetEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("getEnterpriseProperties", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateEnterpriseProperties() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("updateEnterpriseProperties", - EnterprisePropertiesDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePropertiesPut()); + public void testUpdateEnterpriseProperties() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("updateEnterpriseProperties", EnterprisePropertiesDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePropertiesPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, - withHeader(EnterpriseResources.enterprisePropertiesPutPayload()), + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/properties HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EnterprisePropertiesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.enterprisePropertiesPutPayload()), EnterprisePropertiesDto.class, EnterprisePropertiesDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Enterprise Limits ********************** */ + /*********************** Enterprise Limits ********************** */ - public void testCreateLimits() throws SecurityException, NoSuchMethodException, IOException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - DatacenterDto datacenter = InfrastructureResources.datacenterPut(); - DatacenterLimitsDto limits = EnterpriseResources.datacenterLimitsPost(); + public void testCreateLimits() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + DatacenterDto datacenter = InfrastructureResources.datacenterPut(); + DatacenterLimitsDto limits = EnterpriseResources.datacenterLimitsPost(); - Method method = - EnterpriseAsyncApi.class.getMethod("createLimits", EnterpriseDto.class, - DatacenterDto.class, DatacenterLimitsDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, enterprise, datacenter, limits); + Method method = EnterpriseAsyncApi.class.getMethod("createLimits", EnterpriseDto.class, DatacenterDto.class, + DatacenterLimitsDto.class); + GeneratedHttpRequest request = processor.createRequest(method, enterprise, datacenter, limits); - String limitsUri = enterprise.searchLink("limits").getHref(); - String requestURI = - String.format("POST %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId()); + String limitsUri = enterprise.searchLink("limits").getHref(); + String requestURI = String.format("POST %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId()); - assertRequestLineEquals(request, requestURI); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterLimitsDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.datacenterLimitsPostPayload()), + assertRequestLineEquals(request, requestURI); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterLimitsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.datacenterLimitsPostPayload()), DatacenterLimitsDto.class, DatacenterLimitsDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetLimits() throws SecurityException, NoSuchMethodException, IOException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - DatacenterDto datacenter = InfrastructureResources.datacenterPut(); + public void testGetLimits() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + DatacenterDto datacenter = InfrastructureResources.datacenterPut(); - Method method = - EnterpriseAsyncApi.class.getMethod("getLimits", EnterpriseDto.class, - DatacenterDto.class); - GeneratedHttpRequest request = processor.createRequest(method, enterprise, datacenter); + Method method = EnterpriseAsyncApi.class.getMethod("getLimits", EnterpriseDto.class, DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, enterprise, datacenter); - String limitsUri = enterprise.searchLink("limits").getHref(); - String requestURI = - String.format("GET %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId()); + String limitsUri = enterprise.searchLink("limits").getHref(); + String requestURI = String.format("GET %s?datacenter=%d HTTP/1.1", limitsUri, datacenter.getId()); - assertRequestLineEquals(request, requestURI); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, requestURI); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateLimits() throws SecurityException, NoSuchMethodException, IOException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + public void testUpdateLimits() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - Method method = - EnterpriseAsyncApi.class.getMethod("updateLimits", DatacenterLimitsDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.datacenterLimitsPut(enterprise)); + Method method = EnterpriseAsyncApi.class.getMethod("updateLimits", DatacenterLimitsDto.class); + GeneratedHttpRequest request = processor.createRequest(method, + EnterpriseResources.datacenterLimitsPut(enterprise)); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterLimitsDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, - withHeader(EnterpriseResources.datacenterLimitsPutPayload(enterprise)), + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterLimitsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.datacenterLimitsPutPayload(enterprise)), DatacenterLimitsDto.class, DatacenterLimitsDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteLimits() throws SecurityException, NoSuchMethodException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + public void testDeleteLimits() throws SecurityException, NoSuchMethodException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - Method method = - EnterpriseAsyncApi.class.getMethod("deleteLimits", DatacenterLimitsDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.datacenterLimitsPut(enterprise)); + Method method = EnterpriseAsyncApi.class.getMethod("deleteLimits", DatacenterLimitsDto.class); + GeneratedHttpRequest request = processor.createRequest(method, + EnterpriseResources.datacenterLimitsPut(enterprise)); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/limits/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListLimitsEnterprise() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("listLimits", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListLimitsEnterprise() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listLimits", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/limits HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** User ***********************/ + /*********************** User ***********************/ - public void testGetUser() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("getUser", EnterpriseDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut(), 1); + public void testGetUser() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("getUser", EnterpriseDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListUsers() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("listUsers", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListUsers() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listUsers", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/users HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UsersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UsersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateUser() throws SecurityException, NoSuchMethodException, IOException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - UserDto user = EnterpriseResources.userPost(); + public void testCreateUser() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + UserDto user = EnterpriseResources.userPost(); - Method method = - EnterpriseAsyncApi.class.getMethod("createUser", EnterpriseDto.class, UserDto.class); - GeneratedHttpRequest request = processor.createRequest(method, enterprise, user); + Method method = EnterpriseAsyncApi.class.getMethod("createUser", EnterpriseDto.class, UserDto.class); + GeneratedHttpRequest request = processor.createRequest(method, enterprise, user); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/enterprises/1/users HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.userPostPayload()), - UserDto.class, UserDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/users HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.userPostPayload()), UserDto.class, + UserDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateUser() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("updateUser", UserDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.userPut()); + public void testUpdateUser() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("updateUser", UserDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.userPutPayload()), - UserDto.class, UserDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UserDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.userPutPayload()), UserDto.class, + UserDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteUser() throws SecurityException, NoSuchMethodException - { - Method method = EnterpriseAsyncApi.class.getMethod("deleteUser", UserDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.userPut()); + public void testDeleteUser() throws SecurityException, NoSuchMethodException { + Method method = EnterpriseAsyncApi.class.getMethod("deleteUser", UserDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/users/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualMachinesByUser() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = EnterpriseAsyncApi.class.getMethod("listVirtualMachines", UserDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.userPut()); + public void testListVirtualMachinesByUser() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listVirtualMachines", UserDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.userPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Datacenter Repository ********************** */ + /*********************** Datacenter Repository ********************** */ - public void testGetDatacenterRepository() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("getDatacenterRepository", EnterpriseDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut(), - InfrastructureResources.datacenterPut().getId()); + public void testGetDatacenterRepository() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("getDatacenterRepository", EnterpriseDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), + InfrastructureResources.datacenterPut().getId()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterRepositoryDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterRepositoryDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testRefreshTemplateRepository() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("refreshTemplateRepository", Integer.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut().getId(), - InfrastructureResources.datacenterPut().getId()); + public void testRefreshTemplateRepository() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("refreshTemplateRepository", Integer.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut().getId(), + InfrastructureResources.datacenterPut().getId()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/datacenterrepositories/1/actions/refresh HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** External Network ********************** */ + /*********************** External Network ********************** */ - public void testListExternalNetworks() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listExternalNetworks", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListExternalNetworks() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listExternalNetworks", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/action/externalnetworks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/externalnetworks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Cloud ********************** */ + /*********************** Cloud ********************** */ - public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listVirtualMachines", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listVirtualMachines", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/action/virtualmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualmachines HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listVirtualAppliances", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListVirtualAppliances() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listVirtualAppliances", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/action/virtualappliances HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/action/virtualappliances HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualAppliancesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Machine ********************** */ + /*********************** Machine ********************** */ - public void testListReservedMachines() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listReservedMachines", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListReservedMachines() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listReservedMachines", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Template definition list ***********************/ + /*********************** Template definition list ***********************/ - public void testListTemplateDefinitionLists() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listTemplateDefinitionLists", EnterpriseDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut()); + public void testListTemplateDefinitionLists() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listTemplateDefinitionLists", EnterpriseDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + TemplateDefinitionListsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TemplateDefinitionListsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, - IOException - { - EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); - TemplateDefinitionListDto template = EnterpriseResources.templateListPost(); + public void testCreateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { + EnterpriseDto enterprise = EnterpriseResources.enterprisePut(); + TemplateDefinitionListDto template = EnterpriseResources.templateListPost(); - Method method = - EnterpriseAsyncApi.class.getMethod("createTemplateDefinitionList", EnterpriseDto.class, - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = processor.createRequest(method, enterprise, template); + Method method = EnterpriseAsyncApi.class.getMethod("createTemplateDefinitionList", EnterpriseDto.class, + TemplateDefinitionListDto.class); + GeneratedHttpRequest request = processor.createRequest(method, enterprise, template); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.templateListPostPayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.templateListPostPayload()), TemplateDefinitionListDto.class, TemplateDefinitionListDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, - IOException - { - TemplateDefinitionListDto template = EnterpriseResources.templateListPut(); + public void testUpdateTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { + TemplateDefinitionListDto template = EnterpriseResources.templateListPut(); - Method method = - EnterpriseAsyncApi.class.getMethod("updateTemplateDefinitionList", - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = processor.createRequest(method, template); + Method method = EnterpriseAsyncApi.class.getMethod("updateTemplateDefinitionList", + TemplateDefinitionListDto.class); + GeneratedHttpRequest request = processor.createRequest(method, template); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(EnterpriseResources.templateListPutPayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(EnterpriseResources.templateListPutPayload()), TemplateDefinitionListDto.class, TemplateDefinitionListDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteTemplateDefinitionList() throws SecurityException, NoSuchMethodException - { - Method method = - EnterpriseAsyncApi.class.getMethod("deleteTemplateDefinitionList", - TemplateDefinitionListDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.templateListPut()); + public void testDeleteTemplateDefinitionList() throws SecurityException, NoSuchMethodException { + Method method = EnterpriseAsyncApi.class.getMethod("deleteTemplateDefinitionList", + TemplateDefinitionListDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.templateListPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetTemplateDefinitionList() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("getTemplateDefinitionList", EnterpriseDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut(), 1); + public void testGetTemplateDefinitionList() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("getTemplateDefinitionList", EnterpriseDto.class, + Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TemplateDefinitionListDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListTemplateListStatus() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - EnterpriseAsyncApi.class.getMethod("listTemplateListStatus", - TemplateDefinitionListDto.class, DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.templateListPut(), - InfrastructureResources.datacenterPut()); + public void testListTemplateListStatus() throws SecurityException, NoSuchMethodException, IOException { + Method method = EnterpriseAsyncApi.class.getMethod("listTemplateListStatus", TemplateDefinitionListDto.class, + DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.templateListPut(), + InfrastructureResources.datacenterPut()); - assertRequestLineEquals( + assertRequestLineEquals( request, "GET http://localhost/api/admin/enterprises/1/appslib/templateDefinitionLists/1/actions/repositoryStatus?datacenterId=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TemplatesStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TemplatesStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java index bd837ff141..5934affe84 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java @@ -37,29 +37,25 @@ import com.google.inject.TypeLiteral; * @author Vivien Mahé */ @Test(groups = "unit", testName = "EventAsyncApiTest") -public class EventAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - public void testListEvents() throws SecurityException, NoSuchMethodException, IOException - { - Method method = EventAsyncApi.class.getMethod("listEvents"); - GeneratedHttpRequest request = processor.createRequest(method); +public class EventAsyncApiTest extends BaseAbiquoAsyncApiTest { + public void testListEvents() throws SecurityException, NoSuchMethodException, IOException { + Method method = EventAsyncApi.class.getMethod("listEvents"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/events HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + EventsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/events HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + EventsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/FeatureCoverageTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/FeatureCoverageTest.java index 5215f0fd6a..a7193ca9d2 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/FeatureCoverageTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/FeatureCoverageTest.java @@ -44,78 +44,60 @@ import com.google.common.collect.Iterables; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "FeatureCoverageTest") -public class FeatureCoverageTest -{ - /** A collection with all async api classes. */ - private Collection> featureClasses; +public class FeatureCoverageTest { + /** A collection with all async api classes. */ + private Collection> featureClasses; - @BeforeMethod - public void setup() - { - featureClasses = new ArrayList>(); - featureClasses.addAll(AbiquoRestClientModule.DELEGATE_MAP.values()); - featureClasses.add(AbiquoHttpAsyncClient.class); - } + @BeforeMethod + public void setup() { + featureClasses = new ArrayList>(); + featureClasses.addAll(AbiquoRestClientModule.DELEGATE_MAP.values()); + featureClasses.add(AbiquoHttpAsyncClient.class); + } - public void testAllFeaturesHaveTest() throws ClassNotFoundException - { - List missingTests = new ArrayList(); + public void testAllFeaturesHaveTest() throws ClassNotFoundException { + List missingTests = new ArrayList(); - for (Class< ? > featureClass : featureClasses) - { - try - { - Class< ? > testClass = loadTestClass(featureClass); - Iterable testMethodNames = methodNames(testClass); + for (Class featureClass : featureClasses) { + try { + Class testClass = loadTestClass(featureClass); + Iterable testMethodNames = methodNames(testClass); - for (Method method : featureClass.getMethods()) - { - if (!hasTest(testMethodNames, method)) - { - missingTests.add(method.getDeclaringClass().getSimpleName() + "." - + method.getName()); - } - } + for (Method method : featureClass.getMethods()) { + if (!hasTest(testMethodNames, method)) { + missingTests.add(method.getDeclaringClass().getSimpleName() + "." + method.getName()); + } } - catch (ClassNotFoundException ex) - { - fail("Missing tests for class: " + featureClass.getName()); - } - } + } catch (ClassNotFoundException ex) { + fail("Missing tests for class: " + featureClass.getName()); + } + } - assertTrue(missingTests.isEmpty(), "Missing tests: " + Joiner.on(", ").join(missingTests)); - } + assertTrue(missingTests.isEmpty(), "Missing tests: " + Joiner.on(", ").join(missingTests)); + } - private Class< ? > loadTestClass(final Class< ? > featureClass) throws ClassNotFoundException - { - String testClassName = featureClass.getName() + "Test"; - return Thread.currentThread().getContextClassLoader().loadClass(testClassName); - } + private Class loadTestClass(final Class featureClass) throws ClassNotFoundException { + String testClassName = featureClass.getName() + "Test"; + return Thread.currentThread().getContextClassLoader().loadClass(testClassName); + } - private static Iterable methodNames(final Class< ? > clazz) - { - return Iterables.transform(Arrays.asList(clazz.getMethods()), - new Function() - { - @Override - public String apply(final Method input) - { - return input.getName(); - } - }); - } + private static Iterable methodNames(final Class clazz) { + return Iterables.transform(Arrays.asList(clazz.getMethods()), new Function() { + @Override + public String apply(final Method input) { + return input.getName(); + } + }); + } - private static boolean hasTest(final Iterable testMethodNames, final Method method) - { - String testMethod = Iterables.find(testMethodNames, new Predicate() - { - @Override - public boolean apply(final String input) - { - return input.toLowerCase().contains(method.getName().toLowerCase()); - } - }, null); + private static boolean hasTest(final Iterable testMethodNames, final Method method) { + String testMethod = Iterables.find(testMethodNames, new Predicate() { + @Override + public boolean apply(final String input) { + return input.toLowerCase().contains(method.getName().toLowerCase()); + } + }, null); - return testMethod != null; - } + return testMethod != null; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java index ab5b294af7..de782c849a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java @@ -98,2040 +98,1634 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "InfrastructureAsyncApiTest") -public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Datacenter ***********************/ +public class InfrastructureAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Datacenter ***********************/ - public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listDatacenters"); - GeneratedHttpRequest request = processor.createRequest(method); + public void testListDatacenters() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listDatacenters"); + GeneratedHttpRequest request = processor.createRequest(method); - assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateDatacenter() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPost()); + public void testCreateDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createDatacenter", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPost()); - assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.datacenterPostPayload()), - DatacenterDto.class, DatacenterDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.datacenterPostPayload()), DatacenterDto.class, + DatacenterDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetDatacenter() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("getDatacenter", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getDatacenter", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateDatacenter() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testUpdateDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateDatacenter", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.datacenterPutPayload()), - DatacenterDto.class, DatacenterDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacenterDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.datacenterPutPayload()), DatacenterDto.class, + DatacenterDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteDatacenter() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteDatacenter", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testDeleteDatacenter() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteDatacenter", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListLimitsDatacenter() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listLimits", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListLimitsDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listLimits", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/action/getLimits HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/action/getLimits HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersLimitsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Hypervisor ***********************/ + /*********************** Hypervisor ***********************/ - public void testGetHypervisorTypeFromMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getHypervisorTypeFromMachine", - DatacenterDto.class, DatacenterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - DatacenterOptions.builder().ip("10.60.1.120").build()); + public void testGetHypervisorTypeFromMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getHypervisorTypeFromMachine", DatacenterDto.class, + DatacenterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + DatacenterOptions.builder().ip("10.60.1.120").build()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/action/hypervisor?ip=10.60.1.120 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MediaType.TEXT_PLAIN + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + MediaType.TEXT_PLAIN + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnStringIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetHypervisorTypesFromDatacenter() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getHypervisorTypes", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testGetHypervisorTypesFromDatacenter() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getHypervisorTypes", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/hypervisors HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + HypervisorTypesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/hypervisors HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + HypervisorTypesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Managed Rack ***********************/ + /*********************** Managed Rack ***********************/ - public void testListRacks() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listRacks", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListRacks() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listRacks", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RacksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RacksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateRack() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class - .getMethod("createRack", DatacenterDto.class, RackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - InfrastructureResources.rackPost()); + public void testCreateRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createRack", DatacenterDto.class, RackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + InfrastructureResources.rackPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.rackPostPayload()), - RackDto.class, RackDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.rackPostPayload()), RackDto.class, + RackDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetRack() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getRack", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + public void testGetRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getRack", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateRack() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("updateRack", RackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.rackPut()); + public void testUpdateRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateRack", RackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.rackPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.rackPutPayload()), - RackDto.class, RackDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.rackPutPayload()), RackDto.class, + RackDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteRack() throws SecurityException, NoSuchMethodException - { - Method method = InfrastructureAsyncApi.class.getMethod("deleteRack", RackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.rackPut()); + public void testDeleteRack() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteRack", RackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.rackPut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Managed Rack ***********************/ + /*********************** Managed Rack ***********************/ - public void testListManagedRacks() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listManagedRacks", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListManagedRacks() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listManagedRacks", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UcsRacksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UcsRacksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateManagedRack() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createManagedRack", DatacenterDto.class, - UcsRackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - InfrastructureResources.managedRackPost()); + public void testCreateManagedRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class + .getMethod("createManagedRack", DatacenterDto.class, UcsRackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + InfrastructureResources.managedRackPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPostPayload()), - UcsRackDto.class, UcsRackDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPostPayload()), UcsRackDto.class, + UcsRackDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetManagedRack() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getManagedRack", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + public void testGetManagedRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getManagedRack", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateManagedRack() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateManagedRack", UcsRackDto.class); + public void testUpdateManagedRack() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateManagedRack", UcsRackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut()); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPutPayload()), - UcsRackDto.class, UcsRackDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + UcsRackDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.managedRackPutPayload()), UcsRackDto.class, + UcsRackDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListServiceProfiles() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut()); + public void testListServiceProfiles() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListServiceProfilesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - FilterOptions options = FilterOptions.builder().startWith(1).limit(2).build(); + public void testListServiceProfilesWithOptions() throws SecurityException, NoSuchMethodException, IOException { + FilterOptions options = FilterOptions.builder().startWith(1).limit(2).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), options); + Method method = InfrastructureAsyncApi.class.getMethod("listServiceProfiles", UcsRackDto.class, + FilterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/logicservers?startwith=1&limit=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListOrganizations() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listOrganizations", UcsRackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut()); + public void testListOrganizations() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listOrganizations", UcsRackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/organizations HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/organizations HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListOrganizationsWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - FilterOptions options = FilterOptions.builder().has("org").build(); + public void testListOrganizationsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + FilterOptions options = FilterOptions.builder().has("org").build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listOrganizations", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), options); + Method method = InfrastructureAsyncApi.class + .getMethod("listOrganizations", UcsRackDto.class, FilterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/organizations?has=org HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + OrganizationsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListServiceProfileTemplates() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut()); + public void testListServiceProfileTemplates() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListServiceProfileTemplatesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - FilterOptions options = FilterOptions.builder().ascendant(true).build(); + public void testListServiceProfileTemplatesWithOptions() throws SecurityException, NoSuchMethodException, + IOException { + FilterOptions options = FilterOptions.builder().ascendant(true).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class, - FilterOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), options); + Method method = InfrastructureAsyncApi.class.getMethod("listServiceProfileTemplates", UcsRackDto.class, + FilterOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/lstemplates?asc=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + LogicServersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testAssociateLogicServer() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("associateLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "blade"); + public void testAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("associateLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "blade"); - assertRequestLineEquals( + assertRequestLineEquals( request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associate?bladeDn=blade&org=org-root%2Forg-Finance&lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testAssociateTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("associateTemplate", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "newname", "blade"); + public void testAssociateTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("associateTemplate", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "newname", "blade"); - assertRequestLineEquals( + assertRequestLineEquals( request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/associatetemplate?newName=newname&bladeDn=blade&org=org-root%2Forg-Finance&lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCloneAndAssociateLogicServer() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("cloneAndAssociateLogicServer", - UcsRackDto.class, LogicServerDto.class, OrganizationDto.class, String.class, - String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "newname", "blade"); + public void testCloneAndAssociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("cloneAndAssociateLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "newname", "blade"); - assertRequestLineEquals( + assertRequestLineEquals( request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/assocclone?newName=newname&bladeDn=blade&org=org-root%2Forg-Finance&lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDissociateLogicServer() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("dissociateLogicServer", UcsRackDto.class, - LogicServerDto.class); - GeneratedHttpRequest request = - processor - .createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut()); + public void testDissociateLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("dissociateLogicServer", UcsRackDto.class, + LogicServerDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/dissociate?lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCloneLogicServer() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("cloneLogicServer", UcsRackDto.class, - LogicServerDto.class, OrganizationDto.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut(), - InfrastructureResources.organizationPut(), "name"); + public void testCloneLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("cloneLogicServer", UcsRackDto.class, + LogicServerDto.class, OrganizationDto.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut(), InfrastructureResources.organizationPut(), "name"); - assertRequestLineEquals( + assertRequestLineEquals( request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/clone?newName=name&org=org-root%2Forg-Finance&lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteLogicServer() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteLogicServer", UcsRackDto.class, - LogicServerDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), - InfrastructureResources.logicServerPut()); + public void testDeleteLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteLogicServer", UcsRackDto.class, + LogicServerDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), + InfrastructureResources.logicServerPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks/1/logicservers/delete?lsName=server HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListFsms() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listFsms", UcsRackDto.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.managedRackPut(), "dn"); + public void testListFsms() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listFsms", UcsRackDto.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.managedRackPut(), "dn"); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/fsm?dn=dn HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + FsmsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/fsm?dn=dn HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + FsmsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Remote Service **********************/ + /*********************** Remote Service **********************/ - public void testListRemoteServices() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listRemoteServices", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListRemoteServices() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listRemoteServices", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/remoteservices HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServicesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/remoteservices HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServicesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateRemoteService() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createRemoteService", DatacenterDto.class, - RemoteServiceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - InfrastructureResources.remoteServicePost()); + public void testCreateRemoteService() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createRemoteService", DatacenterDto.class, + RemoteServiceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + InfrastructureResources.remoteServicePost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/remoteservices HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, - withHeader(InfrastructureResources.remoteServicePostPayload()), RemoteServiceDto.class, - RemoteServiceDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testGetRemoteService() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getRemoteService", DatacenterDto.class, - RemoteServiceType.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - RemoteServiceType.STORAGE_SYSTEM_MONITOR); - - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/remoteservices/storagesystemmonitor HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateRemoteService() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateRemoteService", RemoteServiceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.remoteServicePut()); - - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/remoteservices/nodecollector HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.remoteServicePutPayload()), + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/remoteservices HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.remoteServicePostPayload()), RemoteServiceDto.class, RemoteServiceDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteRemoteService() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteRemoteService", RemoteServiceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.remoteServicePut()); + public void testGetRemoteService() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getRemoteService", DatacenterDto.class, + RemoteServiceType.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + RemoteServiceType.STORAGE_SYSTEM_MONITOR); - assertRequestLineEquals(request, + assertRequestLineEquals(request, + "GET http://localhost/api/admin/datacenters/1/remoteservices/storagesystemmonitor HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testUpdateRemoteService() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateRemoteService", RemoteServiceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.remoteServicePut()); + + assertRequestLineEquals(request, + "PUT http://localhost/api/admin/datacenters/1/remoteservices/nodecollector HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + RemoteServiceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.remoteServicePutPayload()), + RemoteServiceDto.class, RemoteServiceDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeleteRemoteService() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteRemoteService", RemoteServiceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.remoteServicePut()); + + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/remoteservices/nodecollector HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testIsAvailableRemoteService() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("isAvailable", RemoteServiceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.remoteServicePut()); + public void testIsAvailableRemoteService() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("isAvailable", RemoteServiceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.remoteServicePut()); - String checkUri = InfrastructureResources.remoteServicePut().searchLink("check").getHref(); - assertRequestLineEquals(request, String.format("GET %s HTTP/1.1", checkUri)); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + String checkUri = InfrastructureResources.remoteServicePut().searchLink("check").getHref(); + assertRequestLineEquals(request, String.format("GET %s HTTP/1.1", checkUri)); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseIfNotAvailable.class); + assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnFalseIfNotAvailable.class); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Machine ***********************/ + /*********************** Machine ***********************/ - public void testDiscoverSingleMachineWithoutOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - HypervisorType.XENSERVER, "user", "pass"); + public void testDiscoverSingleMachineWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", HypervisorType.XENSERVER, "user", "pass"); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; - String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; + String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testDiscoverSingleMachineAllParams() throws SecurityException, - NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, - MachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "80.80.80.80", - HypervisorType.KVM, "user", "pass", MachineOptions.builder().port(8889).build()); + public void testDiscoverSingleMachineAllParams() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "80.80.80.80", HypervisorType.KVM, "user", "pass", MachineOptions.builder().port(8889).build()); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; - String query = "hypervisor=KVM&ip=80.80.80.80&user=user&password=pass&port=8889"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; + String query = "hypervisor=KVM&ip=80.80.80.80&user=user&password=pass&port=8889"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testDiscoverSingleMachineDefaultValues() throws SecurityException, - NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, - MachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "80.80.80.80", - HypervisorType.KVM, "user", "pass", MachineOptions.builder().build()); + public void testDiscoverSingleMachineDefaultValues() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("discoverSingleMachine", DatacenterDto.class, + String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "80.80.80.80", HypervisorType.KVM, "user", "pass", MachineOptions.builder().build()); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; - String query = "hypervisor=KVM&ip=80.80.80.80&user=user&password=pass"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/discoversingle"; + String query = "hypervisor=KVM&ip=80.80.80.80&user=user&password=pass"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testDiscoverMultipleMachinesWithoutOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - "10.60.1.250", HypervisorType.XENSERVER, "user", "pass"); + public void testDiscoverMultipleMachinesWithoutOptions() throws SecurityException, NoSuchMethodException, + IOException { + Method method = InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, + String.class, String.class, HypervisorType.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", "10.60.1.250", HypervisorType.XENSERVER, "user", "pass"); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discovermultiple"; - String query = - "password=pass&ipTo=10.60.1.250&ipFrom=10.60.1.222&hypervisor=XENSERVER&user=user"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/discovermultiple"; + String query = "password=pass&ipTo=10.60.1.250&ipFrom=10.60.1.222&hypervisor=XENSERVER&user=user"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testDiscoverMultipleMachinesAllParams() throws SecurityException, - NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, - String.class, String.class, HypervisorType.class, String.class, String.class, - MachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "80.80.80.80", - "80.80.80.86", HypervisorType.KVM, "user", "pass", - MachineOptions.builder().port(8889).build()); + public void testDiscoverMultipleMachinesAllParams() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("discoverMultipleMachines", DatacenterDto.class, + String.class, String.class, HypervisorType.class, String.class, String.class, MachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "80.80.80.80", "80.80.80.86", HypervisorType.KVM, "user", "pass", MachineOptions.builder().port(8889) + .build()); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/discovermultiple"; - String query = - "password=pass&ipTo=80.80.80.86&ipFrom=80.80.80.80&hypervisor=KVM&user=user&port=8889"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/discovermultiple"; + String query = "password=pass&ipTo=80.80.80.86&ipFrom=80.80.80.80&hypervisor=KVM&user=user&port=8889"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineStateWithoutOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - HypervisorType.XENSERVER, "user", "pass"); + public void testCheckMachineStateWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, String.class, + HypervisorType.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", HypervisorType.XENSERVER, "user", "pass"); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachinestate"; - String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachinestate"; + String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineStateAllParams() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, - String.class, HypervisorType.class, String.class, String.class, - MachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - HypervisorType.XENSERVER, "user", "pass", MachineOptions.builder().port(8889) - .build()); + public void testCheckMachineStateAllParams() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineState", DatacenterDto.class, String.class, + HypervisorType.class, String.class, String.class, MachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", HypervisorType.XENSERVER, "user", "pass", MachineOptions.builder().port(8889).build()); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachinestate"; - String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass&port=8889"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachinestate"; + String query = "hypervisor=XENSERVER&ip=10.60.1.222&user=user&password=pass&port=8889"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineIpmiStateWithoutOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - "user", "pass"); + public void testCheckMachineIpmiStateWithoutOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, + String.class, String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", "user", "pass"); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate"; - String query = "user=user&ip=10.60.1.222&password=pass"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate"; + String query = "user=user&ip=10.60.1.222&password=pass"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineIpmiStateWithALLOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, - String.class, String.class, String.class, IpmiOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), "10.60.1.222", - "user", "pass", IpmiOptions.builder().port(8889).build()); + public void testCheckMachineIpmiStateWithALLOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", DatacenterDto.class, + String.class, String.class, String.class, IpmiOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + "10.60.1.222", "user", "pass", IpmiOptions.builder().port(8889).build()); - String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate"; - String query = "user=user&ip=10.60.1.222&password=pass&port=8889"; - String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); + String baseUrl = "http://localhost/api/admin/datacenters/1/action/checkmachineipmistate"; + String query = "user=user&ip=10.60.1.222&password=pass&port=8889"; + String expectedRequest = String.format("GET %s?%s HTTP/1.1", baseUrl, query); - assertRequestLineEquals(request, expectedRequest); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, expectedRequest); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnAbiquoExceptionOnNotFoundOr4xx.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListMachines() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listMachines", RackDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.rackPut()); + public void testListMachines() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listMachines", RackDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.rackPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/machines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachinesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetMachine() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getMachine", RackDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.rackPut(), 1); + public void testGetMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getMachine", RackDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.rackPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineState() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineState", MachineDto.class, - boolean.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut(), true); + public void testCheckMachineState() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineState", MachineDto.class, boolean.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut(), true); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/checkstate?sync=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckMachineIpmiState() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testCheckMachineIpmiState() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("checkMachineIpmiState", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/checkipmistate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineIpmiStateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateMachine() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class - .getMethod("createMachine", RackDto.class, MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.rackPut(), - InfrastructureResources.machinePost()); + public void testCreateMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createMachine", RackDto.class, MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.rackPut(), + InfrastructureResources.machinePost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/racks/1/machines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.machinePostPayload()), - MachineDto.class, MachineDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks/1/machines HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.machinePostPayload()), MachineDto.class, + MachineDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateMachine() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("updateMachine", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testUpdateMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateMachine", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.machinePutPayload()), - MachineDto.class, MachineDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.machinePutPayload()), MachineDto.class, + MachineDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteMachine() throws SecurityException, NoSuchMethodException - { - Method method = InfrastructureAsyncApi.class.getMethod("deleteMachine", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testDeleteMachine() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteMachine", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/racks/1/machines/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testReserveMachine() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("reserveMachine", EnterpriseDto.class, - MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut(), - InfrastructureResources.machinePut()); + public void testReserveMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("reserveMachine", EnterpriseDto.class, MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), + InfrastructureResources.machinePut()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.machinePutPayload()), - MachineDto.class, MachineDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/reservedmachines HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + MachineDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.machinePutPayload()), MachineDto.class, + MachineDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCancelReservation() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("cancelReservation", EnterpriseDto.class, - MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, EnterpriseResources.enterprisePut(), - InfrastructureResources.machinePut()); + public void testCancelReservation() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class + .getMethod("cancelReservation", EnterpriseDto.class, MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, EnterpriseResources.enterprisePut(), + InfrastructureResources.machinePut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/enterprises/1/reservedmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/reservedmachines/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualMachinesByMachine() throws SecurityException, NoSuchMethodException, - IOException - { - MachineOptions options = MachineOptions.builder().sync(true).build(); + public void testListVirtualMachinesByMachine() throws SecurityException, NoSuchMethodException, IOException { + MachineOptions options = MachineOptions.builder().sync(true).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listVirtualMachinesByMachine", - MachineDto.class, MachineOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut(), options); + Method method = InfrastructureAsyncApi.class.getMethod("listVirtualMachinesByMachine", MachineDto.class, + MachineOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut(), options); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/virtualmachines?sync=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualMachineByMachine() throws SecurityException, NoSuchMethodException, - IOException - { + public void testGetVirtualMachineByMachine() throws SecurityException, NoSuchMethodException, IOException { - Method method = - InfrastructureAsyncApi.class.getMethod("getVirtualMachine", MachineDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut(), 1); + Method method = InfrastructureAsyncApi.class.getMethod("getVirtualMachine", MachineDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/virtualmachines/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Blade ***********************/ + /*********************** Blade ***********************/ - public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("powerOff", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("powerOff", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweroff HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("powerOn", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("powerOn", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/poweron HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetLogicServer() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("getLogicServer", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testGetLogicServer() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getLogicServer", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/logicserver HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + LogicServerDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + LogicServerDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testLedOn() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("ledOn", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testLedOn() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("ledOn", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledon HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testLedOff() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("ledOff", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testLedOff() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("ledOff", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/racks/1/machines/1/action/ledoff HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetLocatorLed() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("getLocatorLed", MachineDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.machinePut()); + public void testGetLocatorLed() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getLocatorLed", MachineDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.machinePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/led HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + BladeLocatorLedDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/racks/1/machines/1/led HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + BladeLocatorLedDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Storage Device ***********************/ + /*********************** Storage Device ***********************/ - public void testListStorageDevices() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listStorageDevices", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListStorageDevices() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listStorageDevices", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/devices HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StorageDevicesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StorageDevicesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListSupportedStorageDevices() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", - DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListSupportedStorageDevices() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listSupportedStorageDevices", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/action/supported HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + StorageDevicesMetadataDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + StorageDevicesMetadataDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateStorageDevice() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createStorageDevice", DatacenterDto.class, - StorageDeviceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - InfrastructureResources.storageDevicePost()); + public void testCreateStorageDevice() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createStorageDevice", DatacenterDto.class, + StorageDeviceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + InfrastructureResources.storageDevicePost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/storage/devices HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, - withHeader(InfrastructureResources.storageDevicePostPayload()), StorageDeviceDto.class, - StorageDeviceDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteStorageDevice() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteStorageDevice", StorageDeviceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut()); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateStorageDevice() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateStorageDevice", StorageDeviceDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut()); - - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.storageDevicePutPayload()), + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/storage/devices HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.storageDevicePostPayload()), StorageDeviceDto.class, StorageDeviceDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetStorageDevice() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getStorageDevice", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + public void testDeleteStorageDevice() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteStorageDevice", StorageDeviceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Tier ***********************/ + public void testUpdateStorageDevice() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateStorageDevice", StorageDeviceDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut()); - public void testListTiers() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listTiers", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.storageDevicePutPayload()), + StorageDeviceDto.class, StorageDeviceDto.BASE_MEDIA_TYPE, false); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/tiers HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TiersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + checkFilters(request); + } - checkFilters(request); - } + public void testGetStorageDevice() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getStorageDevice", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); - public void testUpdateTier() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("updateTier", TierDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.tierPut()); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StorageDeviceDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.tierPutPayload()), - TierDto.class, TierDto.BASE_MEDIA_TYPE, false); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + checkFilters(request); + } - checkFilters(request); - } + /*********************** Tier ***********************/ - public void testGetTier() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getTier", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + public void testListTiers() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listTiers", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/tiers HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + TiersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** StoragePool ***********************/ + public void testUpdateTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateTier", TierDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.tierPut()); - public void testListSyncStoragePools() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut(), - StoragePoolOptions.builder().sync(true).build()); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.tierPutPayload()), TierDto.class, + TierDto.BASE_MEDIA_TYPE, false); - assertRequestLineEquals(request, + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getTier", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/tiers/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + TierDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + /*********************** StoragePool ***********************/ + + public void testListSyncStoragePools() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, + StoragePoolOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut(), + StoragePoolOptions.builder().sync(true).build()); + + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1/pools?sync=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListStoragePoolsFromTier() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listStoragePools", TierDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.tierPut(), StoragePoolOptions - .builder().sync(true).build()); + public void testListStoragePoolsFromTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listStoragePools", TierDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.tierPut(), + StoragePoolOptions.builder().sync(true).build()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/tiers/1/pools HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/tiers/1/pools HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListStoragePoolsNoParams() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut(), - StoragePoolOptions.builder().build()); + public void testListStoragePoolsNoParams() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listStoragePools", StorageDeviceDto.class, + StoragePoolOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut(), + StoragePoolOptions.builder().build()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/storage/devices/1/pools HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1/pools HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateStoragePool() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createStoragePool", StorageDeviceDto.class, - StoragePoolDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut(), - InfrastructureResources.storagePoolPost()); + public void testCreateStoragePool() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("createStoragePool", StorageDeviceDto.class, + StoragePoolDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut(), + InfrastructureResources.storagePoolPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/storage/devices/1/pools HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.storagePoolPostPayload()), - StoragePoolDto.class, StoragePoolDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/storage/devices/1/pools HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.storagePoolPostPayload()), StoragePoolDto.class, + StoragePoolDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateStoragePool() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateStoragePool", StoragePoolDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storagePoolPut()); + public void testUpdateStoragePool() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateStoragePool", StoragePoolDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storagePoolPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(InfrastructureResources.storagePoolPutPayload()), - StoragePoolDto.class, StoragePoolDto.BASE_MEDIA_TYPE, false); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(InfrastructureResources.storagePoolPutPayload()), StoragePoolDto.class, + StoragePoolDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteStoragePool() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteStoragePool", StoragePoolDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storagePoolPut()); + public void testDeleteStoragePool() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteStoragePool", StoragePoolDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storagePoolPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetStoragePool() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getStoragePool", StorageDeviceDto.class, - String.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storageDevicePut(), - InfrastructureResources.storagePoolPut().getIdStorage()); + public void testGetStoragePool() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getStoragePool", StorageDeviceDto.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storageDevicePut(), + InfrastructureResources.storagePoolPut().getIdStorage()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testRefreshStoragePool() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("refreshStoragePool", StoragePoolDto.class, - StoragePoolOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.storagePoolPut(), - StoragePoolOptions.builder().sync(true).build()); + public void testRefreshStoragePool() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("refreshStoragePool", StoragePoolDto.class, + StoragePoolOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.storagePoolPut(), + StoragePoolOptions.builder().sync(true).build()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/storage/devices/1/pools/tururututu?sync=true HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + StoragePoolDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Network ***********************/ + /*********************** Network ***********************/ - public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException - { - Method method = InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut()); + public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/network HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListNetworksWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - NetworkOptions options = NetworkOptions.builder().type(NetworkType.PUBLIC).build(); + public void testListNetworksWithOptions() throws SecurityException, NoSuchMethodException, IOException { + NetworkOptions options = NetworkOptions.builder().type(NetworkType.PUBLIC).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class, - NetworkOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), options); + Method method = InfrastructureAsyncApi.class.getMethod("listNetworks", DatacenterDto.class, NetworkOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), options); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/network?type=PUBLIC HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network?type=PUBLIC HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetNetworks() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class - .getMethod("getNetwork", DatacenterDto.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); + public void testGetNetworks() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getNetwork", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testCreateNetwork() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("createNetwork", DatacenterDto.class, - VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), - NetworkResources.vlanPost()); + public void testCreateNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class + .getMethod("createNetwork", DatacenterDto.class, VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), + NetworkResources.vlanPost()); - assertRequestLineEquals(request, - "POST http://localhost/api/admin/datacenters/1/network HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(NetworkResources.vlanNetworkPostPayload()), - VLANNetworkDto.class, VLANNetworkDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "POST http://localhost/api/admin/datacenters/1/network HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(NetworkResources.vlanNetworkPostPayload()), VLANNetworkDto.class, + VLANNetworkDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateNetwork() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("updateNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicNetworkPut()); + public void testUpdateNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("updateNetwork", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicNetworkPut()); - assertRequestLineEquals(request, - "PUT http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(NetworkResources.publicNetworkPutPayload()), - VLANNetworkDto.class, VLANNetworkDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VLANNetworkDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(NetworkResources.publicNetworkPutPayload()), VLANNetworkDto.class, + VLANNetworkDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteNetwork() throws SecurityException, NoSuchMethodException - { - Method method = - InfrastructureAsyncApi.class.getMethod("deleteNetwork", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicNetworkPut()); + public void testDeleteNetwork() throws SecurityException, NoSuchMethodException { + Method method = InfrastructureAsyncApi.class.getMethod("deleteNetwork", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicNetworkPut()); - assertRequestLineEquals(request, - "DELETE http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/datacenters/1/network/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCheckTagAvailability() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("checkTagAvailability", DatacenterDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, InfrastructureResources.datacenterPut(), 2); + public void testCheckTagAvailability() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class + .getMethod("checkTagAvailability", DatacenterDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, InfrastructureResources.datacenterPut(), 2); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/action/checkavailability?tag=2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + VlanTagAvailabilityDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VlanTagAvailabilityDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Network IPs ***********************/ + /*********************** Network IPs ***********************/ - public void testListPublicIps() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicNetworkPut()); + public void testListPublicIps() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicNetworkPut()); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/network/1/ips HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1/ips HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - IpOptions options = IpOptions.builder().startWith(10).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicNetworkPut(), options); + public void testListPublicIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().startWith(10).build(); + Method method = InfrastructureAsyncApi.class.getMethod("listPublicIps", VLANNetworkDto.class, IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicNetworkPut(), options); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1/ips?startwith=10 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPublicIp() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getPublicIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.publicNetworkPut(), 1); + public void testGetPublicIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getPublicIp", VLANNetworkDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.publicNetworkPut(), 1); - assertRequestLineEquals(request, - "GET http://localhost/api/admin/datacenters/1/network/1/ips/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/admin/datacenters/1/network/1/ips/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PublicIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListExternalIps() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.externalNetworkPut()); + public void testListExternalIps() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.externalNetworkPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListExternalIpsWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - IpOptions options = IpOptions.builder().startWith(10).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.externalNetworkPut(), options); + public void testListExternalIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().startWith(10).build(); + Method method = InfrastructureAsyncApi.class.getMethod("listExternalIps", VLANNetworkDto.class, IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.externalNetworkPut(), options); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips?startwith=10 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetExternalIp() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getExternalIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.externalNetworkPut(), 1); + public void testGetExternalIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getExternalIp", VLANNetworkDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.externalNetworkPut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + ExternalIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListUnmanagedIps() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.unmanagedNetworkPut()); + public void testListUnmanagedIps() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.unmanagedNetworkPut()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListUnmanagedIpsWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - IpOptions options = IpOptions.builder().startWith(10).build(); - Method method = - InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class, - IpOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.unmanagedNetworkPut(), options); + public void testListUnmanagedIpsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + IpOptions options = IpOptions.builder().startWith(10).build(); + Method method = InfrastructureAsyncApi.class.getMethod("listUnmanagedIps", VLANNetworkDto.class, IpOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.unmanagedNetworkPut(), options); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips?startwith=10 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetUnmanagedIp() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - InfrastructureAsyncApi.class.getMethod("getUnmanagedIp", VLANNetworkDto.class, - Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, NetworkResources.externalNetworkPut(), 1); + public void testGetUnmanagedIp() throws SecurityException, NoSuchMethodException, IOException { + Method method = InfrastructureAsyncApi.class.getMethod("getUnmanagedIp", VLANNetworkDto.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, NetworkResources.externalNetworkPut(), 1); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/limits/1/externalnetworks/1/ips/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + UnmanagedIpDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java index aea1dc5ce1..728cd4d981 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java @@ -52,458 +52,379 @@ import com.google.inject.TypeLiteral; * @author Susana Acedo */ @Test(groups = "unit", singleThreaded = true, testName = "PricingAsyncApiTest") -public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Currency ***********************/ - - public void testListCurrencies() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("listCurrencies"); - GeneratedHttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost/api/config/currencies HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CurrenciesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testGetCurrency() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("getCurrency", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); - - assertRequestLineEquals(request, "GET http://localhost/api/config/currencies/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateCurrency() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("createCurrency", CurrencyDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.currencyPost()); - - assertRequestLineEquals(request, "POST http://localhost/api/config/currencies HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.currencyPostPayload()), - CurrencyDto.class, CurrencyDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCurrency() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("updateCurrency", CurrencyDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.currencyPut()); - - assertRequestLineEquals(request, "PUT http://localhost/api/config/currencies/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.currencyPutPayload()), - CurrencyDto.class, CurrencyDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteCurrency() throws SecurityException, NoSuchMethodException - { - Method method = PricingAsyncApi.class.getMethod("deleteCurrency", CurrencyDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.currencyPut()); - - assertRequestLineEquals(request, "DELETE http://localhost/api/config/currencies/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Cost Code ***********************/ - - public void testListCostCodes() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("listCostCodes"); - GeneratedHttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testGetCostCode() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("getCostCode", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); - - assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreateCostCode() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("createCostCode", CostCodeDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.costcodePost()); - - assertRequestLineEquals(request, "POST http://localhost/api/config/costcodes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.costcodePostPayload()), - CostCodeDto.class, CostCodeDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdateCostCode() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("updateCostCode", CostCodeDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.costcodePut()); - - assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.costcodePutPayload()), - CostCodeDto.class, CostCodeDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testDeleteCostCode() throws SecurityException, NoSuchMethodException - { - Method method = PricingAsyncApi.class.getMethod("deleteCostCode", CostCodeDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.costcodePut()); - - assertRequestLineEquals(request, "DELETE http://localhost/api/config/costcodes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - /*********************** Pricing Template ***********************/ - - public void testListPricingTemplates() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = PricingAsyncApi.class.getMethod("listPricingTemplates"); - GeneratedHttpRequest request = processor.createRequest(method); - - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplatesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testGetPricingTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = PricingAsyncApi.class.getMethod("getPricingTemplate", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); - - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCreatePricingTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("createPricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.pricingtemplatePost()); - - assertRequestLineEquals(request, - "POST http://localhost/api/config/pricingtemplates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePostPayload()), - PricingTemplateDto.class, PricingTemplateDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testUpdatePricingTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("updatePricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.pricingtemplatePut()); - - assertRequestLineEquals(request, - "PUT http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePutPayload()), - PricingTemplateDto.class, PricingTemplateDto.BASE_MEDIA_TYPE, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testDeletePricingTemplate() throws SecurityException, NoSuchMethodException - { - Method method = - PricingAsyncApi.class.getMethod("deletePricingTemplate", PricingTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.pricingtemplatePut()); - - assertRequestLineEquals(request, - "DELETE http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } - - /*********************** Cost Code Currency ***********************/ - - public void testGetCostCodeCurrencies() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("getCostCodeCurrencies", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1, 1); - - assertRequestLineEquals(request, - "GET http://localhost/api/config/costcodes/1/currencies?idCurrency=1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUpdateCostCodeCurrencies() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("updateCostCodeCurrencies", Integer.class, - CostCodeCurrenciesDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, 1, PricingResources.costcodecurrencyPut()); - - assertRequestLineEquals(request, - "PUT http://localhost/api/config/costcodes/1/currencies HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.costcodecurrencyPutPayload()), +public class PricingAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Currency ***********************/ + + public void testListCurrencies() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("listCurrencies"); + GeneratedHttpRequest request = processor.createRequest(method); + + assertRequestLineEquals(request, "GET http://localhost/api/config/currencies HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CurrenciesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetCurrency() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getCurrency", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); + + assertRequestLineEquals(request, "GET http://localhost/api/config/currencies/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCreateCurrency() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("createCurrency", CurrencyDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.currencyPost()); + + assertRequestLineEquals(request, "POST http://localhost/api/config/currencies HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.currencyPostPayload()), CurrencyDto.class, + CurrencyDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUpdateCurrency() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updateCurrency", CurrencyDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.currencyPut()); + + assertRequestLineEquals(request, "PUT http://localhost/api/config/currencies/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CurrencyDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.currencyPutPayload()), CurrencyDto.class, + CurrencyDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeleteCurrency() throws SecurityException, NoSuchMethodException { + Method method = PricingAsyncApi.class.getMethod("deleteCurrency", CurrencyDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.currencyPut()); + + assertRequestLineEquals(request, "DELETE http://localhost/api/config/currencies/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + /*********************** Cost Code ***********************/ + + public void testListCostCodes() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("listCostCodes"); + GeneratedHttpRequest request = processor.createRequest(method); + + assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetCostCode() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getCostCode", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); + + assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCreateCostCode() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("createCostCode", CostCodeDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.costcodePost()); + + assertRequestLineEquals(request, "POST http://localhost/api/config/costcodes HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.costcodePostPayload()), CostCodeDto.class, + CostCodeDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUpdateCostCode() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updateCostCode", CostCodeDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.costcodePut()); + + assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.costcodePutPayload()), CostCodeDto.class, + CostCodeDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeleteCostCode() throws SecurityException, NoSuchMethodException { + Method method = PricingAsyncApi.class.getMethod("deleteCostCode", CostCodeDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.costcodePut()); + + assertRequestLineEquals(request, "DELETE http://localhost/api/config/costcodes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + /*********************** Pricing Template ***********************/ + + public void testListPricingTemplates() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("listPricingTemplates"); + GeneratedHttpRequest request = processor.createRequest(method); + + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplatesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetPricingTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getPricingTemplate", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); + + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCreatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("createPricingTemplate", PricingTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.pricingtemplatePost()); + + assertRequestLineEquals(request, "POST http://localhost/api/config/pricingtemplates HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePostPayload()), PricingTemplateDto.class, + PricingTemplateDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUpdatePricingTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updatePricingTemplate", PricingTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.pricingtemplatePut()); + + assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.pricingtemplatePutPayload()), PricingTemplateDto.class, + PricingTemplateDto.BASE_MEDIA_TYPE, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeletePricingTemplate() throws SecurityException, NoSuchMethodException { + Method method = PricingAsyncApi.class.getMethod("deletePricingTemplate", PricingTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.pricingtemplatePut()); + + assertRequestLineEquals(request, "DELETE http://localhost/api/config/pricingtemplates/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + /*********************** Cost Code Currency ***********************/ + + public void testGetCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getCostCodeCurrencies", Integer.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1); + + assertRequestLineEquals(request, "GET http://localhost/api/config/costcodes/1/currencies?idCurrency=1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testUpdateCostCodeCurrencies() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updateCostCodeCurrencies", Integer.class, + CostCodeCurrenciesDto.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, PricingResources.costcodecurrencyPut()); + + assertRequestLineEquals(request, "PUT http://localhost/api/config/costcodes/1/currencies HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + CostCodeCurrenciesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.costcodecurrencyPutPayload()), CostCodeCurrenciesDto.class, CostCodeCurrenciesDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Pricing Cost Code ***********************/ + /*********************** Pricing Cost Code ***********************/ - public void testGetPricingCostCodes() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = PricingAsyncApi.class.getMethod("getPricingCostCodes", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetPricingCostCodes() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getPricingCostCodes", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates/1/costcodes HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodesDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPricingCostCode() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("getPricingCostCode", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1, 1); + public void testGetPricingCostCode() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getPricingCostCode", Integer.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdatePricingCostCode() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("updatePricingCostCode", PricingCostCodeDto.class, - Integer.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.pricingCostcodePut(), 1, 1); + public void testUpdatePricingCostCode() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updatePricingCostCode", PricingCostCodeDto.class, Integer.class, + Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.pricingCostcodePut(), 1, 1); - assertRequestLineEquals(request, - "PUT http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.pricingCostCodePutPayload()), - PricingCostCodeDto.class, PricingCostCodeDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/costcodes/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingCostCodeDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.pricingCostCodePutPayload()), PricingCostCodeDto.class, + PricingCostCodeDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Pricing Tier ***************************/ + /*********************** Pricing Tier ***************************/ - public void testGetPricingTiers() throws SecurityException, NoSuchMethodException, IOException - { - Method method = PricingAsyncApi.class.getMethod("getPricingTiers", Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1); + public void testGetPricingTiers() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getPricingTiers", Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates/1/tiers HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTiersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTiersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testGetPricingTier() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - PricingAsyncApi.class.getMethod("getPricingTier", Integer.class, Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1, 1); + public void testGetPricingTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("getPricingTier", Integer.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1); - assertRequestLineEquals(request, - "GET http://localhost/api/config/pricingtemplates/1/tiers/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://localhost/api/config/pricingtemplates/1/tiers/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdatePricingTier() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - PricingAsyncApi.class.getMethod("updatePricingTier", PricingTierDto.class, - Integer.class, Integer.class); - GeneratedHttpRequest request = - processor.createRequest(method, PricingResources.pricingTierPut(), 1, 2); + public void testUpdatePricingTier() throws SecurityException, NoSuchMethodException, IOException { + Method method = PricingAsyncApi.class.getMethod("updatePricingTier", PricingTierDto.class, Integer.class, + Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, PricingResources.pricingTierPut(), 1, 2); - assertRequestLineEquals(request, - "PUT http://localhost/api/config/pricingtemplates/1/tiers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, withHeader(PricingResources.pricingTierPutPayload()), - PricingTierDto.class, PricingTierDto.BASE_MEDIA_TYPE, false); + assertRequestLineEquals(request, "PUT http://localhost/api/config/pricingtemplates/1/tiers/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + PricingTierDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(PricingResources.pricingTierPutPayload()), PricingTierDto.class, + PricingTierDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java index 906a85166a..5a14254387 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java @@ -43,103 +43,88 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "TaskAsyncApiTest") -public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest -{ - /*********************** Task ***********************/ +public class TaskAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Task ***********************/ - public void testGetTaskVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = TaskAsyncApi.class.getMethod("getTask", RESTLink.class); - GeneratedHttpRequest request = - processor - .createRequest( - method, - new RESTLink("task", + public void testGetTaskVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncApi.class.getMethod("getTask", RESTLink.class); + GeneratedHttpRequest request = processor + .createRequest( + method, + new RESTLink( + "task", "http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks/169f1877-5f17-4f62-9563-974001295c54")); - assertRequestLineEquals( + assertRequestLineEquals( request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks/169f1877-5f17-4f62-9563-974001295c54 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TaskDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TaskDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOn303.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOn303.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListTasksVirtualMachine() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, CloudResources.virtualMachinePut()); + public void testListTasksVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class); + GeneratedHttpRequest request = processor.createRequest(method, CloudResources.virtualMachinePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/1/tasks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TasksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TasksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetTaskVirtualMachineTemplate() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = TaskAsyncApi.class.getMethod("getTask", RESTLink.class); - GeneratedHttpRequest request = - processor - .createRequest( - method, - new RESTLink("task", + public void testGetTaskVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncApi.class.getMethod("getTask", RESTLink.class); + GeneratedHttpRequest request = processor + .createRequest( + method, + new RESTLink( + "task", "http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/169f1877-5f17-4f62-9563-974001295c54")); - assertRequestLineEquals( + assertRequestLineEquals( request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks/169f1877-5f17-4f62-9563-974001295c54 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TaskDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TaskDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOn303.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOn303.class); - checkFilters(request); - } + checkFilters(request); + } - public void testListTasksVirtualMachineTemplate() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); + public void testListTasksVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncApi.class.getMethod("listTasks", SingleResourceTransportDto.class); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/tasks HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + TasksDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + TasksDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java index b77477ac75..648cefe877 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java @@ -53,252 +53,202 @@ import com.google.inject.TypeLiteral; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "VirtualMachineTemplateAsyncApiTest") -public class VirtualMachineTemplateAsyncApiTest extends - BaseAbiquoAsyncApiTest -{ - /*********************** Virtual Machine Template ***********************/ +public class VirtualMachineTemplateAsyncApiTest extends BaseAbiquoAsyncApiTest { + /*********************** Virtual Machine Template ***********************/ - public void testListVirtualMachineTemplates() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", - Integer.class, Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1, 1); + public void testListVirtualMachineTemplates() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", Integer.class, + Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListVirtualMachineTemplatesWithOptions() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", - Integer.class, Integer.class, VirtualMachineTemplateOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, 1, 1, VirtualMachineTemplateOptions.builder() - .hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls").build()); + public void testListVirtualMachineTemplatesWithOptions() throws SecurityException, NoSuchMethodException, + IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("listVirtualMachineTemplates", Integer.class, + Integer.class, VirtualMachineTemplateOptions.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1, VirtualMachineTemplateOptions.builder() + .hypervisorType(HypervisorType.XENSERVER).categoryName("Firewalls").build()); - assertRequestLineEquals(request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates" - + "?hypervisorTypeName=XENSERVER&categoryName=Firewalls HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + + "?hypervisorTypeName=XENSERVER&categoryName=Firewalls HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplatesDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("getVirtualMachineTemplate", - Integer.class, Integer.class, Integer.class); - GeneratedHttpRequest request = processor.createRequest(method, 1, 1, 1); + public void testGetVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("getVirtualMachineTemplate", Integer.class, + Integer.class, Integer.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1, 1); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - public void testUpdateVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("updateVirtualMachineTemplate", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); + public void testUpdateVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("updateVirtualMachineTemplate", + VirtualMachineTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "PUT http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " - + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, - withHeader(TemplateResources.virtualMachineTemplatePutPayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + VirtualMachineTemplateDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(TemplateResources.virtualMachineTemplatePutPayload()), VirtualMachineTemplateDto.class, VirtualMachineTemplateDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testDeleteVirtualMachineTemplate() throws SecurityException, NoSuchMethodException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("deleteVirtualMachineTemplate", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); + public void testDeleteVirtualMachineTemplate() throws SecurityException, NoSuchMethodException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("deleteVirtualMachineTemplate", + VirtualMachineTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "DELETE http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testCreatePersistentVirtualMachineTemplate() throws SecurityException, - NoSuchMethodException, IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod( - "createPersistentVirtualMachineTemplate", Integer.class, Integer.class, - VirtualMachineTemplatePersistentDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, 1, 1, TemplateResources.persistentData()); + public void testCreatePersistentVirtualMachineTemplate() throws SecurityException, NoSuchMethodException, + IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("createPersistentVirtualMachineTemplate", + Integer.class, Integer.class, VirtualMachineTemplatePersistentDto.class); + GeneratedHttpRequest request = processor.createRequest(method, 1, 1, TemplateResources.persistentData()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "POST http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(TemplateResources.persistentPayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(TemplateResources.persistentPayload()), VirtualMachineTemplatePersistentDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - /*********************** Conversions ***********************/ + /*********************** Conversions ***********************/ - public void testRequestConversion() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("requestConversion", - VirtualMachineTemplateDto.class, DiskFormatType.class, ConversionDto.class); + public void testRequestConversion() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("requestConversion", + VirtualMachineTemplateDto.class, DiskFormatType.class, ConversionDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut(), - DiskFormatType.VMDK_STREAM_OPTIMIZED, TemplateResources.conversionPut()); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut(), + DiskFormatType.VMDK_STREAM_OPTIMIZED, TemplateResources.conversionPut()); - assertRequestLineEquals( + assertRequestLineEquals( request, "PUT http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/VMDK_STREAM_OPTIMIZED HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE - + "\n"); - assertPayloadEquals(request, withHeader(TemplateResources.conversionPutPlayload()), + assertNonPayloadHeadersEqual(request, "Accept: " + AcceptedRequestDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, withHeader(TemplateResources.conversionPutPlayload()), ConversionDto.BASE_MEDIA_TYPE, false); - assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ReturnTaskReferenceOrNull.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListConversions() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("listConversions", - VirtualMachineTemplateDto.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); + public void testListConversions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class + .getMethod("listConversions", VirtualMachineTemplateDto.class); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ConversionsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + ConversionsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testListConversionsWithOptions() throws SecurityException, NoSuchMethodException, - IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("listConversions", - VirtualMachineTemplateDto.class, ConversionOptions.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut(), - ConversionOptions.builder().hypervisorType(HypervisorType.XENSERVER) - .conversionState(ConversionState.FINISHED).build()); + public void testListConversionsWithOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("listConversions", + VirtualMachineTemplateDto.class, ConversionOptions.class); + GeneratedHttpRequest request = processor.createRequest( + method, + TemplateResources.virtualMachineTemplatePut(), + ConversionOptions.builder().hypervisorType(HypervisorType.XENSERVER) + .conversionState(ConversionState.FINISHED).build()); - assertRequestLineEquals( - request, + assertRequestLineEquals(request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions" - + "?hypervisor=XENSERVER&state=FINISHED HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ConversionsDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + + "?hypervisor=XENSERVER&state=FINISHED HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + ConversionsDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, null); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); - checkFilters(request); - } + checkFilters(request); + } - public void testGetConversion() throws SecurityException, NoSuchMethodException, IOException - { - Method method = - VirtualMachineTemplateAsyncApi.class.getMethod("getConversion", - VirtualMachineTemplateDto.class, DiskFormatType.class); - GeneratedHttpRequest request = - processor.createRequest(method, TemplateResources.virtualMachineTemplatePut(), - DiskFormatType.RAW); + public void testGetConversion() throws SecurityException, NoSuchMethodException, IOException { + Method method = VirtualMachineTemplateAsyncApi.class.getMethod("getConversion", VirtualMachineTemplateDto.class, + DiskFormatType.class); + GeneratedHttpRequest request = processor.createRequest(method, TemplateResources.virtualMachineTemplatePut(), + DiskFormatType.RAW); - assertRequestLineEquals( + assertRequestLineEquals( request, "GET http://localhost/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/1/conversions/RAW HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + ConversionDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertNonPayloadHeadersEqual(request, "Accept: " + ConversionDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, ParseXMLWithJAXB.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeTypeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeTypeTest.java index 115e551af7..1867008fc1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeTypeTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeTypeTest.java @@ -32,44 +32,33 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AppendApiVersionToAbiquoMimeTypeTest") -public class AppendApiVersionToAbiquoMimeTypeTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testApplyWithNullInput() - { - Function function = - new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); - function.apply(null); - } +public class AppendApiVersionToAbiquoMimeTypeTest { + @Test(expectedExceptions = NullPointerException.class) + public void testApplyWithNullInput() { + Function function = new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); + function.apply(null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testApplyWithInvalidMediaType() - { - Function function = - new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); - function.apply("foo"); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testApplyWithInvalidMediaType() { + Function function = new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); + function.apply("foo"); + } - public void testApplyToStandardMediaType() - { - Function function = - new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); - assertEquals(function.apply("application/xml"), "application/xml"); - } + public void testApplyToStandardMediaType() { + Function function = new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); + assertEquals(function.apply("application/xml"), "application/xml"); + } - public void testApplyToAbiquoMediaTypeWithVersion() - { - Function function = - new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); - assertEquals(function.apply("application/vnd.abiquo.datacenters+xml;version=1.8.5"), + public void testApplyToAbiquoMediaTypeWithVersion() { + Function function = new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); + assertEquals(function.apply("application/vnd.abiquo.datacenters+xml;version=1.8.5"), "application/vnd.abiquo.datacenters+xml;version=1.8.5"); - } + } - public void testApplyToAbiquoMediaTypeWithoutVersion() - { - Function function = - new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); - assertEquals(function.apply("application/vnd.abiquo.datacenters+xml"), + public void testApplyToAbiquoMediaTypeWithoutVersion() { + Function function = new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION); + assertEquals(function.apply("application/vnd.abiquo.datacenters+xml"), "application/vnd.abiquo.datacenters+xml;version=" + AbiquoAsyncApi.API_VERSION); - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xxTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xxTest.java index 5f3b6eb56d..2bcd2ec9e8 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xxTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnAbiquoExceptionOnNotFoundOr4xxTest.java @@ -36,51 +36,38 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnAbiquoExceptionOnNotFoundOr4xxTest") -public class ReturnAbiquoExceptionOnNotFoundOr4xxTest -{ - public void testReturnOriginalExceptionIfNotResourceNotFound() - { - Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); - RuntimeException exception = new RuntimeException(); +public class ReturnAbiquoExceptionOnNotFoundOr4xxTest { + public void testReturnOriginalExceptionIfNotResourceNotFound() { + Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); + RuntimeException exception = new RuntimeException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnOriginalExceptionIfNotAbiquoException() - { - Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); - ResourceNotFoundException exception = new ResourceNotFoundException(); + public void testReturnOriginalExceptionIfNotAbiquoException() { + Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); + ResourceNotFoundException exception = new ResourceNotFoundException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnAbiquoException() - { - Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); - AbiquoException abiquoException = new AbiquoException(Status.NOT_FOUND, new ErrorsDto()); - ResourceNotFoundException exception = new ResourceNotFoundException(abiquoException); + public void testReturnAbiquoException() { + Function function = new ReturnAbiquoExceptionOnNotFoundOr4xx(); + AbiquoException abiquoException = new AbiquoException(Status.NOT_FOUND, new ErrorsDto()); + ResourceNotFoundException exception = new ResourceNotFoundException(abiquoException); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, abiquoException); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, abiquoException); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailableTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailableTest.java index 423c095297..a4bc6f978d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailableTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseIfNotAvailableTest.java @@ -38,84 +38,73 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnFalseIfNotAvailableTest") -public class ReturnFalseIfNotAvailableTest -{ - public void testReturnOriginalExceptionIfUnknownException() - { - Function function = new ReturnFalseIfNotAvailable(); - RuntimeException exception = new RuntimeException(); +public class ReturnFalseIfNotAvailableTest { + public void testReturnOriginalExceptionIfUnknownException() { + Function function = new ReturnFalseIfNotAvailable(); + RuntimeException exception = new RuntimeException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnFalseIf5xx() - { - Function function = new ReturnFalseIfNotAvailable(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnFalseIf5xx() { + Function function = new ReturnFalseIfNotAvailable(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called twice - expect(response.getStatusCode()).andReturn(503); - expect(response.getStatusCode()).andReturn(503); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called twice + expect(response.getStatusCode()).andReturn(503); + expect(response.getStatusCode()).andReturn(503); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - assertEquals(function.apply(exception), false); + assertEquals(function.apply(exception), false); - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } - public void testReturnExceptionIfNot5xx() - { - Function function = new ReturnFalseIfNotAvailable(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnExceptionIfNot5xx() { + Function function = new ReturnFalseIfNotAvailable(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called twice - expect(response.getStatusCode()).andReturn(600); - expect(response.getStatusCode()).andReturn(600); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called twice + expect(response.getStatusCode()).andReturn(600); + expect(response.getStatusCode()).andReturn(600); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } - public void testReturnFalseIfResourceNotFound() - { - Function function = new ReturnFalseIfNotAvailable(); - ResourceNotFoundException exception = new ResourceNotFoundException(); + public void testReturnFalseIfResourceNotFound() { + Function function = new ReturnFalseIfNotAvailable(); + ResourceNotFoundException exception = new ResourceNotFoundException(); - assertEquals(function.apply(exception), false); - } + assertEquals(function.apply(exception), false); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseOn5xxTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseOn5xxTest.java index 8cab916359..745793408f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseOn5xxTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnFalseOn5xxTest.java @@ -37,75 +37,65 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnFalseOn5xxTest") -public class ReturnFalseOn5xxTest -{ - public void testReturnOriginalExceptionIfNotHttpResponseException() - { - Function function = new ReturnFalseOn5xx(); - RuntimeException exception = new RuntimeException(); +public class ReturnFalseOn5xxTest { + public void testReturnOriginalExceptionIfNotHttpResponseException() { + Function function = new ReturnFalseOn5xx(); + RuntimeException exception = new RuntimeException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnFalseIf5xx() - { - Function function = new ReturnFalseOn5xx(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnFalseIf5xx() { + Function function = new ReturnFalseOn5xx(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called twice - expect(response.getStatusCode()).andReturn(503); - expect(response.getStatusCode()).andReturn(503); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called twice + expect(response.getStatusCode()).andReturn(503); + expect(response.getStatusCode()).andReturn(503); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - assertEquals(function.apply(exception), false); + assertEquals(function.apply(exception), false); - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } - public void testReturnExceptionIfNot5xx() - { - Function function = new ReturnFalseOn5xx(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnExceptionIfNot5xx() { + Function function = new ReturnFalseOn5xx(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called twice - expect(response.getStatusCode()).andReturn(600); - expect(response.getStatusCode()).andReturn(600); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called twice + expect(response.getStatusCode()).andReturn(600); + expect(response.getStatusCode()).andReturn(600); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnNullOn303Test.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnNullOn303Test.java index c79f5349f5..b3ba8dc182 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnNullOn303Test.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnNullOn303Test.java @@ -38,73 +38,63 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnNullOn303Test") -public class ReturnNullOn303Test -{ - public void testReturnOriginalExceptionIfNotHttpResponseException() - { - Function function = new ReturnNullOn303(); - RuntimeException exception = new RuntimeException(); +public class ReturnNullOn303Test { + public void testReturnOriginalExceptionIfNotHttpResponseException() { + Function function = new ReturnNullOn303(); + RuntimeException exception = new RuntimeException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnNullIf303() - { - Function function = new ReturnNullOn303(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnNullIf303() { + Function function = new ReturnNullOn303(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called once - expect(response.getStatusCode()).andReturn(303); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called once + expect(response.getStatusCode()).andReturn(303); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - assertNull(function.apply(exception)); + assertNull(function.apply(exception)); - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } - public void testReturnExceptionIfNot303() - { - Function function = new ReturnNullOn303(); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + public void testReturnExceptionIfNot303() { + Function function = new ReturnNullOn303(); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - // Status code is called once - expect(response.getStatusCode()).andReturn(600); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called once + expect(response.getStatusCode()).andReturn(600); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNullTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNullTest.java index 0fb2db3a64..fcaf2eda6d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNullTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNullTest.java @@ -46,53 +46,49 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnTaskReferenceOrNullTest") -public class ReturnTaskReferenceOrNullTest -{ - public void testReturnNullIfNoContent() - { - Function> function = - new ReturnTaskReferenceOrNull(new JAXBParser("false"), createTypeLiteral()); +public class ReturnTaskReferenceOrNullTest { + public void testReturnNullIfNoContent() { + Function> function = new ReturnTaskReferenceOrNull(new JAXBParser( + "false"), createTypeLiteral()); - HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponse response = EasyMock.createMock(HttpResponse.class); - expect(response.getStatusCode()).andReturn(Status.NO_CONTENT.getStatusCode()); - expect(response.getPayload()).andReturn(null); + expect(response.getStatusCode()).andReturn(Status.NO_CONTENT.getStatusCode()); + expect(response.getPayload()).andReturn(null); - replay(response); + replay(response); - assertNull(function.apply(response)); + assertNull(function.apply(response)); - verify(response); - } + verify(response); + } - public void testReturnTaskIfAccepted() throws IOException - { - JAXBParser parser = new JAXBParser("false"); - AcceptedRequestDto< ? > task = new AcceptedRequestDto(); - Payload payload = Payloads.newPayload(parser.toXML(task)); + public void testReturnTaskIfAccepted() throws IOException { + JAXBParser parser = new JAXBParser("false"); + AcceptedRequestDto task = new AcceptedRequestDto(); + Payload payload = Payloads.newPayload(parser.toXML(task)); - Function> function = - new ReturnTaskReferenceOrNull(parser, createTypeLiteral()); + Function> function = new ReturnTaskReferenceOrNull(parser, + createTypeLiteral()); - HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponse response = EasyMock.createMock(HttpResponse.class); - expect(response.getStatusCode()).andReturn(Status.ACCEPTED.getStatusCode()); - // Get payload is called three times: one to deserialize it, and twice to release it - expect(response.getPayload()).andReturn(payload); - expect(response.getPayload()).andReturn(payload); - expect(response.getPayload()).andReturn(payload); + expect(response.getStatusCode()).andReturn(Status.ACCEPTED.getStatusCode()); + // Get payload is called three times: one to deserialize it, and twice to + // release it + expect(response.getPayload()).andReturn(payload); + expect(response.getPayload()).andReturn(payload); + expect(response.getPayload()).andReturn(payload); - replay(response); + replay(response); - assertTrue(function.apply(response) instanceof AcceptedRequestDto); + assertTrue(function.apply(response) instanceof AcceptedRequestDto); - verify(response); - } + verify(response); + } - private static TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + private static TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolumeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolumeTest.java index a86b2302dd..628b384bdf 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolumeTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/cloud/ReturnMovedVolumeTest.java @@ -47,60 +47,53 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ReturnMovedVolumeTest") -public class ReturnMovedVolumeTest -{ - public void testReturnOriginalExceptionIfNotHttpResponseException() - { - Function function = - new ReturnMovedVolume(new ReturnMoveVolumeReference(new JAXBParser("false"), - TypeLiteral.get(MovedVolumeDto.class))); +public class ReturnMovedVolumeTest { + public void testReturnOriginalExceptionIfNotHttpResponseException() { + Function function = new ReturnMovedVolume(new ReturnMoveVolumeReference( + new JAXBParser("false"), TypeLiteral.get(MovedVolumeDto.class))); - RuntimeException exception = new RuntimeException(); + RuntimeException exception = new RuntimeException(); - try - { - function.apply(exception); - } - catch (Exception ex) - { - assertEquals(ex, exception); - } - } + try { + function.apply(exception); + } catch (Exception ex) { + assertEquals(ex, exception); + } + } - public void testReturnVolume() throws IOException - { - JAXBParser xmlParser = new JAXBParser("false"); - Function function = - new ReturnMovedVolume(new ReturnMoveVolumeReference(new JAXBParser("false"), - TypeLiteral.get(MovedVolumeDto.class))); + public void testReturnVolume() throws IOException { + JAXBParser xmlParser = new JAXBParser("false"); + Function function = new ReturnMovedVolume(new ReturnMoveVolumeReference( + new JAXBParser("false"), TypeLiteral.get(MovedVolumeDto.class))); - VolumeManagementDto volume = new VolumeManagementDto(); - volume.setName("Test volume"); - MovedVolumeDto movedRef = new MovedVolumeDto(); - movedRef.setVolume(volume); + VolumeManagementDto volume = new VolumeManagementDto(); + volume.setName("Test volume"); + MovedVolumeDto movedRef = new MovedVolumeDto(); + movedRef.setVolume(volume); - HttpResponse response = EasyMock.createMock(HttpResponse.class); - HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); - Payload payload = Payloads.newPayload(xmlParser.toXML(movedRef)); + HttpResponse response = EasyMock.createMock(HttpResponse.class); + HttpResponseException exception = EasyMock.createMock(HttpResponseException.class); + Payload payload = Payloads.newPayload(xmlParser.toXML(movedRef)); - // Status code is called once - expect(response.getStatusCode()).andReturn(Status.MOVED_PERMANENTLY.getStatusCode()); - // Get response gets called twice - expect(exception.getResponse()).andReturn(response); - expect(exception.getResponse()).andReturn(response); - // Get payload is called three times: one to deserialize it, and twice to release it - expect(response.getPayload()).andReturn(payload); - expect(response.getPayload()).andReturn(payload); - expect(response.getPayload()).andReturn(payload); - // Get cause is called to determine the root cause - expect(exception.getCause()).andReturn(null); + // Status code is called once + expect(response.getStatusCode()).andReturn(Status.MOVED_PERMANENTLY.getStatusCode()); + // Get response gets called twice + expect(exception.getResponse()).andReturn(response); + expect(exception.getResponse()).andReturn(response); + // Get payload is called three times: one to deserialize it, and twice to + // release it + expect(response.getPayload()).andReturn(payload); + expect(response.getPayload()).andReturn(payload); + expect(response.getPayload()).andReturn(payload); + // Get cause is called to determine the root cause + expect(exception.getCause()).andReturn(null); - replay(response); - replay(exception); + replay(response); + replay(exception); - function.apply(exception); + function.apply(exception); - verify(response); - verify(exception); - } + verify(response); + verify(exception); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseIdTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseIdTest.java index 2822fae898..5f034ef0b1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseIdTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/enterprise/ParseEnterpriseIdTest.java @@ -32,35 +32,30 @@ import com.google.common.base.Function; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "ParseEnterpriseIdTest") -public class ParseEnterpriseIdTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - Function parser = new ParseEnterpriseId(); - parser.apply(null); - } +public class ParseEnterpriseIdTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + Function parser = new ParseEnterpriseId(); + parser.apply(null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() - { - Function parser = new ParseEnterpriseId(); - parser.apply(new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() { + Function parser = new ParseEnterpriseId(); + parser.apply(new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidId() - { - Function parser = new ParseEnterpriseId(); - parser.apply(new EnterpriseDto()); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidId() { + Function parser = new ParseEnterpriseId(); + parser.apply(new EnterpriseDto()); + } - public void testValidId() - { - Function parser = new ParseEnterpriseId(); + public void testValidId() { + Function parser = new ParseEnterpriseId(); - EnterpriseDto enterprise = new EnterpriseDto(); - enterprise.setId(5); - assertEquals(parser.apply(enterprise), "5"); - } + EnterpriseDto enterprise = new EnterpriseDto(); + enterprise.setId(5); + assertEquals(parser.apply(enterprise), "5"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterIdTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterIdTest.java index bf93734732..48aca7b9fc 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterIdTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseDatacenterIdTest.java @@ -32,35 +32,30 @@ import com.google.common.base.Function; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "ParseDatacenterIdTest") -public class ParseDatacenterIdTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - Function parser = new ParseDatacenterId(); - parser.apply(null); - } +public class ParseDatacenterIdTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + Function parser = new ParseDatacenterId(); + parser.apply(null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() - { - Function parser = new ParseDatacenterId(); - parser.apply(new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() { + Function parser = new ParseDatacenterId(); + parser.apply(new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidId() - { - Function parser = new ParseDatacenterId(); - parser.apply(new DatacenterDto()); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidId() { + Function parser = new ParseDatacenterId(); + parser.apply(new DatacenterDto()); + } - public void testValidId() - { - Function parser = new ParseDatacenterId(); + public void testValidId() { + Function parser = new ParseDatacenterId(); - DatacenterDto datacenter = new DatacenterDto(); - datacenter.setId(5); - assertEquals(parser.apply(datacenter), "5"); - } + DatacenterDto datacenter = new DatacenterDto(); + datacenter.setId(5); + assertEquals(parser.apply(datacenter), "5"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineIdTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineIdTest.java index 2d1a938959..27647d8775 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineIdTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseMachineIdTest.java @@ -32,35 +32,30 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "ParseMachineIdTest") -public class ParseMachineIdTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - Function parser = new ParseMachineId(); - parser.apply(null); - } +public class ParseMachineIdTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + Function parser = new ParseMachineId(); + parser.apply(null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() - { - Function parser = new ParseMachineId(); - parser.apply(new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() { + Function parser = new ParseMachineId(); + parser.apply(new Object()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidId() - { - Function parser = new ParseMachineId(); - parser.apply(new MachineDto()); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidId() { + Function parser = new ParseMachineId(); + parser.apply(new MachineDto()); + } - public void testValidId() - { - Function parser = new ParseMachineId(); + public void testValidId() { + Function parser = new ParseMachineId(); - MachineDto machine = new MachineDto(); - machine.setId(5); - assertEquals(parser.apply(machine), "5"); - } + MachineDto machine = new MachineDto(); + machine.setId(5); + assertEquals(parser.apply(machine), "5"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceTypeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceTypeTest.java index 828ae42f19..072e0147f5 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceTypeTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/functions/infrastructure/ParseRemoteServiceTypeTest.java @@ -32,25 +32,21 @@ import com.google.common.base.Function; * @author Francesc Montserrat */ @Test(groups = "unit", testName = "ParseRemoteServiceTypeTest") -public class ParseRemoteServiceTypeTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullInput() - { - Function parser = new ParseRemoteServiceType(); - parser.apply(null); - } +public class ParseRemoteServiceTypeTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullInput() { + Function parser = new ParseRemoteServiceType(); + parser.apply(null); + } - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInvalidInputType() - { - Function parser = new ParseRemoteServiceType(); - parser.apply(new Object()); - } + @Test(expectedExceptions = IllegalArgumentException.class) + public void testInvalidInputType() { + Function parser = new ParseRemoteServiceType(); + parser.apply(new Object()); + } - public void testValidId() - { - Function parser = new ParseRemoteServiceType(); - assertEquals(parser.apply(RemoteServiceType.BPM_SERVICE), "bpmservice"); - } + public void testValidId() { + Function parser = new ParseRemoteServiceType(); + assertEquals(parser.apply(RemoteServiceType.BPM_SERVICE), "bpmservice"); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationLiveApiTest.java index b90d442ca2..5ed7e84b82 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationLiveApiTest.java @@ -55,144 +55,122 @@ import com.google.inject.Module; * @author Ignasi Barrera */ @Test(groups = "api", testName = "AbiquoAuthenticationLiveApiTest") -public class AbiquoAuthenticationLiveApiTest -{ - private String identity; +public class AbiquoAuthenticationLiveApiTest { + private String identity; - private String credential; + private String credential; - private String endpoint; + private String endpoint; - @BeforeMethod - public void setupToken() - { - identity = checkNotNull(System.getProperty("test.abiquo.identity"), "test.abiquo.identity"); - credential = - checkNotNull(System.getProperty("test.abiquo.credential"), "test.abiquo.credential"); - endpoint = checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); - } + @BeforeMethod + public void setupToken() { + identity = checkNotNull(System.getProperty("test.abiquo.identity"), "test.abiquo.identity"); + credential = checkNotNull(System.getProperty("test.abiquo.credential"), "test.abiquo.credential"); + endpoint = checkNotNull(System.getProperty("test.abiquo.endpoint"), "test.abiquo.endpoint"); + } - @Test - public void testAuthenticateWithToken() throws IOException - { - String token = getAuthtenticationToken(); + @Test + public void testAuthenticateWithToken() throws IOException { + String token = getAuthtenticationToken(); - Properties props = new Properties(); - props.setProperty(AbiquoProperties.CREDENTIAL_IS_TOKEN, "true"); + Properties props = new Properties(); + props.setProperty(AbiquoProperties.CREDENTIAL_IS_TOKEN, "true"); - // Create a new context that uses the generated token to perform the API calls - AbiquoContext tokenContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + // Create a new context that uses the generated token to perform the API + // calls + AbiquoContext tokenContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .endpoint(endpoint) // .credentials("token", token) // .modules(ImmutableSet. of(new SLF4JLoggingModule())) // .overrides(props) // .build(AbiquoContext.class); - try - { - // Perform a call to get the logged user and verify the identity - UserDto user = tokenContext.getApiContext().getApi().getAdminApi().getCurrentUser(); - assertNotNull(user); - assertEquals(user.getNick(), identity); - } - finally - { - if (tokenContext != null) - { - tokenContext.close(); - } - } - } + try { + // Perform a call to get the logged user and verify the identity + UserDto user = tokenContext.getApiContext().getApi().getAdminApi().getCurrentUser(); + assertNotNull(user); + assertEquals(user.getNick(), identity); + } finally { + if (tokenContext != null) { + tokenContext.close(); + } + } + } - @Test - public void testAuthenticateWithInvalidToken() throws IOException - { - String token = getAuthtenticationToken() + "INVALID"; + @Test + public void testAuthenticateWithInvalidToken() throws IOException { + String token = getAuthtenticationToken() + "INVALID"; - Properties props = new Properties(); - props.setProperty(AbiquoProperties.CREDENTIAL_IS_TOKEN, "true"); + Properties props = new Properties(); + props.setProperty(AbiquoProperties.CREDENTIAL_IS_TOKEN, "true"); - // Create a new context that uses the generated token to perform the API calls - AbiquoContext tokenContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + // Create a new context that uses the generated token to perform the API + // calls + AbiquoContext tokenContext = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .endpoint(endpoint) // .credentials("token", token) // .modules(ImmutableSet. of(new SLF4JLoggingModule())) // .overrides(props) // .build(AbiquoContext.class); - // Perform a call to get the logged user. It should fail - try - { - tokenContext.getApiContext().getApi().getAdminApi().getCurrentUser(); - } - catch (AuthorizationException ex) - { - // Test succeeded - return; - } - finally - { - if (tokenContext != null) - { - tokenContext.close(); - } - } + // Perform a call to get the logged user. It should fail + try { + tokenContext.getApiContext().getApi().getAdminApi().getCurrentUser(); + } catch (AuthorizationException ex) { + // Test succeeded + return; + } finally { + if (tokenContext != null) { + tokenContext.close(); + } + } - fail("Token authentication should have failed"); - } + fail("Token authentication should have failed"); + } - private String getAuthtenticationToken() - { - String token = null; + private String getAuthtenticationToken() { + String token = null; - AbiquoContext context = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + AbiquoContext context = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .endpoint(endpoint) // .credentials(identity, credential) // .modules(ImmutableSet. of(new SLF4JLoggingModule())) // .build(AbiquoContext.class); - try - { - // Create a request to authenticate to the API and generate the token - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build(); - String auth = AbiquoAuthentication.basicAuth(identity, credential); - request = request.toBuilder().replaceHeader(HttpHeaders.AUTHORIZATION, auth).build(); + try { + // Create a request to authenticate to the API and generate the token + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build(); + String auth = AbiquoAuthentication.basicAuth(identity, credential); + request = request.toBuilder().replaceHeader(HttpHeaders.AUTHORIZATION, auth).build(); - // Execute the request and read the generated token - HttpResponse response = context.utils().http().invoke(request); - assertEquals(response.getStatusCode(), 200); + // Execute the request and read the generated token + HttpResponse response = context.utils().http().invoke(request); + assertEquals(response.getStatusCode(), 200); - token = readAuthenticationToken(response); - assertNotNull(token); + token = readAuthenticationToken(response); + assertNotNull(token); - releasePayload(response); - } - finally - { - if (context != null) - { - context.close(); - } - } + releasePayload(response); + } finally { + if (context != null) { + context.close(); + } + } - return token; - } + return token; + } - private String readAuthenticationToken(final HttpResponse response) - { - Collection cookies = response.getHeaders().get(HttpHeaders.SET_COOKIE); - assertFalse(cookies.isEmpty()); + private String readAuthenticationToken(final HttpResponse response) { + Collection cookies = response.getHeaders().get(HttpHeaders.SET_COOKIE); + assertFalse(cookies.isEmpty()); - for (String cookie : cookies) - { - Cookie c = Cookie.valueOf(cookie); - if (c.getName().equals(AbiquoAuthentication.AUTH_TOKEN_NAME)) - { - return c.getValue(); - } - } + for (String cookie : cookies) { + Cookie c = Cookie.valueOf(cookie); + if (c.getName().equals(AbiquoAuthentication.AUTH_TOKEN_NAME)) { + return c.getValue(); + } + } - return null; - } + return null; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationTest.java index c340599d97..e93258e787 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AbiquoAuthenticationTest.java @@ -37,58 +37,45 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AbiquoAuthenticationTest") -public class AbiquoAuthenticationTest -{ +public class AbiquoAuthenticationTest { - public void testBasicAuthentication() throws NoSuchAlgorithmException, CertificateException - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + public void testBasicAuthentication() throws NoSuchAlgorithmException, CertificateException { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AbiquoAuthentication filter = new AbiquoAuthentication("identity", "credential", "false"); - HttpRequest filtered = filter.filter(request); - HttpRequest expected = - request - .toBuilder() - .replaceHeader(HttpHeaders.AUTHORIZATION, - AbiquoAuthentication.basicAuth("identity", "credential")).build(); + AbiquoAuthentication filter = new AbiquoAuthentication("identity", "credential", "false"); + HttpRequest filtered = filter.filter(request); + HttpRequest expected = request.toBuilder() + .replaceHeader(HttpHeaders.AUTHORIZATION, AbiquoAuthentication.basicAuth("identity", "credential")).build(); - assertFalse(filtered.getHeaders().containsKey(HttpHeaders.COOKIE)); - assertEquals(filtered, expected); - } + assertFalse(filtered.getHeaders().containsKey(HttpHeaders.COOKIE)); + assertEquals(filtered, expected); + } - @Test(expectedExceptions = NullPointerException.class) - public void testBasicAuthenticationWithoutIdentity() throws NoSuchAlgorithmException, CertificateException - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + @Test(expectedExceptions = NullPointerException.class) + public void testBasicAuthenticationWithoutIdentity() throws NoSuchAlgorithmException, CertificateException { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AbiquoAuthentication filter = new AbiquoAuthentication(null, "credential", "false"); - filter.filter(request); - } + AbiquoAuthentication filter = new AbiquoAuthentication(null, "credential", "false"); + filter.filter(request); + } - @Test(expectedExceptions = NullPointerException.class) - public void testBasicAuthenticationWithoutCredential() throws NoSuchAlgorithmException, CertificateException - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + @Test(expectedExceptions = NullPointerException.class) + public void testBasicAuthenticationWithoutCredential() throws NoSuchAlgorithmException, CertificateException { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AbiquoAuthentication filter = new AbiquoAuthentication("identity", null, "false"); - filter.filter(request); - } + AbiquoAuthentication filter = new AbiquoAuthentication("identity", null, "false"); + filter.filter(request); + } - public void testTokenAuthentication() throws NoSuchAlgorithmException, CertificateException - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + public void testTokenAuthentication() throws NoSuchAlgorithmException, CertificateException { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AbiquoAuthentication filter = new AbiquoAuthentication("token-identity", "token", "true"); - HttpRequest filtered = filter.filter(request); - HttpRequest expected = - request.toBuilder() - .replaceHeader(HttpHeaders.COOKIE, AbiquoAuthentication.tokenAuth("token")).build(); + AbiquoAuthentication filter = new AbiquoAuthentication("token-identity", "token", "true"); + HttpRequest filtered = filter.filter(request); + HttpRequest expected = request.toBuilder() + .replaceHeader(HttpHeaders.COOKIE, AbiquoAuthentication.tokenAuth("token")).build(); - assertFalse(filtered.getHeaders().containsKey(HttpHeaders.AUTHORIZATION)); - assertEquals(filtered, expected); - } + assertFalse(filtered.getHeaders().containsKey(HttpHeaders.AUTHORIZATION)); + assertEquals(filtered, expected); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaTypeTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaTypeTest.java index 02ce2827b9..73a29dd41c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaTypeTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/http/filters/AppendApiVersionToMediaTypeTest.java @@ -44,267 +44,231 @@ import com.google.common.collect.Multimap; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AppendApiVersionToMediaTypeTest") -public class AppendApiVersionToMediaTypeTest -{ +public class AppendApiVersionToMediaTypeTest { - public void testAppendVersionToNonPayloadHeadersWithoutHeaders() - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + public void testAppendVersionToNonPayloadHeadersWithoutHeaders() { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - assertTrue(filtered.getHeaders().get(HttpHeaders.ACCEPT).isEmpty()); - } + assertTrue(filtered.getHeaders().get(HttpHeaders.ACCEPT).isEmpty()); + } - public void testAppendVersionToNonPayloadHeadersWithStandardMediaType() - { - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/xml"); + public void testAppendVersionToNonPayloadHeadersWithStandardMediaType() { + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/xml"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - Collection contentType = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(contentType.size(), 1); - assertEquals(contentType.iterator().next(), "application/xml"); - } + Collection contentType = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(contentType.size(), 1); + assertEquals(contentType.iterator().next(), "application/xml"); + } - public void testAppendVersionToNonPayloadHeadersWithVersionInMediaType() - { - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + public void testAppendVersionToNonPayloadHeadersWithVersionInMediaType() { + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - Collection contentType = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(contentType.size(), 1); - assertEquals(contentType.iterator().next(), - "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); - } + Collection contentType = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(contentType.size(), 1); + assertEquals(contentType.iterator().next(), "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + } - public void testAppendVersionToNonPayloadHeadersWithoutVersionInMediaType() - { - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); + public void testAppendVersionToNonPayloadHeadersWithoutVersionInMediaType() { + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToNonPayloadHeaders(request); - Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(accept.size(), 1); - assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" - + AbiquoAsyncApi.API_VERSION); - } + Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(accept.size(), 1); + assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); + } - public void testAppendVersionToPayloadHeadersWithoutPayload() - { - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); + public void testAppendVersionToPayloadHeadersWithoutPayload() { + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - assertNull(filtered.getPayload()); - } + assertNull(filtered.getPayload()); + } - public void testAppendVersionToPayloadHeadersWithStandardPayload() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType("application/xml"); + public void testAppendVersionToPayloadHeadersWithStandardPayload() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/xml"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) - .build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) + .build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/xml"); - } + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/xml"); + } - public void testAppendVersionToPayloadHeadersWithDefaultPayload() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + public void testAppendVersionToPayloadHeadersWithDefaultPayload() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) - .build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) + .build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); + HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), - "application/unknown"); - } + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/unknown"); + } - public void testAppendVersionToPayloadHeadersWithVersionInPayload() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType( + public void testAppendVersionToPayloadHeadersWithVersionInPayload() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml;version=1.8.5"); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) + .build(); + + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); + + HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); + + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=1.8.5"); + } - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) - .build(); + public void testAppendVersionToPayloadHeadersWithoutVersionInPayload() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) + .build(); - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), - "application/vnd.abiquo.racks+xml;version=1.8.5"); - } + HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - public void testAppendVersionToPayloadHeadersWithoutVersionInPayload() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); - - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).payload(payload) - .build(); - - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.appendVersionToPayloadHeaders(request); - - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); - } + } - public void testFilterWithAcceptAndContentTypeWithVersion() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType( + public void testFilterWithAcceptAndContentTypeWithVersion() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .payload(payload).build(); + + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); + + HttpRequest filtered = filter.filter(request); + + Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(accept.size(), 1); + assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + } - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + public void testFilterWithAcceptAndContentTypeWithoutVersion() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .payload(payload).build(); + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .payload(payload).build(); - HttpRequest filtered = filter.filter(request); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(accept.size(), 1); - assertEquals(accept.iterator().next(), - "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); + HttpRequest filtered = filter.filter(request); - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), - "application/vnd.abiquo.racks+xml;version=2.1-SNAPSHOT"); - } + Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(accept.size(), 1); + assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); - public void testFilterWithAcceptAndContentTypeWithoutVersion() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); - - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); - - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .payload(payload).build(); - - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.filter(request); - - Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(accept.size(), 1); - assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" - + AbiquoAsyncApi.API_VERSION); - - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); - } + } - public void testFilterWithversionInAccept() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); + public void testFilterWithversionInAccept() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml"); - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=1.8.5"); + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml;version=1.8.5"); - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .payload(payload).build(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .payload(payload).build(); - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); - HttpRequest filtered = filter.filter(request); + HttpRequest filtered = filter.filter(request); - Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(accept.size(), 1); - assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=1.8.5"); + Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(accept.size(), 1); + assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=1.8.5"); - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); - } + } - public void testFilterWithversionInContentType() - { - Payload payload = Payloads.newByteArrayPayload(new byte[] {}); - payload.getContentMetadata().setContentType( + public void testFilterWithversionInContentType() { + Payload payload = Payloads.newByteArrayPayload(new byte[] {}); + payload.getContentMetadata().setContentType("application/vnd.abiquo.racks+xml;version=1.8.5"); + + Multimap headers = LinkedHashMultimap. create(); + headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) + .payload(payload).build(); + + AppendApiVersionToMediaType filter = new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType( + AbiquoAsyncApi.API_VERSION)); + + HttpRequest filtered = filter.filter(request); + + Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); + assertEquals(accept.size(), 1); + assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" + AbiquoAsyncApi.API_VERSION); + + assertEquals(filtered.getPayload().getContentMetadata().getContentType(), "application/vnd.abiquo.racks+xml;version=1.8.5"); - - Multimap headers = LinkedHashMultimap. create(); - headers.put(HttpHeaders.ACCEPT, "application/vnd.abiquo.racks+xml"); - - HttpRequest request = - HttpRequest.builder().method("GET").endpoint(URI.create("http://foo")).headers(headers) - .payload(payload).build(); - - AppendApiVersionToMediaType filter = - new AppendApiVersionToMediaType(new AppendApiVersionToAbiquoMimeType(AbiquoAsyncApi.API_VERSION)); - - HttpRequest filtered = filter.filter(request); - - Collection accept = filtered.getHeaders().get(HttpHeaders.ACCEPT); - assertEquals(accept.size(), 1); - assertEquals(accept.iterator().next(), "application/vnd.abiquo.racks+xml;version=" - + AbiquoAsyncApi.API_VERSION); - - assertEquals(filtered.getPayload().getContentMetadata().getContentType(), - "application/vnd.abiquo.racks+xml;version=1.8.5"); - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java index 0a45f0a2fd..b765fd0375 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/AsyncMonitorTest.java @@ -51,473 +51,426 @@ import com.google.common.eventbus.Subscribe; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AsyncMonitorTest") -public class AsyncMonitorTest -{ - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testStartMonitoringWithoutTimeout() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( +public class AsyncMonitorTest { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testStartMonitoringWithoutTimeout() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); + monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testStartMonitoringWithTimeout() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testStartMonitoringWithTimeout() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(100L); + monitor.startMonitoring(100L); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertTrue(monitor.getTimeout() > 100L); + assertNotNull(monitor.getFuture()); + assertNotNull(monitor.getTimeout()); + assertTrue(monitor.getTimeout() > 100L); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testIsTimeoutWhenNullTimeout() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testIsTimeoutWhenNullTimeout() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); - assertFalse(monitor.isTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); + assertFalse(monitor.isTimeout()); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testIsTimeoutReturnsFalseWhenNotFinished() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testIsTimeoutReturnsFalseWhenNotFinished() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(60000L); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertFalse(monitor.isTimeout()); + monitor.startMonitoring(60000L); + assertNotNull(monitor.getFuture()); + assertNotNull(monitor.getTimeout()); + assertFalse(monitor.isTimeout()); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testIsTimeoutReturnsTrueWhenFinished() throws InterruptedException - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testIsTimeoutReturnsTrueWhenFinished() throws InterruptedException { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(1L); - Thread.sleep(2L); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); - assertTrue(monitor.isTimeout()); + monitor.startMonitoring(1L); + Thread.sleep(2L); + assertNotNull(monitor.getFuture()); + assertNotNull(monitor.getTimeout()); + assertTrue(monitor.isTimeout()); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testStopMonitoringWhenFutureIsCancelled() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testStopMonitoringWhenFutureIsCancelled() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.stopMonitoring(); + monitor.stopMonitoring(); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testStopMonitoringWhenFutureIsDone() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(false); - expect(mockFuture.isDone()).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testStopMonitoringWhenFutureIsDone() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(false); + expect(mockFuture.isDone()).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.stopMonitoring(); + monitor.stopMonitoring(); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testStopMonitoringWhenFutureIsNotComplete() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(false); - expect(mockFuture.isDone()).andReturn(false); - expect(mockFuture.cancel(false)).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testStopMonitoringWhenFutureIsNotComplete() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(false); + expect(mockFuture.isDone()).andReturn(false); + expect(mockFuture.cancel(false)).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), - new EventBus()); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + new EventBus()); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.stopMonitoring(); + monitor.stopMonitoring(); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testMonitorAndDone() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testMonitorAndDone() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); + CoutingEventHandler handler = new CoutingEventHandler(); + EventBus eventBus = new EventBus(); + eventBus.register(handler); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), eventBus); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.DONE), + eventBus); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.run(); - assertEquals(handler.numCompletes, 1); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 0); + monitor.run(); + assertEquals(handler.numCompletes, 1); + assertEquals(handler.numFailures, 0); + assertEquals(handler.numTimeouts, 0); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testMonitorAndFail() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testMonitorAndFail() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); + CoutingEventHandler handler = new CoutingEventHandler(); + EventBus eventBus = new EventBus(); + eventBus.register(handler); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.FAILED), eventBus); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.FAILED), + eventBus); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 1); - assertEquals(handler.numTimeouts, 0); + monitor.run(); + assertEquals(handler.numCompletes, 0); + assertEquals(handler.numFailures, 1); + assertEquals(handler.numTimeouts, 0); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testMonitorAndContinueWithoutTimeout() - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testMonitorAndContinueWithoutTimeout() { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); + CoutingEventHandler handler = new CoutingEventHandler(); + EventBus eventBus = new EventBus(); + eventBus.register(handler); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), eventBus); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), + eventBus); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(null); - assertNotNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + monitor.startMonitoring(null); + assertNotNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 0); + monitor.run(); + assertEquals(handler.numCompletes, 0); + assertEquals(handler.numFailures, 0); + assertEquals(handler.numTimeouts, 0); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - public void testMonitorAndContinueWithtTimeout() throws InterruptedException - { - ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); - expect(mockFuture.isCancelled()).andReturn(true); + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void testMonitorAndContinueWithtTimeout() throws InterruptedException { + ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class); + expect(mockFuture.isCancelled()).andReturn(true); - ScheduledExecutorService schedulerMock = - EasyMock.createMock(ScheduledExecutorService.class); - expect( + ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class); + expect( schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(), - anyObject(TimeUnit.class))).andReturn(mockFuture); + anyObject(TimeUnit.class))).andReturn(mockFuture); - replay(mockFuture); - replay(schedulerMock); + replay(mockFuture); + replay(schedulerMock); - CoutingEventHandler handler = new CoutingEventHandler(); - EventBus eventBus = new EventBus(); - eventBus.register(handler); + CoutingEventHandler handler = new CoutingEventHandler(); + EventBus eventBus = new EventBus(); + eventBus.register(handler); - AsyncMonitor monitor = - mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), eventBus); + AsyncMonitor monitor = mockMonitor(schedulerMock, new Object(), mockFunction(MonitorStatus.CONTINUE), + eventBus); - assertNull(monitor.getFuture()); - assertNull(monitor.getTimeout()); + assertNull(monitor.getFuture()); + assertNull(monitor.getTimeout()); - monitor.startMonitoring(1L); - assertNotNull(monitor.getFuture()); - assertNotNull(monitor.getTimeout()); + monitor.startMonitoring(1L); + assertNotNull(monitor.getFuture()); + assertNotNull(monitor.getTimeout()); - Thread.sleep(2L); - monitor.run(); - assertEquals(handler.numCompletes, 0); - assertEquals(handler.numFailures, 0); - assertEquals(handler.numTimeouts, 1); + Thread.sleep(2L); + monitor.run(); + assertEquals(handler.numCompletes, 0); + assertEquals(handler.numFailures, 0); + assertEquals(handler.numTimeouts, 1); - verify(mockFuture); - verify(schedulerMock); - } + verify(mockFuture); + verify(schedulerMock); + } - @Test(expectedExceptions = NullPointerException.class) - public void testCreateMonitorWithNullObject() - { - mockMonitor(null, null, new Function() - { - @Override - public MonitorStatus apply(final Object input) - { - return MonitorStatus.DONE; - } - }, new EventBus()); - } + @Test(expectedExceptions = NullPointerException.class) + public void testCreateMonitorWithNullObject() { + mockMonitor(null, null, new Function() { + @Override + public MonitorStatus apply(final Object input) { + return MonitorStatus.DONE; + } + }, new EventBus()); + } - @Test(expectedExceptions = NullPointerException.class) - public void testCreateMonitorWithNullFunction() - { - mockMonitor(null, new Object(), null, new EventBus()); - } + @Test(expectedExceptions = NullPointerException.class) + public void testCreateMonitorWithNullFunction() { + mockMonitor(null, new Object(), null, new EventBus()); + } - @SuppressWarnings("unchecked") - private AsyncMonitor mockMonitor(final ScheduledExecutorService scheduler, - final Object object, final Function function, final EventBus eventBus) - { - BaseMonitoringService monitorService = - new BaseMonitoringService(EasyMock.createMock(RestContext.class), - scheduler, - 100L, - eventBus); + @SuppressWarnings("unchecked") + private AsyncMonitor mockMonitor(final ScheduledExecutorService scheduler, final Object object, + final Function function, final EventBus eventBus) { + BaseMonitoringService monitorService = new BaseMonitoringService(EasyMock.createMock(RestContext.class), + scheduler, 100L, eventBus); - return monitorService.new AsyncMonitor(object, function); - } + return monitorService.new AsyncMonitor(object, function); + } - private Function mockFunction(final MonitorStatus status) - { - return new Function() - { - @Override - public MonitorStatus apply(final Object input) - { - return status; - } - }; - } + private Function mockFunction(final MonitorStatus status) { + return new Function() { + @Override + public MonitorStatus apply(final Object input) { + return status; + } + }; + } - private static class CoutingEventHandler - { - public int numCompletes = 0; + private static class CoutingEventHandler { + public int numCompletes = 0; - public int numFailures = 0; + public int numFailures = 0; - public int numTimeouts = 0; + public int numTimeouts = 0; - @Subscribe - @SuppressWarnings("unused") - public void handle(final MonitorEvent< ? > event) - { - switch (event.getType()) - { - case COMPLETED: - numCompletes++; - break; - case FAILED: - numFailures++; - break; - case TIMEOUT: - numTimeouts++; - break; - } - } - } + @Subscribe + @SuppressWarnings("unused") + public void handle(final MonitorEvent event) { + switch (event.getType()) { + case COMPLETED: + numCompletes++; + break; + case FAILED: + numFailures++; + break; + case TIMEOUT: + numTimeouts++; + break; + } + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java index 40fc5fafa5..f79211a759 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoApiLiveApiTest.java @@ -30,76 +30,60 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "BaseAbiquoApiLiveApiTest", singleThreaded = true) -public abstract class BaseAbiquoApiLiveApiTest extends BaseAbiquoLiveApiTest -{ - /** The test environment. */ - protected static CloudTestEnvironment env; +public abstract class BaseAbiquoApiLiveApiTest extends BaseAbiquoLiveApiTest { + /** The test environment. */ + protected static CloudTestEnvironment env; - @Override - @BeforeSuite(groups = "api") - public void setupContext() - { - super.setupContext(); - setupEnvironment(); - } + @Override + @BeforeSuite(groups = "api") + public void setupContext() { + super.setupContext(); + setupEnvironment(); + } - // @BeforeSuite(groups = "ucs", dependsOnMethods = "setupContext") - protected void setupUcsEnvironment() throws Exception - { - if (env != null) - { - env.createUcsRack(); - } - } + // @BeforeSuite(groups = "ucs", dependsOnMethods = "setupContext") + protected void setupUcsEnvironment() throws Exception { + if (env != null) { + env.createUcsRack(); + } + } - @Override - @AfterSuite(groups = "api") - protected void tearDownContext() - { - try - { - tearDownEnvironment(); - } - finally - { - // Make sure we close the context - super.tearDownContext(); - } - } + @Override + @AfterSuite(groups = "api") + protected void tearDownContext() { + try { + tearDownEnvironment(); + } finally { + // Make sure we close the context + super.tearDownContext(); + } + } - protected void setupEnvironment() - { - if (env == null) - { - try - { - env = new CloudTestEnvironment(view); - env.setup(); - } - catch (Exception ex) - { - super.tearDownContext(); // Make sure we close the context setup fails - throw new RuntimeException("Could not create environment", ex); - } - } - } + protected void setupEnvironment() { + if (env == null) { + try { + env = new CloudTestEnvironment(view); + env.setup(); + } catch (Exception ex) { + super.tearDownContext(); // Make sure we close the context setup + // fails + throw new RuntimeException("Could not create environment", ex); + } + } + } - protected void tearDownEnvironment() - { - if (env != null) - { - try - { - env.tearDown(); + protected void tearDownEnvironment() { + if (env != null) { + try { + env.tearDown(); - // Wait a bit before closing context, to avoid executor shutdown while - // there are still open threads - Thread.sleep(1000L); - } - catch (Exception ex) - { - throw new RuntimeException("Could not tear down environment", ex); - } - } - } + // Wait a bit before closing context, to avoid executor shutdown + // while + // there are still open threads + Thread.sleep(1000L); + } catch (Exception ex) { + throw new RuntimeException("Could not tear down environment", ex); + } + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java index 290c4493fb..62c7fe3c49 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAbiquoLiveApiTest.java @@ -34,39 +34,34 @@ import com.google.common.reflect.TypeToken; * * @author Ignasi Barrera */ -public abstract class BaseAbiquoLiveApiTest extends BaseViewLiveTest -{ - public BaseAbiquoLiveApiTest() - { - provider = "abiquo"; - } +public abstract class BaseAbiquoLiveApiTest extends BaseViewLiveTest { + public BaseAbiquoLiveApiTest() { + provider = "abiquo"; + } - @Override - protected Properties setupProperties() - { - Properties overrides = super.setupProperties(); - overrides.put(Constants.PROPERTY_MAX_RETRIES, "0"); - overrides.put(Constants.PROPERTY_MAX_REDIRECTS, "0"); - // Wait at most one minute in Machine discovery - overrides.put("jclouds.timeouts.InfrastructureApi.discoverSingleMachine", "60000"); - overrides.put("jclouds.timeouts.InfrastructureApi.discoverMultipleMachines", "60000"); - overrides.put("jclouds.timeouts.InfrastructureApi.createMachine", "60000"); - overrides.put("jclouds.timeouts.InfrastructureApi.updateMachine", "60000"); - overrides.put("jclouds.timeouts.InfrastructureApi.checkMachineState", "60000"); - overrides.put("jclouds.timeouts.CloudApi.listVirtualMachines", "60000"); - return overrides; - } + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.put(Constants.PROPERTY_MAX_RETRIES, "0"); + overrides.put(Constants.PROPERTY_MAX_REDIRECTS, "0"); + // Wait at most one minute in Machine discovery + overrides.put("jclouds.timeouts.InfrastructureApi.discoverSingleMachine", "60000"); + overrides.put("jclouds.timeouts.InfrastructureApi.discoverMultipleMachines", "60000"); + overrides.put("jclouds.timeouts.InfrastructureApi.createMachine", "60000"); + overrides.put("jclouds.timeouts.InfrastructureApi.updateMachine", "60000"); + overrides.put("jclouds.timeouts.InfrastructureApi.checkMachineState", "60000"); + overrides.put("jclouds.timeouts.CloudApi.listVirtualMachines", "60000"); + return overrides; + } - @Override - protected LoggingModule getLoggingModule() - { - return new SLF4JLoggingModule(); - } + @Override + protected LoggingModule getLoggingModule() { + return new SLF4JLoggingModule(); + } - @Override - protected TypeToken viewType() - { - return TypeToken.of(AbiquoContext.class); - } + @Override + protected TypeToken viewType() { + return TypeToken.of(AbiquoContext.class); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java index f95f5deaef..4a2b2122bc 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseAdministrationServiceTest.java @@ -30,22 +30,19 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseAdministrationServiceTest") -public class BaseAdministrationServiceTest extends BaseInjectionTest -{ +public class BaseAdministrationServiceTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseAdministrationService service = - (BaseAdministrationService) injector.getInstance(AdministrationService.class); + public void testAllPropertiesInjected() { + BaseAdministrationService service = (BaseAdministrationService) injector.getInstance(AdministrationService.class); - assertNotNull(service.context); - assertNotNull(service.listDatacenters); - assertNotNull(service.listMachines); - assertNotNull(service.listEnterprises); - assertNotNull(service.listLicenses); - assertNotNull(service.listPrivileges); - assertNotNull(service.listRoles); - assertNotNull(service.currentUser); - assertNotNull(service.currentEnterprise); - } + assertNotNull(service.context); + assertNotNull(service.listDatacenters); + assertNotNull(service.listMachines); + assertNotNull(service.listEnterprises); + assertNotNull(service.listLicenses); + assertNotNull(service.listPrivileges); + assertNotNull(service.listRoles); + assertNotNull(service.currentUser); + assertNotNull(service.currentEnterprise); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java index e90806b064..c1e49628d1 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseCloudServiceTest.java @@ -30,16 +30,14 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseCloudServiceTest") -public class BaseCloudServiceTest extends BaseInjectionTest -{ +public class BaseCloudServiceTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseCloudService service = (BaseCloudService) injector.getInstance(CloudService.class); + public void testAllPropertiesInjected() { + BaseCloudService service = (BaseCloudService) injector.getInstance(CloudService.class); - assertNotNull(service.context); - assertNotNull(service.listVirtualDatacenters); - assertNotNull(service.listVirtualAppliances); - assertNotNull(service.listVirtualMachines); - } + assertNotNull(service.context); + assertNotNull(service.listVirtualDatacenters); + assertNotNull(service.listVirtualAppliances); + assertNotNull(service.listVirtualMachines); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java index 39a6fd318b..137c88194b 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseEventServiceTest.java @@ -30,13 +30,11 @@ import org.testng.annotations.Test; * @author Vivien Mahé */ @Test(groups = "unit", testName = "BaseEventServiceTest") -public class BaseEventServiceTest extends BaseInjectionTest -{ - public void testAllPropertiesInjected() - { - BaseEventService service = (BaseEventService) injector.getInstance(EventService.class); +public class BaseEventServiceTest extends BaseInjectionTest { + public void testAllPropertiesInjected() { + BaseEventService service = (BaseEventService) injector.getInstance(EventService.class); - assertNotNull(service.context); - assertNotNull(service.listEvents); - } + assertNotNull(service.context); + assertNotNull(service.listEvents); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseInjectionTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseInjectionTest.java index 3749a80e8e..23bad0ed4a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseInjectionTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseInjectionTest.java @@ -40,32 +40,27 @@ import com.google.inject.Module; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseEventServiceTest") -public class BaseInjectionTest -{ - protected Injector injector; +public class BaseInjectionTest { + protected Injector injector; - @BeforeClass - public void setup() - { - injector = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // + @BeforeClass + public void setup() { + injector = ContextBuilder.newBuilder(new AbiquoApiMetadata()) // .credentials("identity", "credential") // .modules(ImmutableSet. of(new NullLoggingModule())) // .overrides(buildProperties()) // .build(AbiquoContext.class).getUtils().getInjector(); - } + } - protected Properties buildProperties() - { - return new Properties(); - } + protected Properties buildProperties() { + return new Properties(); + } - @AfterClass - public void tearDown() throws Exception - { - if (injector != null) - { - injector.getInstance(Closer.class).close(); - } - } + @AfterClass + public void tearDown() throws Exception { + if (injector != null) { + injector.getInstance(Closer.class).close(); + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseMonitoringServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseMonitoringServiceTest.java index c5c8e36234..075894805e 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseMonitoringServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseMonitoringServiceTest.java @@ -33,77 +33,63 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseMonitoringServiceTest") -public class BaseMonitoringServiceTest extends BaseInjectionTest -{ - public void testAllPropertiesInjected() - { - BaseMonitoringService service = - (BaseMonitoringService) injector.getInstance(MonitoringService.class); +public class BaseMonitoringServiceTest extends BaseInjectionTest { + public void testAllPropertiesInjected() { + BaseMonitoringService service = (BaseMonitoringService) injector.getInstance(MonitoringService.class); - assertNotNull(service.context); - assertNotNull(service.scheduler); - assertNotNull(service.pollingDelay); - assertNotNull(service.eventBus); - } + assertNotNull(service.context); + assertNotNull(service.scheduler); + assertNotNull(service.pollingDelay); + assertNotNull(service.eventBus); + } - @Test(expectedExceptions = NullPointerException.class) - public void testAwaitCompletionWithNullFunction() - { - monitoringService().awaitCompletion(null, new Object[] {}); - } + @Test(expectedExceptions = NullPointerException.class) + public void testAwaitCompletionWithNullFunction() { + monitoringService().awaitCompletion(null, new Object[] {}); + } - public void testAwaitCompletionWithoutTasks() - { - BaseMonitoringService service = monitoringService(); + public void testAwaitCompletionWithoutTasks() { + BaseMonitoringService service = monitoringService(); - service.awaitCompletion(new MockMonitor()); - service.awaitCompletion(new MockMonitor(), (Object[]) null); - service.awaitCompletion(new MockMonitor(), new Object[] {}); - } + service.awaitCompletion(new MockMonitor()); + service.awaitCompletion(new MockMonitor(), (Object[]) null); + service.awaitCompletion(new MockMonitor(), new Object[] {}); + } - @Test(expectedExceptions = NullPointerException.class) - public void testMonitorWithNullCompleteCondition() - { - monitoringService().monitor(null, (Object[]) null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testMonitorWithNullCompleteCondition() { + monitoringService().monitor(null, (Object[]) null); + } - public void testMonitorWithoutTasks() - { - monitoringService().monitor(new MockMonitor()); - } + public void testMonitorWithoutTasks() { + monitoringService().monitor(new MockMonitor()); + } - public void testDelegateToVirtualMachineMonitor() - { - assertNotNull(monitoringService().getVirtualMachineMonitor()); - } + public void testDelegateToVirtualMachineMonitor() { + assertNotNull(monitoringService().getVirtualMachineMonitor()); + } - public void testDelegateToVirtualApplianceMonitor() - { - assertNotNull(monitoringService().getVirtualApplianceMonitor()); - } + public void testDelegateToVirtualApplianceMonitor() { + assertNotNull(monitoringService().getVirtualApplianceMonitor()); + } - public void testDelegateToAsyncTaskMonitor() - { - assertNotNull(monitoringService().getAsyncTaskMonitor()); - } + public void testDelegateToAsyncTaskMonitor() { + assertNotNull(monitoringService().getAsyncTaskMonitor()); + } - public void testDelegateToConversioMonitor() - { - assertNotNull(monitoringService().getConversionMonitor()); - } + public void testDelegateToConversioMonitor() { + assertNotNull(monitoringService().getConversionMonitor()); + } - private BaseMonitoringService monitoringService() - { - return injector.getInstance(BaseMonitoringService.class); - } + private BaseMonitoringService monitoringService() { + return injector.getInstance(BaseMonitoringService.class); + } - private static class MockMonitor implements Function - { - @Override - public MonitorStatus apply(final Object object) - { - return MonitorStatus.DONE; - } - } + private static class MockMonitor implements Function { + @Override + public MonitorStatus apply(final Object object) { + return MonitorStatus.DONE; + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseSearchServiceTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseSearchServiceTest.java index 1bd84c6e35..27f9e15edc 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseSearchServiceTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/internal/BaseSearchServiceTest.java @@ -30,13 +30,11 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseSearchServiceTest") -public class BaseSearchServiceTest extends BaseInjectionTest -{ +public class BaseSearchServiceTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseSearchService service = (BaseSearchService) injector.getInstance(SearchService.class); + public void testAllPropertiesInjected() { + BaseSearchService service = (BaseSearchService) injector.getInstance(SearchService.class); - assertNotNull(service.context); - } + assertNotNull(service.context); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitorTest.java index 4c7b626ce7..90352de997 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/AsyncTaskStatusMonitorTest.java @@ -37,82 +37,64 @@ import com.google.common.base.Function; * @author Serafin Sedano */ @Test(groups = "unit", testName = "AsyncTaskStatusMonitorTest") -public class AsyncTaskStatusMonitorTest -{ +public class AsyncTaskStatusMonitorTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new AsyncTaskStatusMonitor(); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new AsyncTaskStatusMonitor(); + function.apply(null); + } - public void testReturnDone() - { - TaskState[] states = {TaskState.FINISHED_SUCCESSFULLY}; + public void testReturnDone() { + TaskState[] states = { TaskState.FINISHED_SUCCESSFULLY }; - checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, - MonitorStatus.DONE); - } + checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - TaskState[] states = {TaskState.ABORTED, TaskState.FINISHED_UNSUCCESSFULLY}; + public void testReturnFail() { + TaskState[] states = { TaskState.ABORTED, TaskState.FINISHED_UNSUCCESSFULLY }; - checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, - MonitorStatus.FAILED); - } + checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - TaskState[] states = {TaskState.STARTED, TaskState.PENDING}; + public void testReturnContinue() { + TaskState[] states = { TaskState.STARTED, TaskState.PENDING }; - checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, - MonitorStatus.CONTINUE); + checkStatesReturn(new MockAsyncTask(), new AsyncTaskStatusMonitor(), states, MonitorStatus.CONTINUE); - checkStatesReturn(new MockAsyncTaskFailing(), new AsyncTaskStatusMonitor(), states, - MonitorStatus.CONTINUE); - } + checkStatesReturn(new MockAsyncTaskFailing(), new AsyncTaskStatusMonitor(), states, MonitorStatus.CONTINUE); + } - private void checkStatesReturn(final MockAsyncTask task, - final Function function, final TaskState[] states, - final MonitorStatus expectedStatus) - { - for (TaskState state : states) - { - task.setState(state); - assertEquals(function.apply(task), expectedStatus); - } - } + private void checkStatesReturn(final MockAsyncTask task, final Function function, + final TaskState[] states, final MonitorStatus expectedStatus) { + for (TaskState state : states) { + task.setState(state); + assertEquals(function.apply(task), expectedStatus); + } + } - private static class MockAsyncTask extends AsyncTask - { - @SuppressWarnings("unchecked") - public MockAsyncTask() - { - super(EasyMock.createMock(RestContext.class), new TaskDto()); - } + private static class MockAsyncTask extends AsyncTask { + @SuppressWarnings("unchecked") + public MockAsyncTask() { + super(EasyMock.createMock(RestContext.class), new TaskDto()); + } - @Override - public void refresh() - { - // Do not perform any API call - } + @Override + public void refresh() { + // Do not perform any API call + } - public void setState(final TaskState state) - { - target.setState(state); - } - } + public void setState(final TaskState state) { + target.setState(state); + } + } - private static class MockAsyncTaskFailing extends MockAsyncTask - { - @Override - public void refresh() - { - throw new RuntimeException("This mock class always fails to refresh"); - } + private static class MockAsyncTaskFailing extends MockAsyncTask { + @Override + public void refresh() { + throw new RuntimeException("This mock class always fails to refresh"); + } - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitorTest.java index 912e155041..40007eef2d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/ConversionStatusMonitorTest.java @@ -37,82 +37,64 @@ import com.google.common.base.Function; * @author Sergi Castro */ @Test(groups = "unit", testName = "ConversionStatusMonitorTest") -public class ConversionStatusMonitorTest -{ +public class ConversionStatusMonitorTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new ConversionStatusMonitor(); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new ConversionStatusMonitor(); + function.apply(null); + } - public void testReturnDone() - { - ConversionState[] states = {ConversionState.FINISHED}; + public void testReturnDone() { + ConversionState[] states = { ConversionState.FINISHED }; - checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, - MonitorStatus.DONE); - } + checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - ConversionState[] states = {ConversionState.FAILED}; + public void testReturnFail() { + ConversionState[] states = { ConversionState.FAILED }; - checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, - MonitorStatus.FAILED); - } + checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - ConversionState[] states = {ConversionState.ENQUEUED}; + public void testReturnContinue() { + ConversionState[] states = { ConversionState.ENQUEUED }; - checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, - MonitorStatus.CONTINUE); + checkStatesReturn(new MockConversion(), new ConversionStatusMonitor(), states, MonitorStatus.CONTINUE); - checkStatesReturn(new MockConversionFailing(), new ConversionStatusMonitor(), states, - MonitorStatus.CONTINUE); - } + checkStatesReturn(new MockConversionFailing(), new ConversionStatusMonitor(), states, MonitorStatus.CONTINUE); + } - private void checkStatesReturn(final MockConversion task, - final Function function, final ConversionState[] states, - final MonitorStatus expectedStatus) - { - for (ConversionState state : states) - { - task.setState(state); - assertEquals(function.apply(task), expectedStatus); - } - } + private void checkStatesReturn(final MockConversion task, final Function function, + final ConversionState[] states, final MonitorStatus expectedStatus) { + for (ConversionState state : states) { + task.setState(state); + assertEquals(function.apply(task), expectedStatus); + } + } - private static class MockConversion extends Conversion - { - @SuppressWarnings("unchecked") - public MockConversion() - { - super(EasyMock.createMock(RestContext.class), new ConversionDto()); - } + private static class MockConversion extends Conversion { + @SuppressWarnings("unchecked") + public MockConversion() { + super(EasyMock.createMock(RestContext.class), new ConversionDto()); + } - @Override - public void refresh() - { - // Do not perform any API call - } + @Override + public void refresh() { + // Do not perform any API call + } - public void setState(final ConversionState state) - { - target.setState(state); - } - } + public void setState(final ConversionState state) { + target.setState(state); + } + } - private static class MockConversionFailing extends MockConversion - { - @Override - public void refresh() - { - throw new RuntimeException("This mock class always fails to refresh"); - } + private static class MockConversionFailing extends MockConversion { + @Override + public void refresh() { + throw new RuntimeException("This mock class always fails to refresh"); + } - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitorTest.java index 261597887a..31c2831304 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceDeployMonitorTest.java @@ -37,85 +37,68 @@ import com.google.common.base.Function; * @author Serafin Sedano */ @Test(groups = "unit", testName = "VirtualApplianceDeployMonitorTest") -public class VirtualApplianceDeployMonitorTest -{ +public class VirtualApplianceDeployMonitorTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new VirtualApplianceDeployMonitor(); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new VirtualApplianceDeployMonitor(); + function.apply(null); + } - public void testReturnDone() - { - VirtualApplianceState[] states = {VirtualApplianceState.DEPLOYED}; + public void testReturnDone() { + VirtualApplianceState[] states = { VirtualApplianceState.DEPLOYED }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, - MonitorStatus.DONE); - } + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - VirtualApplianceState[] states = - {VirtualApplianceState.NEEDS_SYNC, VirtualApplianceState.UNKNOWN, - VirtualApplianceState.NOT_DEPLOYED}; + public void testReturnFail() { + VirtualApplianceState[] states = { VirtualApplianceState.NEEDS_SYNC, VirtualApplianceState.UNKNOWN, + VirtualApplianceState.NOT_DEPLOYED }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, - MonitorStatus.FAILED); - } + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - VirtualApplianceState[] states = {VirtualApplianceState.LOCKED}; + public void testReturnContinue() { + VirtualApplianceState[] states = { VirtualApplianceState.LOCKED }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.CONTINUE); + + checkStatesReturn(new MockVirtualApplianceFailing(), new VirtualApplianceDeployMonitor(), states, MonitorStatus.CONTINUE); + } - checkStatesReturn(new MockVirtualApplianceFailing(), new VirtualApplianceDeployMonitor(), - states, MonitorStatus.CONTINUE); - } + private void checkStatesReturn(final MockVirtualAppliance vapp, + final Function function, final VirtualApplianceState[] states, + final MonitorStatus expectedStatus) { + for (VirtualApplianceState state : states) { + vapp.setState(state); + assertEquals(function.apply(vapp), expectedStatus); + } + } - private void checkStatesReturn(final MockVirtualAppliance vapp, - final Function function, - final VirtualApplianceState[] states, final MonitorStatus expectedStatus) - { - for (VirtualApplianceState state : states) - { - vapp.setState(state); - assertEquals(function.apply(vapp), expectedStatus); - } - } + private static class MockVirtualAppliance extends VirtualAppliance { + private VirtualApplianceState state; - private static class MockVirtualAppliance extends VirtualAppliance - { - private VirtualApplianceState state; + @SuppressWarnings("unchecked") + public MockVirtualAppliance() { + super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); + } - @SuppressWarnings("unchecked") - public MockVirtualAppliance() - { - super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); - } + @Override + public VirtualApplianceState getState() { + return state; + } - @Override - public VirtualApplianceState getState() - { - return state; - } + public void setState(final VirtualApplianceState state) { + this.state = state; + } + } - public void setState(final VirtualApplianceState state) - { - this.state = state; - } - } + private static class MockVirtualApplianceFailing extends MockVirtualAppliance { + @Override + public VirtualApplianceState getState() { + throw new RuntimeException("This mock class always fails to get the state"); + } - private static class MockVirtualApplianceFailing extends MockVirtualAppliance - { - @Override - public VirtualApplianceState getState() - { - throw new RuntimeException("This mock class always fails to get the state"); - } - - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitorTest.java index 103b76b457..c2b9b3ce8d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualApplianceUndeployMonitorTest.java @@ -37,85 +37,69 @@ import com.google.common.base.Function; * @author Serafin Sedano */ @Test(groups = "unit", testName = "VirtualApplianceUndeployMonitorTest") -public class VirtualApplianceUndeployMonitorTest -{ +public class VirtualApplianceUndeployMonitorTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new VirtualApplianceUndeployMonitor(); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new VirtualApplianceUndeployMonitor(); + function.apply(null); + } - public void testReturnDone() - { - VirtualApplianceState[] states = {VirtualApplianceState.NOT_DEPLOYED}; + public void testReturnDone() { + VirtualApplianceState[] states = { VirtualApplianceState.NOT_DEPLOYED }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), - states, MonitorStatus.DONE); - } + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - VirtualApplianceState[] states = - {VirtualApplianceState.DEPLOYED, VirtualApplianceState.NEEDS_SYNC, - VirtualApplianceState.UNKNOWN}; + public void testReturnFail() { + VirtualApplianceState[] states = { VirtualApplianceState.DEPLOYED, VirtualApplianceState.NEEDS_SYNC, + VirtualApplianceState.UNKNOWN }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), - states, MonitorStatus.FAILED); - } + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - VirtualApplianceState[] states = {VirtualApplianceState.LOCKED}; + public void testReturnContinue() { + VirtualApplianceState[] states = { VirtualApplianceState.LOCKED }; - checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), - states, MonitorStatus.CONTINUE); + checkStatesReturn(new MockVirtualAppliance(), new VirtualApplianceUndeployMonitor(), states, + MonitorStatus.CONTINUE); - checkStatesReturn(new MockVirtualApplianceFailing(), new VirtualApplianceUndeployMonitor(), - states, MonitorStatus.CONTINUE); - } + checkStatesReturn(new MockVirtualApplianceFailing(), new VirtualApplianceUndeployMonitor(), states, + MonitorStatus.CONTINUE); + } - private void checkStatesReturn(final MockVirtualAppliance vapp, - final Function function, - final VirtualApplianceState[] states, final MonitorStatus expectedStatus) - { - for (VirtualApplianceState state : states) - { - vapp.setState(state); - assertEquals(function.apply(vapp), expectedStatus); - } - } + private void checkStatesReturn(final MockVirtualAppliance vapp, + final Function function, final VirtualApplianceState[] states, + final MonitorStatus expectedStatus) { + for (VirtualApplianceState state : states) { + vapp.setState(state); + assertEquals(function.apply(vapp), expectedStatus); + } + } - private static class MockVirtualAppliance extends VirtualAppliance - { - private VirtualApplianceState state; + private static class MockVirtualAppliance extends VirtualAppliance { + private VirtualApplianceState state; - @SuppressWarnings("unchecked") - public MockVirtualAppliance() - { - super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); - } + @SuppressWarnings("unchecked") + public MockVirtualAppliance() { + super(EasyMock.createMock(RestContext.class), new VirtualApplianceDto()); + } - @Override - public VirtualApplianceState getState() - { - return state; - } + @Override + public VirtualApplianceState getState() { + return state; + } - public void setState(final VirtualApplianceState state) - { - this.state = state; - } - } + public void setState(final VirtualApplianceState state) { + this.state = state; + } + } - private static class MockVirtualApplianceFailing extends MockVirtualAppliance - { - @Override - public VirtualApplianceState getState() - { - throw new RuntimeException("This mock class always fails to get the state"); - } + private static class MockVirtualApplianceFailing extends MockVirtualAppliance { + @Override + public VirtualApplianceState getState() { + throw new RuntimeException("This mock class always fails to get the state"); + } - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitorTest.java index 2f0d08dbf3..566e91bc13 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineDeployMonitorTest.java @@ -37,85 +37,66 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineDeployMonitorTest") -public class VirtualMachineDeployMonitorTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new VirtualMachineDeployMonitor(); - function.apply(null); - } +public class VirtualMachineDeployMonitorTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new VirtualMachineDeployMonitor(); + function.apply(null); + } - public void testReturnDone() - { - VirtualMachineState[] states = {VirtualMachineState.ON}; + public void testReturnDone() { + VirtualMachineState[] states = { VirtualMachineState.ON }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, - MonitorStatus.DONE); - } + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - VirtualMachineState[] states = - {VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN}; + public void testReturnFail() { + VirtualMachineState[] states = { VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, - MonitorStatus.FAILED); - } + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - VirtualMachineState[] states = - {VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, - VirtualMachineState.LOCKED, VirtualMachineState.OFF, VirtualMachineState.PAUSED}; + public void testReturnContinue() { + VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, + VirtualMachineState.LOCKED, VirtualMachineState.OFF, VirtualMachineState.PAUSED }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineDeployMonitor(), states, MonitorStatus.CONTINUE); + + checkStatesReturn(new MockVirtualMachineFailing(), new VirtualMachineDeployMonitor(), states, MonitorStatus.CONTINUE); + } - checkStatesReturn(new MockVirtualMachineFailing(), new VirtualMachineDeployMonitor(), - states, MonitorStatus.CONTINUE); - } + private void checkStatesReturn(final MockVirtualMachine vm, final Function function, + final VirtualMachineState[] states, final MonitorStatus expectedStatus) { + for (VirtualMachineState state : states) { + vm.setState(state); + assertEquals(function.apply(vm), expectedStatus); + } + } - private void checkStatesReturn(final MockVirtualMachine vm, - final Function function, final VirtualMachineState[] states, - final MonitorStatus expectedStatus) - { - for (VirtualMachineState state : states) - { - vm.setState(state); - assertEquals(function.apply(vm), expectedStatus); - } - } + private static class MockVirtualMachine extends VirtualMachine { + private VirtualMachineState state; - private static class MockVirtualMachine extends VirtualMachine - { - private VirtualMachineState state; + @SuppressWarnings("unchecked") + public MockVirtualMachine() { + super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); + } - @SuppressWarnings("unchecked") - public MockVirtualMachine() - { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } + @Override + public VirtualMachineState getState() { + return state; + } - @Override - public VirtualMachineState getState() - { - return state; - } + public void setState(final VirtualMachineState state) { + this.state = state; + } + } - public void setState(final VirtualMachineState state) - { - this.state = state; - } - } + private static class MockVirtualMachineFailing extends MockVirtualMachine { + @Override + public VirtualMachineState getState() { + throw new RuntimeException("This mock class always fails to get the state"); + } - private static class MockVirtualMachineFailing extends MockVirtualMachine - { - @Override - public VirtualMachineState getState() - { - throw new RuntimeException("This mock class always fails to get the state"); - } - - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitorTest.java index 0ec4307f2a..fdc7e294b6 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineStateMonitorTest.java @@ -37,84 +37,68 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineStateMonitorTest") -public class VirtualMachineStateMonitorTest -{ - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullState() - { - new VirtualMachineStateMonitor(null); - } +public class VirtualMachineStateMonitorTest { + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullState() { + new VirtualMachineStateMonitor(null); + } - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = - new VirtualMachineStateMonitor(VirtualMachineState.ON); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new VirtualMachineStateMonitor(VirtualMachineState.ON); + function.apply(null); + } - public void testReturnDone() - { - VirtualMachineState[] states = {VirtualMachineState.ON}; + public void testReturnDone() { + VirtualMachineState[] states = { VirtualMachineState.ON }; - checkStatesReturn(new MockVirtualMachine(), - new VirtualMachineStateMonitor(VirtualMachineState.ON), states, MonitorStatus.DONE); - } + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineStateMonitor(VirtualMachineState.ON), states, + MonitorStatus.DONE); + } - public void testReturnContinue() - { - VirtualMachineState[] states = - {VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, + public void testReturnContinue() { + VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.CONFIGURED, VirtualMachineState.LOCKED, VirtualMachineState.OFF, VirtualMachineState.PAUSED, - VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN}; + VirtualMachineState.NOT_ALLOCATED, VirtualMachineState.UNKNOWN }; - checkStatesReturn(new MockVirtualMachine(), - new VirtualMachineStateMonitor(VirtualMachineState.ON), states, MonitorStatus.CONTINUE); + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineStateMonitor(VirtualMachineState.ON), states, + MonitorStatus.CONTINUE); - checkStatesReturn(new MockVirtualMachineFailing(), - new VirtualMachineStateMonitor(VirtualMachineState.ON), states, MonitorStatus.CONTINUE); - } + checkStatesReturn(new MockVirtualMachineFailing(), new VirtualMachineStateMonitor(VirtualMachineState.ON), + states, MonitorStatus.CONTINUE); + } - private void checkStatesReturn(final MockVirtualMachine vm, - final Function function, final VirtualMachineState[] states, - final MonitorStatus expectedStatus) - { - for (VirtualMachineState state : states) - { - vm.setState(state); - assertEquals(function.apply(vm), expectedStatus); - } - } + private void checkStatesReturn(final MockVirtualMachine vm, final Function function, + final VirtualMachineState[] states, final MonitorStatus expectedStatus) { + for (VirtualMachineState state : states) { + vm.setState(state); + assertEquals(function.apply(vm), expectedStatus); + } + } - private static class MockVirtualMachine extends VirtualMachine - { - private VirtualMachineState state; + private static class MockVirtualMachine extends VirtualMachine { + private VirtualMachineState state; - @SuppressWarnings("unchecked") - public MockVirtualMachine() - { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } + @SuppressWarnings("unchecked") + public MockVirtualMachine() { + super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); + } - @Override - public VirtualMachineState getState() - { - return state; - } + @Override + public VirtualMachineState getState() { + return state; + } - public void setState(final VirtualMachineState state) - { - this.state = state; - } - } + public void setState(final VirtualMachineState state) { + this.state = state; + } + } - private static class MockVirtualMachineFailing extends MockVirtualMachine - { - @Override - public VirtualMachineState getState() - { - throw new RuntimeException("This mock class always fails to get the state"); - } + private static class MockVirtualMachineFailing extends MockVirtualMachine { + @Override + public VirtualMachineState getState() { + throw new RuntimeException("This mock class always fails to get the state"); + } - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitorTest.java index e5a2dba938..27ce26b8be 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/functions/VirtualMachineUndeployMonitorTest.java @@ -37,85 +37,67 @@ import com.google.common.base.Function; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "VirtualMachineUndeployMonitorTest") -public class VirtualMachineUndeployMonitorTest -{ +public class VirtualMachineUndeployMonitorTest { - @Test(expectedExceptions = NullPointerException.class) - public void testInvalidNullArgument() - { - Function function = new VirtualMachineUndeployMonitor(); - function.apply(null); - } + @Test(expectedExceptions = NullPointerException.class) + public void testInvalidNullArgument() { + Function function = new VirtualMachineUndeployMonitor(); + function.apply(null); + } - public void testReturnDone() - { - VirtualMachineState[] states = {VirtualMachineState.NOT_ALLOCATED}; + public void testReturnDone() { + VirtualMachineState[] states = { VirtualMachineState.NOT_ALLOCATED }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, - MonitorStatus.DONE); - } + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.DONE); + } - public void testReturnFail() - { - VirtualMachineState[] states = - {VirtualMachineState.ON, VirtualMachineState.CONFIGURED, VirtualMachineState.OFF, - VirtualMachineState.PAUSED, VirtualMachineState.UNKNOWN}; + public void testReturnFail() { + VirtualMachineState[] states = { VirtualMachineState.ON, VirtualMachineState.CONFIGURED, VirtualMachineState.OFF, + VirtualMachineState.PAUSED, VirtualMachineState.UNKNOWN }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, - MonitorStatus.FAILED); - } + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.FAILED); + } - public void testReturnContinue() - { - VirtualMachineState[] states = {VirtualMachineState.ALLOCATED, VirtualMachineState.LOCKED}; + public void testReturnContinue() { + VirtualMachineState[] states = { VirtualMachineState.ALLOCATED, VirtualMachineState.LOCKED }; - checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, + checkStatesReturn(new MockVirtualMachine(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.CONTINUE); + + checkStatesReturn(new MockVirtualMachineFailing(), new VirtualMachineUndeployMonitor(), states, MonitorStatus.CONTINUE); + } - checkStatesReturn(new MockVirtualMachineFailing(), new VirtualMachineUndeployMonitor(), - states, MonitorStatus.CONTINUE); - } + private void checkStatesReturn(final MockVirtualMachine vm, final Function function, + final VirtualMachineState[] states, final MonitorStatus expectedStatus) { + for (VirtualMachineState state : states) { + vm.setState(state); + assertEquals(function.apply(vm), expectedStatus); + } + } - private void checkStatesReturn(final MockVirtualMachine vm, - final Function function, final VirtualMachineState[] states, - final MonitorStatus expectedStatus) - { - for (VirtualMachineState state : states) - { - vm.setState(state); - assertEquals(function.apply(vm), expectedStatus); - } - } + private static class MockVirtualMachine extends VirtualMachine { + private VirtualMachineState state; - private static class MockVirtualMachine extends VirtualMachine - { - private VirtualMachineState state; + @SuppressWarnings("unchecked") + public MockVirtualMachine() { + super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); + } - @SuppressWarnings("unchecked") - public MockVirtualMachine() - { - super(EasyMock.createMock(RestContext.class), new VirtualMachineWithNodeExtendedDto()); - } + @Override + public VirtualMachineState getState() { + return state; + } - @Override - public VirtualMachineState getState() - { - return state; - } + public void setState(final VirtualMachineState state) { + this.state = state; + } + } - public void setState(final VirtualMachineState state) - { - this.state = state; - } - } + private static class MockVirtualMachineFailing extends MockVirtualMachine { + @Override + public VirtualMachineState getState() { + throw new RuntimeException("This mock class always fails to get the state"); + } - private static class MockVirtualMachineFailing extends MockVirtualMachine - { - @Override - public VirtualMachineState getState() - { - throw new RuntimeException("This mock class always fails to get the state"); - } - - } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitorTest.java index 729148a220..af6857bd63 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseAsyncTaskMonitorTest.java @@ -31,14 +31,11 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseAsyncTaskMonitorTest") -public class BaseAsyncTaskMonitorTest extends BaseInjectionTest -{ +public class BaseAsyncTaskMonitorTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseAsyncTaskMonitor monitor = - (BaseAsyncTaskMonitor) injector.getInstance(AsyncTaskMonitor.class); + public void testAllPropertiesInjected() { + BaseAsyncTaskMonitor monitor = (BaseAsyncTaskMonitor) injector.getInstance(AsyncTaskMonitor.class); - assertNotNull(monitor.taskMonitor); - } + assertNotNull(monitor.taskMonitor); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitorTest.java index eb8bf9f160..6e5e62a1b6 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualApplianceMonitorTest.java @@ -31,15 +31,13 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseVirtualApplianceMonitorTest") -public class BaseVirtualApplianceMonitorTest extends BaseInjectionTest -{ +public class BaseVirtualApplianceMonitorTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseVirtualApplianceMonitor monitor = - (BaseVirtualApplianceMonitor) injector.getInstance(VirtualApplianceMonitor.class); + public void testAllPropertiesInjected() { + BaseVirtualApplianceMonitor monitor = (BaseVirtualApplianceMonitor) injector + .getInstance(VirtualApplianceMonitor.class); - assertNotNull(monitor.deployMonitor); - assertNotNull(monitor.undeployMonitor); - } + assertNotNull(monitor.deployMonitor); + assertNotNull(monitor.undeployMonitor); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitorTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitorTest.java index a07d75b31a..6c17a59ada 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitorTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/monitor/internal/BaseVirtualMachineMonitorTest.java @@ -31,15 +31,12 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "BaseVirtualMachineMonitorTest") -public class BaseVirtualMachineMonitorTest extends BaseInjectionTest -{ +public class BaseVirtualMachineMonitorTest extends BaseInjectionTest { - public void testAllPropertiesInjected() - { - BaseVirtualMachineMonitor monitor = - (BaseVirtualMachineMonitor) injector.getInstance(VirtualMachineMonitor.class); + public void testAllPropertiesInjected() { + BaseVirtualMachineMonitor monitor = (BaseVirtualMachineMonitor) injector.getInstance(VirtualMachineMonitor.class); - assertNotNull(monitor.deployMonitor); - assertNotNull(monitor.undeployMonitor); - } + assertNotNull(monitor.deployMonitor); + assertNotNull(monitor.undeployMonitor); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/reference/AbiquoTestConstants.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/reference/AbiquoTestConstants.java index 0a3fcf41e0..b909d9b4d9 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/reference/AbiquoTestConstants.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/reference/AbiquoTestConstants.java @@ -24,8 +24,7 @@ package org.jclouds.abiquo.reference; * * @author Ignasi Barrera */ -public interface AbiquoTestConstants -{ - /** The prefix for test object names. */ - public static final String PREFIX = "JC-"; +public interface AbiquoTestConstants { + /** The prefix for test object names. */ + public static final String PREFIX = "JC-"; } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java index fc49bb2125..18bc306826 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java @@ -39,33 +39,29 @@ import com.google.inject.TypeLiteral; * @author Ignasi Barrera */ @Test(groups = "unit", testName = "AbiquoHttpAsyncClientTest") -public class AbiquoHttpAsyncClientTest extends BaseAbiquoAsyncApiTest -{ - public void testGet() throws SecurityException, NoSuchMethodException, IOException - { - RESTLink link = new RESTLink("edit", "http://foo/bar"); - link.setType(DatacentersDto.BASE_MEDIA_TYPE); +public class AbiquoHttpAsyncClientTest extends BaseAbiquoAsyncApiTest { + public void testGet() throws SecurityException, NoSuchMethodException, IOException { + RESTLink link = new RESTLink("edit", "http://foo/bar"); + link.setType(DatacentersDto.BASE_MEDIA_TYPE); - Method method = AbiquoHttpAsyncClient.class.getMethod("get", RESTLink.class); - GeneratedHttpRequest request = processor.createRequest(method, link); + Method method = AbiquoHttpAsyncClient.class.getMethod("get", RESTLink.class); + GeneratedHttpRequest request = processor.createRequest(method, link); - assertRequestLineEquals(request, "GET http://foo/bar HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); - assertPayloadEquals(request, null, null, false); + assertRequestLineEquals(request, "GET http://foo/bar HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: " + DatacentersDto.BASE_MEDIA_TYPE + "\n"); + assertPayloadEquals(request, null, null, false); - assertResponseParserClassEquals(method, request, IdentityFunction.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + assertResponseParserClassEquals(method, request, IdentityFunction.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - checkFilters(request); - } + checkFilters(request); + } - @Override - protected TypeLiteral> createTypeLiteral() - { - return new TypeLiteral>() - { - }; - } + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/BaseAbiquoStrategyLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/BaseAbiquoStrategyLiveApiTest.java index 06d10f1c13..a84bf558e9 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/BaseAbiquoStrategyLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/BaseAbiquoStrategyLiveApiTest.java @@ -27,8 +27,7 @@ import org.testng.annotations.BeforeClass; * * @author Ignasi Barrera */ -public abstract class BaseAbiquoStrategyLiveApiTest extends BaseAbiquoApiLiveApiTest -{ - @BeforeClass(groups = "api") - protected abstract void setupStrategy(); +public abstract class BaseAbiquoStrategyLiveApiTest extends BaseAbiquoApiLiveApiTest { + @BeforeClass(groups = "api") + protected abstract void setupStrategy(); } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java index 9e3ec7fd4a..5e6aabbb1e 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/admin/internal/ListRolesImplLiveApiTest.java @@ -36,35 +36,30 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListRolesImplLiveApiTest") -public class ListRolesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListRolesImpl strategy; +public class ListRolesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListRolesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListRolesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListRolesImpl.class); + } - public void testExecute() - { - Iterable roles = strategy.execute(); - assertNotNull(roles); - assertTrue(size(roles) > 0); - } + public void testExecute() { + Iterable roles = strategy.execute(); + assertNotNull(roles); + assertTrue(size(roles) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable roles = strategy.execute(RolePredicates.name("UNEXISTING")); - assertNotNull(roles); - assertEquals(size(roles), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable roles = strategy.execute(RolePredicates.name("UNEXISTING")); + assertNotNull(roles); + assertEquals(size(roles), 0); + } - public void testExecutePredicateWithResults() - { - Iterable roles = strategy.execute(RolePredicates.name(env.role.getName())); - assertNotNull(roles); - assertEquals(size(roles), 1); - } + public void testExecutePredicateWithResults() { + Iterable roles = strategy.execute(RolePredicates.name(env.role.getName())); + assertNotNull(roles); + assertEquals(size(roles), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java index 997a73da9a..70d1cc9637 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListAttachedNicsImplLiveApiTest.java @@ -44,71 +44,58 @@ import com.google.common.collect.Lists; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListAttachedNicsImplLiveApiTest") -public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListAttachedNicsImpl strategy; +public class ListAttachedNicsImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListAttachedNicsImpl strategy; - private PrivateIp privateIp; + private PrivateIp privateIp; - private ExternalIp externalIp; + private ExternalIp externalIp; - private PublicIp publicIp; + private PublicIp publicIp; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = - env.context.getUtils().getInjector().getInstance(ListAttachedNicsImpl.class); + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListAttachedNicsImpl.class); - privateIp = env.privateNetwork.listUnusedIps().get(0); - assertNotNull(privateIp); + privateIp = env.privateNetwork.listUnusedIps().get(0); + assertNotNull(privateIp); - externalIp = env.externalNetwork.listUnusedIps().get(0); - assertNotNull(externalIp); + externalIp = env.externalNetwork.listUnusedIps().get(0); + assertNotNull(externalIp); - publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0); - env.virtualDatacenter.purchasePublicIp(publicIp); - publicIp = - env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp - .getIp())); - assertNotNull(publicIp); + publicIp = env.virtualDatacenter.listAvailablePublicIps().get(0); + env.virtualDatacenter.purchasePublicIp(publicIp); + publicIp = env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(publicIp.getIp())); + assertNotNull(publicIp); - env.virtualMachine.setNics( - Lists.> newArrayList(privateIp, externalIp, publicIp), + env.virtualMachine.setNics(Lists.> newArrayList(privateIp, externalIp, publicIp), Lists. newArrayList(env.unmanagedNetwork)); - } + } - @AfterClass(groups = "api") - protected void tearDownStrategy() - { - env.virtualMachine.setNics(Lists.> newArrayList(privateIp)); - String address = publicIp.getIp(); - env.virtualDatacenter.releaseePublicIp(publicIp); - assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates - . address(address))); - } + @AfterClass(groups = "api") + protected void tearDownStrategy() { + env.virtualMachine.setNics(Lists.> newArrayList(privateIp)); + String address = publicIp.getIp(); + env.virtualDatacenter.releaseePublicIp(publicIp); + assertNull(env.virtualDatacenter.findPurchasedPublicIp(IpPredicates. address(address))); + } - public void testExecute() - { - Iterable> vapps = strategy.execute(env.virtualMachine); - assertNotNull(vapps); - assertTrue(size(vapps) == 4); - } + public void testExecute() { + Iterable> vapps = strategy.execute(env.virtualMachine); + assertNotNull(vapps); + assertTrue(size(vapps) == 4); + } - public void testExecutePredicateWithoutResults() - { - Iterable> vapps = - strategy.execute(env.virtualMachine, IpPredicates.address("UNEXISTING")); - assertNotNull(vapps); - assertEquals(size(vapps), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable> vapps = strategy.execute(env.virtualMachine, IpPredicates.address("UNEXISTING")); + assertNotNull(vapps); + assertEquals(size(vapps), 0); + } - public void testExecutePredicateWithResults() - { - Iterable> vapps = - strategy.execute(env.virtualMachine, IpPredicates.address(publicIp.getIp())); - assertNotNull(vapps); - assertEquals(size(vapps), 1); - } + public void testExecutePredicateWithResults() { + Iterable> vapps = strategy.execute(env.virtualMachine, IpPredicates.address(publicIp.getIp())); + assertNotNull(vapps); + assertEquals(size(vapps), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java index faa063355c..c577de9b41 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualAppliancesImplLiveApiTest.java @@ -36,38 +36,31 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListVirtualAppliancesImplLiveApiTest") -public class ListVirtualAppliancesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListVirtualAppliancesImpl strategy; +public class ListVirtualAppliancesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualAppliancesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = - env.context.getUtils().getInjector().getInstance(ListVirtualAppliancesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualAppliancesImpl.class); + } - public void testExecute() - { - Iterable vapps = strategy.execute(); - assertNotNull(vapps); - assertTrue(size(vapps) > 0); - } + public void testExecute() { + Iterable vapps = strategy.execute(); + assertNotNull(vapps); + assertTrue(size(vapps) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable vapps = - strategy.execute(VirtualAppliancePredicates.name("UNEXISTING")); - assertNotNull(vapps); - assertEquals(size(vapps), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable vapps = strategy.execute(VirtualAppliancePredicates.name("UNEXISTING")); + assertNotNull(vapps); + assertEquals(size(vapps), 0); + } - public void testExecutePredicateWithResults() - { - Iterable vapps = - strategy.execute(VirtualAppliancePredicates.name(env.virtualAppliance.getName())); - assertNotNull(vapps); - assertEquals(size(vapps), 1); - } + public void testExecutePredicateWithResults() { + Iterable vapps = strategy.execute(VirtualAppliancePredicates.name(env.virtualAppliance + .getName())); + assertNotNull(vapps); + assertEquals(size(vapps), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java index 21048f18ba..1a155baf17 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualDatacentersImplLiveApiTest.java @@ -37,57 +37,45 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListVirtualDatacentersImplLiveApiTest") -public class ListVirtualDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListVirtualDatacentersImpl strategy; +public class ListVirtualDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualDatacentersImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = - env.context.getUtils().getInjector().getInstance(ListVirtualDatacentersImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualDatacentersImpl.class); + } - public void testExecute() - { - Iterable vdcs = strategy.execute(); - assertNotNull(vdcs); - assertTrue(size(vdcs) > 0); - } + public void testExecute() { + Iterable vdcs = strategy.execute(); + assertNotNull(vdcs); + assertTrue(size(vdcs) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable vdcs = - strategy.execute(VirtualDatacenterPredicates.name("UNEXISTING")); - assertNotNull(vdcs); - assertEquals(size(vdcs), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable vdcs = strategy.execute(VirtualDatacenterPredicates.name("UNEXISTING")); + assertNotNull(vdcs); + assertEquals(size(vdcs), 0); + } - public void testExecutePredicateWithResults() - { - Iterable vdcs = - strategy.execute(VirtualDatacenterPredicates.name(env.virtualDatacenter.getName())); - assertNotNull(vdcs); - assertEquals(size(vdcs), 1); - } + public void testExecutePredicateWithResults() { + Iterable vdcs = strategy.execute(VirtualDatacenterPredicates.name(env.virtualDatacenter + .getName())); + assertNotNull(vdcs); + assertEquals(size(vdcs), 1); + } - public void testExecutePredicateOptionsWithResults() - { - Iterable vdcs = - strategy.execute(VirtualDatacenterOptions.builder() - .datacenterId(env.datacenter.getId()).enterpriseId(env.defaultEnterprise.getId()) - .build()); - assertNotNull(vdcs); - assertEquals(size(vdcs), 1); - } + public void testExecutePredicateOptionsWithResults() { + Iterable vdcs = strategy.execute(VirtualDatacenterOptions.builder() + .datacenterId(env.datacenter.getId()).enterpriseId(env.defaultEnterprise.getId()).build()); + assertNotNull(vdcs); + assertEquals(size(vdcs), 1); + } - public void testExecutePredicateOptionsWithoutResults() - { - Iterable vdcs = - strategy.execute(VirtualDatacenterOptions.builder() - .enterpriseId(env.enterprise.getId()).build()); - assertNotNull(vdcs); - assertEquals(size(vdcs), 0); - } + public void testExecutePredicateOptionsWithoutResults() { + Iterable vdcs = strategy.execute(VirtualDatacenterOptions.builder() + .enterpriseId(env.enterprise.getId()).build()); + assertNotNull(vdcs); + assertEquals(size(vdcs), 0); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java index c3e1afc936..4c87e244e9 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/cloud/internal/ListVirtualMachinesImplLiveApiTest.java @@ -39,71 +39,57 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListVirtualMachinesImplLiveApiTest") -public class ListVirtualMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListVirtualMachinesImpl strategy; +public class ListVirtualMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualMachinesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = - env.context.getUtils().getInjector().getInstance(ListVirtualMachinesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachinesImpl.class); + } - public void testExecute() - { - Iterable vms = strategy.execute(); - assertNotNull(vms); - assertTrue(size(vms) > 0); - } + public void testExecute() { + Iterable vms = strategy.execute(); + assertNotNull(vms); + assertTrue(size(vms) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable vms = - strategy.execute(VirtualMachinePredicates.internalName("UNEXISTING")); - assertNotNull(vms); - assertEquals(size(vms), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable vms = strategy.execute(VirtualMachinePredicates.internalName("UNEXISTING")); + assertNotNull(vms); + assertEquals(size(vms), 0); + } - public void testExecutePredicateWithResults() - { - Iterable vms = - strategy.execute(VirtualMachinePredicates.internalName(env.virtualMachine - .getInternalName())); - assertNotNull(vms); - assertEquals(size(vms), 1); - } + public void testExecutePredicateWithResults() { + Iterable vms = strategy.execute(VirtualMachinePredicates.internalName(env.virtualMachine + .getInternalName())); + assertNotNull(vms); + assertEquals(size(vms), 1); + } - public void testExecuteWhenExceedsPagination() - { - List vms = new ArrayList(); + public void testExecuteWhenExceedsPagination() { + List vms = new ArrayList(); - // Pagination by default is set to 25 items per page, so create a few more to verify that - // all are returned when listing - int numVms = 30; + // Pagination by default is set to 25 items per page, so create a few more + // to verify that + // all are returned when listing + int numVms = 30; - for (int i = 0; i < numVms; i++) - { - VirtualMachine vm = - VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).build(); - vm.save(); - vms.add(vm); - } + for (int i = 0; i < numVms; i++) { + VirtualMachine vm = VirtualMachine.Builder.fromVirtualMachine(env.virtualMachine).build(); + vm.save(); + vms.add(vm); + } - try - { - Iterable all = strategy.execute(); + try { + Iterable all = strategy.execute(); - assertNotNull(all); - assertTrue(size(all) >= numVms); - } - finally - { - for (VirtualMachine vm : vms) - { - vm.delete(); - } - } - } + assertNotNull(all); + assertTrue(size(all) >= numVms); + } finally { + for (VirtualMachine vm : vms) { + vm.delete(); + } + } + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java index ca68a97c14..de62bb849f 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListCategoriesImplLiveApiTest.java @@ -39,49 +39,40 @@ import com.google.common.base.Predicates; * @author Francesc Montserrat */ @Test(groups = "api", testName = "ListCategoriesImplLiveApiTest") -public class ListCategoriesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListCategoriesImpl strategy; +public class ListCategoriesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListCategoriesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListCategoriesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListCategoriesImpl.class); + } - public void testExecute() - { - Iterable categories = strategy.execute(); - assertNotNull(categories); - assertTrue(size(categories) > 0); - } + public void testExecute() { + Iterable categories = strategy.execute(); + assertNotNull(categories); + assertTrue(size(categories) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable categories = - strategy.execute(CategoryPredicates.name("Unexisting category")); - assertNotNull(categories); - assertEquals(size(categories), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable categories = strategy.execute(CategoryPredicates.name("Unexisting category")); + assertNotNull(categories); + assertEquals(size(categories), 0); + } - public void testExecutePredicateWithResults() - { - Iterable categories = - strategy.execute(CategoryPredicates.name("Applications servers")); - assertNotNull(categories); - assertEquals(size(categories), 1); - } + public void testExecutePredicateWithResults() { + Iterable categories = strategy.execute(CategoryPredicates.name("Applications servers")); + assertNotNull(categories); + assertEquals(size(categories), 1); + } - public void testExecuteNotPredicateWithResults() - { - Iterable categories = - strategy.execute(Predicates.not(CategoryPredicates.name("Applications servers"))); + public void testExecuteNotPredicateWithResults() { + Iterable categories = strategy.execute(Predicates.not(CategoryPredicates.name("Applications servers"))); - Iterable allProperties = strategy.execute(); + Iterable allProperties = strategy.execute(); - assertNotNull(categories); - assertNotNull(allProperties); - assertEquals(size(categories), size(allProperties) - 1); - } + assertNotNull(categories); + assertNotNull(allProperties); + assertEquals(size(categories), size(allProperties) - 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java index d1e0676a3a..d9776c52f8 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListLicensesImplLiveApiTest.java @@ -37,54 +37,46 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListLicensesImplLiveApiTest") -public class ListLicensesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListLicensesImpl strategy; +public class ListLicensesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListLicensesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListLicensesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListLicensesImpl.class); + } - public void testExecute() - { - Iterable licenses = strategy.execute(); - assertNotNull(licenses); - assertTrue(size(licenses) > 0); - } + public void testExecute() { + Iterable licenses = strategy.execute(); + assertNotNull(licenses); + assertTrue(size(licenses) > 0); + } - public void testExecuteInactive() - { - LicenseOptions options = LicenseOptions.builder().inactive(true).build(); + public void testExecuteInactive() { + LicenseOptions options = LicenseOptions.builder().inactive(true).build(); - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) == 1); - } + Iterable licenses = strategy.execute(options); + assertNotNull(licenses); + assertTrue(size(licenses) == 1); + } - public void testExecuteActive() - { - LicenseOptions options = LicenseOptions.builder().active(true).build(); + public void testExecuteActive() { + LicenseOptions options = LicenseOptions.builder().active(true).build(); - Iterable licenses = strategy.execute(options); - assertNotNull(licenses); - assertTrue(size(licenses) >= 1); - } + Iterable licenses = strategy.execute(options); + assertNotNull(licenses); + assertTrue(size(licenses) >= 1); + } - public void testExecutePredicateWithoutResults() - { - Iterable licenses = strategy.execute(LicensePredicates.customer("FAIL")); - assertNotNull(licenses); - assertEquals(size(licenses), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable licenses = strategy.execute(LicensePredicates.customer("FAIL")); + assertNotNull(licenses); + assertEquals(size(licenses), 0); + } - public void testExecutePredicateWithResults() - { - Iterable licenses = - strategy.execute(LicensePredicates.code(env.license.getCode())); - assertNotNull(licenses); - assertEquals(size(licenses), 1); - } + public void testExecutePredicateWithResults() { + Iterable licenses = strategy.execute(LicensePredicates.code(env.license.getCode())); + assertNotNull(licenses); + assertEquals(size(licenses), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java index f379f6c6cf..eea2ebc953 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPrivilegesImplLiveApiTest.java @@ -38,49 +38,40 @@ import com.google.common.base.Predicates; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListPrivilegesImplLiveApiTest") -public class ListPrivilegesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListPrivilegesImpl strategy; +public class ListPrivilegesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListPrivilegesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPrivilegesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListPrivilegesImpl.class); + } - public void testExecute() - { - Iterable privileges = strategy.execute(); - assertNotNull(privileges); - assertTrue(size(privileges) > 0); - } + public void testExecute() { + Iterable privileges = strategy.execute(); + assertNotNull(privileges); + assertTrue(size(privileges) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable privileges = - strategy.execute(PrivilegePredicates.name("Destroy the universe")); - assertNotNull(privileges); - assertEquals(size(privileges), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable privileges = strategy.execute(PrivilegePredicates.name("Destroy the universe")); + assertNotNull(privileges); + assertEquals(size(privileges), 0); + } - public void testExecutePredicateWithResults() - { - Iterable privileges = - strategy.execute(PrivilegePredicates.name("USERS_MANAGE_USERS")); - assertNotNull(privileges); - assertEquals(size(privileges), 1); - } + public void testExecutePredicateWithResults() { + Iterable privileges = strategy.execute(PrivilegePredicates.name("USERS_MANAGE_USERS")); + assertNotNull(privileges); + assertEquals(size(privileges), 1); + } - public void testExecuteNotPredicateWithResults() - { - Iterable privileges = - strategy.execute(Predicates.not(PrivilegePredicates.name("USERS_MANAGE_USERS"))); + public void testExecuteNotPredicateWithResults() { + Iterable privileges = strategy.execute(Predicates.not(PrivilegePredicates.name("USERS_MANAGE_USERS"))); - Iterable allPrivileges = strategy.execute(); + Iterable allPrivileges = strategy.execute(); - assertNotNull(privileges); - assertNotNull(allPrivileges); - assertEquals(size(privileges), size(allPrivileges) - 1); - } + assertNotNull(privileges); + assertNotNull(allPrivileges); + assertEquals(size(privileges), size(allPrivileges) - 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java index 26eb511490..28e747e5e3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/config/internal/ListPropertiesImplLiveApiTest.java @@ -40,60 +40,50 @@ import com.google.common.base.Predicates; * @author Francesc Montserrat */ @Test(groups = "api", testName = "ListPropertiesImplLiveApiTest") -public class ListPropertiesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListPropertiesImpl strategy; +public class ListPropertiesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListPropertiesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListPropertiesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListPropertiesImpl.class); + } - public void testExecute() - { - Iterable properties = strategy.execute(); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } + public void testExecute() { + Iterable properties = strategy.execute(); + assertNotNull(properties); + assertTrue(size(properties) > 0); + } - public void testExecuteWithOptions() - { - PropertyOptions options = PropertyOptions.builder().component("client").build(); + public void testExecuteWithOptions() { + PropertyOptions options = PropertyOptions.builder().component("client").build(); - Iterable properties = strategy.execute(options); - assertNotNull(properties); - assertTrue(size(properties) > 0); - } + Iterable properties = strategy.execute(options); + assertNotNull(properties); + assertTrue(size(properties) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable properties = - strategy.execute(SystemPropertyPredicates.name("Cloud color")); - assertNotNull(properties); - assertEquals(size(properties), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable properties = strategy.execute(SystemPropertyPredicates.name("Cloud color")); + assertNotNull(properties); + assertEquals(size(properties), 0); + } - public void testExecutePredicateWithResults() - { - Iterable properties = - strategy.execute(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval")); - assertNotNull(properties); - assertEquals(size(properties), 1); - } + public void testExecutePredicateWithResults() { + Iterable properties = strategy.execute(SystemPropertyPredicates + .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval")); + assertNotNull(properties); + assertEquals(size(properties), 1); + } - public void testExecuteNotPredicateWithResults() - { - Iterable properties = - strategy.execute(Predicates.not(SystemPropertyPredicates - .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval"))); + public void testExecuteNotPredicateWithResults() { + Iterable properties = strategy.execute(Predicates.not(SystemPropertyPredicates + .name("client.applibrary.ovfpackagesDownloadingProgressUpdateInterval"))); - Iterable allProperties = strategy.execute(); + Iterable allProperties = strategy.execute(); - assertNotNull(properties); - assertNotNull(allProperties); - assertEquals(size(properties), size(allProperties) - 1); - } + assertNotNull(properties); + assertNotNull(allProperties); + assertEquals(size(properties), size(allProperties) - 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java index 6175710cbc..13f1167e2d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListEnterprisesImplLiveApiTest.java @@ -36,37 +36,30 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListEnterprisesImplLiveApiTest") -public class ListEnterprisesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListEnterprisesImpl strategy; +public class ListEnterprisesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListEnterprisesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListEnterprisesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListEnterprisesImpl.class); + } - public void testExecute() - { - Iterable enterprises = strategy.execute(); - assertNotNull(enterprises); - assertTrue(size(enterprises) > 0); - } + public void testExecute() { + Iterable enterprises = strategy.execute(); + assertNotNull(enterprises); + assertTrue(size(enterprises) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable enterprises = - strategy.execute(EnterprisePredicates.name("UNEXISTING")); - assertNotNull(enterprises); - assertEquals(size(enterprises), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable enterprises = strategy.execute(EnterprisePredicates.name("UNEXISTING")); + assertNotNull(enterprises); + assertEquals(size(enterprises), 0); + } - public void testExecutePredicateWithResults() - { - Iterable enterprises = - strategy.execute(EnterprisePredicates.name(env.enterprise.getName())); - assertNotNull(enterprises); - assertEquals(size(enterprises), 1); - } + public void testExecutePredicateWithResults() { + Iterable enterprises = strategy.execute(EnterprisePredicates.name(env.enterprise.getName())); + assertNotNull(enterprises); + assertEquals(size(enterprises), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java index 3a8170977e..20b739608a 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/enterprise/internal/ListVirtualMachineTemplatesImplLiveApiTest.java @@ -37,41 +37,33 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListVirtualMachineTemplatesImplLiveApiTest") -public class ListVirtualMachineTemplatesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListVirtualMachineTemplatesImpl strategy; +public class ListVirtualMachineTemplatesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListVirtualMachineTemplatesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = - env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplatesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListVirtualMachineTemplatesImpl.class); + } - public void testExecute() - { - Iterable templates = strategy.execute(env.defaultEnterprise); - assertNotNull(templates); - assertTrue(size(templates) > 0); - } + public void testExecute() { + Iterable templates = strategy.execute(env.defaultEnterprise); + assertNotNull(templates); + assertTrue(size(templates) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable templates = - strategy.execute(env.defaultEnterprise, - VirtualMachineTemplatePredicates.name("UNEXISTING")); - assertNotNull(templates); - assertEquals(size(templates), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable templates = strategy.execute(env.defaultEnterprise, + VirtualMachineTemplatePredicates.name("UNEXISTING")); + assertNotNull(templates); + assertEquals(size(templates), 0); + } - public void testExecutePredicateWithResults() - { - Iterable templates = - strategy.execute(env.defaultEnterprise, - VirtualMachineTemplatePredicates.name(env.template.getName())); - assertNotNull(templates); - // Repository can have multiple templates with the same name - assertTrue(size(templates) > 0); - } + public void testExecutePredicateWithResults() { + Iterable templates = strategy.execute(env.defaultEnterprise, + VirtualMachineTemplatePredicates.name(env.template.getName())); + assertNotNull(templates); + // Repository can have multiple templates with the same name + assertTrue(size(templates) > 0); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java index 33aca3a096..391c46c857 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListDatacentersImplLiveApiTest.java @@ -36,37 +36,30 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListDatacentersImplLiveApiTest") -public class ListDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListDatacentersImpl strategy; +public class ListDatacentersImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListDatacentersImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListDatacentersImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListDatacentersImpl.class); + } - public void testExecute() - { - Iterable datacenters = strategy.execute(); - assertNotNull(datacenters); - assertTrue(size(datacenters) > 0); - } + public void testExecute() { + Iterable datacenters = strategy.execute(); + assertNotNull(datacenters); + assertTrue(size(datacenters) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable datacenters = - strategy.execute(DatacenterPredicates.name("UNEXISTING")); - assertNotNull(datacenters); - assertEquals(size(datacenters), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable datacenters = strategy.execute(DatacenterPredicates.name("UNEXISTING")); + assertNotNull(datacenters); + assertEquals(size(datacenters), 0); + } - public void testExecutePredicateWithResults() - { - Iterable datacenters = - strategy.execute(DatacenterPredicates.name(env.datacenter.getName())); - assertNotNull(datacenters); - assertEquals(size(datacenters), 1); - } + public void testExecutePredicateWithResults() { + Iterable datacenters = strategy.execute(DatacenterPredicates.name(env.datacenter.getName())); + assertNotNull(datacenters); + assertEquals(size(datacenters), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java index 206a15d29d..b739f42623 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/strategy/infrastructure/internal/ListMachinesImplLiveApiTest.java @@ -36,36 +36,30 @@ import org.testng.annotations.Test; * @author Ignasi Barrera */ @Test(groups = "api", testName = "ListMachinesImplLiveApiTest") -public class ListMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest -{ - private ListMachinesImpl strategy; +public class ListMachinesImplLiveApiTest extends BaseAbiquoStrategyLiveApiTest { + private ListMachinesImpl strategy; - @Override - @BeforeClass(groups = "api") - protected void setupStrategy() - { - this.strategy = env.context.getUtils().getInjector().getInstance(ListMachinesImpl.class); - } + @Override + @BeforeClass(groups = "api") + protected void setupStrategy() { + this.strategy = env.context.getUtils().getInjector().getInstance(ListMachinesImpl.class); + } - public void testExecute() - { - Iterable machines = strategy.execute(); - assertNotNull(machines); - assertTrue(size(machines) > 0); - } + public void testExecute() { + Iterable machines = strategy.execute(); + assertNotNull(machines); + assertTrue(size(machines) > 0); + } - public void testExecutePredicateWithoutResults() - { - Iterable machines = strategy.execute(MachinePredicates.name("UNEXISTING")); - assertNotNull(machines); - assertEquals(size(machines), 0); - } + public void testExecutePredicateWithoutResults() { + Iterable machines = strategy.execute(MachinePredicates.name("UNEXISTING")); + assertNotNull(machines); + assertEquals(size(machines), 0); + } - public void testExecutePredicateWithResults() - { - Iterable machines = - strategy.execute(MachinePredicates.name(env.machine.getName())); - assertNotNull(machines); - assertEquals(size(machines), 1); - } + public void testExecutePredicateWithResults() { + Iterable machines = strategy.execute(MachinePredicates.name(env.machine.getName())); + assertNotNull(machines); + assertEquals(size(machines), 1); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Assert.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Assert.java index e2914fb986..dcbf9d8904 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Assert.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Assert.java @@ -39,39 +39,43 @@ import com.abiquo.model.transport.error.ErrorDto; * * @author Ignasi Barrera */ -public class Assert -{ - /** - * Assert that the exception contains the given error. - * - * @param exception The exception. - * @param expectedHttpStatus The expected HTTP status code. - * @param expectedErrorCode The expected error code. - */ - public static void assertHasError(final AbiquoException exception, - final Status expectedHttpStatus, final String expectedErrorCode) - { - assertEquals(exception.getHttpStatus(), expectedHttpStatus); - ErrorDto error = exception.findError(expectedErrorCode); - assertNotNull(error); - } +public class Assert { + /** + * Assert that the exception contains the given error. + * + * @param exception + * The exception. + * @param expectedHttpStatus + * The expected HTTP status code. + * @param expectedErrorCode + * The expected error code. + */ + public static void assertHasError(final AbiquoException exception, final Status expectedHttpStatus, + final String expectedErrorCode) { + assertEquals(exception.getHttpStatus(), expectedHttpStatus); + ErrorDto error = exception.findError(expectedErrorCode); + assertNotNull(error); + } - /** - * Assert that the given payload matches the given string. - * - * @param payload The payload to check. - * @param expected The expected string. - * @param entityClass The entity class for the payload. - * @throws IOException If there is an error during serialization. - */ - public static void assertPayloadEquals(final Payload payload, final String expected, - final Class< ? extends SingleResourceTransportDto> entityClass) throws IOException - { - // Serialize and deserialize to avoid formatting issues - XMLParser xml = new JAXBParser("false"); - SingleResourceTransportDto entity = xml.fromXML(expected, entityClass); - String toMatch = xml.toXML(entity, entityClass); + /** + * Assert that the given payload matches the given string. + * + * @param payload + * The payload to check. + * @param expected + * The expected string. + * @param entityClass + * The entity class for the payload. + * @throws IOException + * If there is an error during serialization. + */ + public static void assertPayloadEquals(final Payload payload, final String expected, + final Class entityClass) throws IOException { + // Serialize and deserialize to avoid formatting issues + XMLParser xml = new JAXBParser("false"); + SingleResourceTransportDto entity = xml.fromXML(expected, entityClass); + String toMatch = xml.toXML(entity, entityClass); - assertEquals(payload.getRawContent(), toMatch); - } + assertEquals(payload.getRawContent(), toMatch); + } } diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Config.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Config.java index 4b438aa464..f2c2eae504 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Config.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/util/Config.java @@ -29,51 +29,42 @@ import java.util.Properties; * * @author Ignasi Barrera */ -public class Config -{ - /** The main configuration file. */ - private static final String CONFIG_FILE = "api-live.properties"; +public class Config { + /** The main configuration file. */ + private static final String CONFIG_FILE = "api-live.properties"; - /** The configuration properties */ - private Properties config; + /** The configuration properties */ + private Properties config; - /** The singleton configuration instance. */ - private static Config instance; + /** The singleton configuration instance. */ + private static Config instance; - public Config(final String config) - { - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - this.config = new Properties(); + public Config(final String config) { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + this.config = new Properties(); - try - { - this.config.load(cl.getResourceAsStream(config)); - } - catch (IOException ex) - { - throw new RuntimeException("Could not load test configuration file", ex); - } - } + try { + this.config.load(cl.getResourceAsStream(config)); + } catch (IOException ex) { + throw new RuntimeException("Could not load test configuration file", ex); + } + } - public Config(final Properties config) - { - this.config = config; - } + public Config(final Properties config) { + this.config = config; + } - public static String get(final String property) - { - return get(property, null); - } + public static String get(final String property) { + return get(property, null); + } - public static String get(final String property, final String defaultValue) - { - if (instance == null) - { - String configFile = System.getProperty("abiquo.live.config", CONFIG_FILE); - instance = new Config(configFile); - } + public static String get(final String property, final String defaultValue) { + if (instance == null) { + String configFile = System.getProperty("abiquo.live.config", CONFIG_FILE); + instance = new Config(configFile); + } - return checkNotNull(instance.config.getProperty(property, defaultValue)); - } + return checkNotNull(instance.config.getProperty(property, defaultValue)); + } }